http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestCompilationUnit.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestCompilationUnit.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestCompilationUnit.java deleted file mode 100644 index 820dfc7..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestCompilationUnit.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestCompilationUnit extends AbstractAs3ParserTest -{ - @Test - public void testEmptyPackage() throws TokenException - { - assertCompilationUnit( "1", - "package a { } ", - "<compilation-unit line=\"-1\">" - + "<package line=\"1\">" + "<name line=\"1\">a" - + "</name><content line=\"1\">" - + "</content></package><content line=\"2\">" - + "</content></compilation-unit>" ); - } - - @Test - public void testEmptyPackagePlusLocalClass() throws TokenException - { - assertCompilationUnit( "1", - "package a { } class Local { }", - "<compilation-unit line=\"-1\"><package line=\"1\">" - + "<name line=\"1\">a</name><content line=\"1\">" - + "</content></package><content line=\"1\"><class line=\"1\"" - + "><name line=\"1\">Local</name>" - + "<mod-list line=\"1\"></mod-list><content line=\"1\">" - + "</content></class></content></compilation-unit>" ); - } - - @Test - public void testPackageWithClass() throws TokenException - { - assertCompilationUnit( "1", - "package a { public class B { } } ", - "<compilation-unit line=\"-1\"><package line=\"1\">" - + "<name line=\"1\">a</name><content line=\"1\">" - + "<class line=\"1\"><name line=\"1\">B</name>" - + "<mod-list line=\"1\"><mod line=\"1\">public" - + "</mod></mod-list><content line=\"1\"></content>" - + "</class></content></package><content line=\"2\">" - + "</content></compilation-unit>" ); - } - - @Test - public void testPackageWithInterface() throws TokenException - { - assertCompilationUnit( "1", - "package a { public interface B { } } ", - "<compilation-unit line=\"-1\"><package line=\"1\">" - + "<name line=\"1\">a</name><content line=\"1\">" - + "<interface line=\"1\"><name line=\"1\">B</name>" - + "<mod-list line=\"1\"><mod line=\"1\">public</mod>" - + "</mod-list><content line=\"1\"></content></interface>" - + "</content></package><content line=\"2\"></content>" - + "</compilation-unit>" ); - } - - private void assertCompilationUnit( final String message, - final String input, - final String expected ) throws TokenException - { - scn.setLines( new String[] - { input, - "__END__" } ); - final String result = new ASTToXMLConverter().convert( asp.parseCompilationUnit() ); - assertEquals( message, - expected, - result ); - } -}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestConstStatement.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestConstStatement.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestConstStatement.java deleted file mode 100644 index ccfb640..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestConstStatement.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestConstStatement extends AbstractStatementTest -{ - @Test - public void testFullFeaturedConst() throws TokenException - { - assertStatement( "1", - "const a : int = 4", - "<const-list line=\"1\">" - + "<name-type-init line=\"1\">" - + "<name line=\"1\">a</name><type line=\"1\">int</type>" - + "<init line=\"1\"><primary line=\"1\">4</primary>" - + "</init></name-type-init></const-list>" ); - } - - @Test - public void testInitializedConst() throws TokenException - { - assertStatement( "1", - "const a = 4", - "<const-list line=\"1\"><name-type-init line=\"1\">" - + "<name line=\"1\">a</name><type line=\"1\">" - + "</type><init line=\"1\"><primary line=\"1\">4" - + "</primary></init></name-type-init></const-list>" ); - } - - @Test - public void testSimpleConst() throws TokenException - { - assertStatement( "1", - "const a", - "<const-list line=\"1\"><name-type-init line=\"1\">" - + "<name line=\"1\">a</name><type line=\"2\">" - + "</type></name-type-init></const-list>" ); - } - - @Test - public void testTypedConst() throws TokenException - { - assertStatement( "1", - "const a : Object", - "<const-list line=\"1\"><name-type-init line=\"1\">" - + "<name line=\"1\">a</name><type line=\"1\">Object</type>" - + "</name-type-init></const-list>" ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestDoStatement.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestDoStatement.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestDoStatement.java deleted file mode 100644 index a66d2dd..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestDoStatement.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestDoStatement extends AbstractStatementTest -{ - @Test - public void testDo() throws TokenException - { - assertStatement( "1", - "do{ trace( i ); } while( i++ );", - "<do line=\"1\"><block line=\"1\">" - + "<call line=\"1\"><primary line=\"1\">" - + "trace</primary><arguments line=\"1\">" - + "<primary line=\"1\">i</primary></arguments>" - + "</call></block><condition line=\"1\">" - + "<post-inc line=\"1\"><primary line=\"1\">" - + "i</primary></post-inc></condition></do>" ); - } - - @Test - public void testDoWithEmptyStatement() throws TokenException - { - assertStatement( "1", - "do ; while( i++ ); ", - "<do line=\"1\"><stmt-empty line=\"1\">;</stmt-empty>" - + "<condition line=\"1\"><post-inc line=\"1\">" - + "<primary line=\"1\">i</primary></post-inc></condition></do>" ); - } - - @Test - public void testDoWithoutBlock() throws TokenException - { - assertStatement( "1", - "do trace( i ); while( i++ ); ", - "<do line=\"1\"><call line=\"1\">" - + "<primary line=\"1\">trace</primary><arguments line=\"1\"" - + "><primary line=\"1\">i</primary>" - + "</arguments></call><condition line=\"1\">" - + "<post-inc line=\"1\"><primary line=\"1\"" - + ">i</primary></post-inc></condition></do>" ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestE4xExpression.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestE4xExpression.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestE4xExpression.java deleted file mode 100644 index 7d6f874..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestE4xExpression.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestE4xExpression extends AbstractStatementTest -{ - @Test - public void testE4xFilter() throws TokenException - { - assertStatement( "", - "myXml.(lala=\"lala\")", - "<e4x-filter line=\"1\"><primary line=\"1\">myXml" - + "</primary><assign line=\"1\"><primary line=\"1\">" - + "lala</primary><op line=\"1\">=</op><primary line=\"1\">" - + "\"lala\"</primary></assign></e4x-filter>" ); - - assertStatement( "", - "doc.*.worm[1]", - "<mul line=\"1\"><e4x-star line=\"1\"><primary line=\"1\"" - + ">doc</primary></e4x-star><op line=\"1\">*</op><primary " - + "line=\"1\">.</primary></mul>" ); - - assertStatement( "", - "doc.@worm", - "<dot line=\"1\"><primary line=\"1\">doc</primary><primary " - + "line=\"1\">@worm</primary></dot>" ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestEmptyStatement.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestEmptyStatement.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestEmptyStatement.java deleted file mode 100644 index 6133b33..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestEmptyStatement.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestEmptyStatement extends AbstractStatementTest -{ - @Test - public void testComplex() throws TokenException - { - assertStatement( "1", - "{;1;;}", - "<block line=\"1\"><stmt-empty line=\"1\">;" - + "</stmt-empty><primary line=\"1\">1" - + "</primary><stmt-empty line=\"1\">;</stmt-empty></block>" ); - } - - @Test - public void testSimple() throws TokenException - { - assertStatement( "1", - ";", - "<stmt-empty line=\"1\">;</stmt-empty>" ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestExpression.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestExpression.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestExpression.java deleted file mode 100644 index 16308c9..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestExpression.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestExpression extends AbstractStatementTest -{ - @Test - public void testAddExpression() throws TokenException - { - assertStatement( "1", - "5+6", - "<add line=\"1\"><primary line=\"1\"" - + ">5</primary><op line=\"1\">+</op>" + "<primary line=\"1\">6</primary></add>" ); - } - - @Test - public void testAndExpression() throws TokenException - { - assertStatement( "1", - "5&&6", - "<and line=\"1\"><primary line=\"1\">5</primary>" - + "<op line=\"1\">&&</op>" + "<primary line=\"1\">6</primary></and>" ); - } - - @Test - public void testAssignmentExpression() throws TokenException - { - assertStatement( "1", - "x+=6", - "<assign line=\"1\"><primary line=\"1\">x" - + "</primary><op line=\"1\">+=</op><primary line=\"1\"" - + ">6</primary></assign>" ); - } - - @Test - public void testBitwiseAndExpression() throws TokenException - { - assertStatement( "1", - "5&6", - "<b-and line=\"1\"><primary line=\"1\">5" - + "</primary><op line=\"1\">&</op><primary line=\"1\">6</primary></b-and>" ); - } - - @Test - public void testBitwiseOrExpression() throws TokenException - { - assertStatement( "1", - "5|6", - "<b-or line=\"1\"><primary line=\"1\">5" - + "</primary><op line=\"1\">|</op><primary line=\"1\">6</primary></b-or>" ); - } - - @Test - public void testBitwiseXorExpression() throws TokenException - { - assertStatement( "1", - "5^6", - "<b-xor line=\"1\"><primary line=\"1\">5" - + "</primary><op line=\"1\">^</op><primary line=\"1\">6</primary></b-xor>" ); - } - - @Test - public void testConditionalExpression() throws TokenException - { - assertStatement( "1", - "true?5:6", - "<conditional line=\"1\"><primary line=\"1\">" - + "true</primary><primary line=\"1\">5" + "</primary><primary line=\"1\">6" - + "</primary></conditional>" ); - } - - @Test - public void testDivision() throws TokenException - { - assertStatement( "", - "offset = ( this[ axis.unscaled ] / 2 - ( rightPos ) / 2 );", - "<assign line=\"1\"><primary line=\"1\">offset</primary><op line=\"1\">=</op>" - + "<primary line=\"1\"><encapsulated line=\"1\"><add line=\"1\"><mul line=\"1\">" - + "<arr-acc line=\"1\"><primary line=\"1\">this</primary><dot line=\"1\"><primary " - + "line=\"1\">axis</primary><primary line=\"1\">unscaled</primary></dot></arr-acc>" - + "<op line=\"1\">/</op><primary line=\"1\">2</primary></mul><op line=\"1\">-</op>" - + "<mul line=\"1\"><primary line=\"1\"><encapsulated line=\"1\"><primary line=\"1\">" - + "rightPos</primary></encapsulated></primary><op line=\"1\">/</op><primary line=\"1\">" - + "2</primary></mul></add></encapsulated></primary></assign>" ); - } - - @Test - public void testEncapsulated() throws TokenException - { - assertStatement( "", - "(dataProvider as ArrayCollection) = null", - "<assign line=\"1\"><primary line=\"1\">" - + "<encapsulated line=\"1\"><relation line=\"1\">" - + "<primary line=\"1\">dataProvider</primary>" - + "<as line=\"1\">as</as><primary line=\"1\">" - + "ArrayCollection</primary></relation></encapsulated></primary>" - + "<op line=\"1\">=</op><primary line=\"1\">" + "null</primary></assign>" ); - } - - @Test - public void testEqualityExpression() throws TokenException - { - assertStatement( "1", - "5!==6", - "<equality line=\"1\"><primary line=\"1\">5" - + "</primary><op line=\"1\">!==</op><primary line=\"1\">6</primary></equality>" ); - } - - @Test - public void testExpressionList() throws TokenException - { - assertStatement( "1", - "5&&6,5&&9", - "<expr-list line=\"1\"><and line=\"1\">" - + "<primary line=\"1\">5</primary><op line=\"1\">" - + "&&</op><primary line=\"1\">6</primary></and><and line=\"1\"" - + "><primary line=\"1\">5</primary><op line=\"1\"" - + ">&&</op><primary line=\"1\">9</primary></and></expr-list>" ); - } - - @Test - public void testInstanceOf() throws TokenException - { - assertStatement( "bug237", - "if (a instanceof b){}", - "<if line=\"1\"><condition line=\"1\"><relation line=\"1\"><primary " - + "line=\"1\">a</primary><op line=\"1\">instanceof</op><primary line=\"1\">" - + "b</primary></relation></condition><block line=\"1\"></block></if>" ); - } - - @Test - public void testMulExpression() throws TokenException - { - assertStatement( "1", - "5/6", - "<mul line=\"1\"><primary line=\"1\">5" - + "</primary><op line=\"1\">/</op><primary line=\"1\">6</primary></mul>" ); - } - - @Test - public void testNewExpression() throws TokenException - { - assertStatement( "", - "new Event()", - "<new line=\"1\"><call line=\"1\">" - + "<primary line=\"1\">Event</primary>" - + "<arguments line=\"1\"></arguments></call></new>" ); - - assertStatement( "", - "new Event(\"lala\")", - "<new line=\"1\"><call line=\"1\">" - + "<primary line=\"1\">Event</primary>" - + "<arguments line=\"1\"><primary line=\"1\">" - + "\"lala\"</primary></arguments></call></new>" ); - - } - - @Test - public void testOrExpression() throws TokenException - { - assertStatement( "1", - "5||6", - "<or line=\"1\"><primary line=\"1\">5" - + "</primary><op line=\"1\">||</op><primary line=\"1\">6</primary></or>" ); - } - - @Test - public void testRelationalExpression() throws TokenException - { - assertStatement( "1", - "5<=6", - "<relation line=\"1\"><primary line=\"1\">5" - + "</primary><op line=\"1\"><=</op><primary line=\"1\"" - + ">6</primary></relation>" ); - } - - @Test - public void testShiftExpression() throws TokenException - { - assertStatement( "1", - "5<<6", - "<shift line=\"1\"><primary line=\"1\">5" - + "</primary><op line=\"1\"><<</op><primary line=\"1\"" - + ">6</primary></shift>" ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestForStatement.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestForStatement.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestForStatement.java deleted file mode 100644 index afafbf2..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestForStatement.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestForStatement extends AbstractStatementTest -{ - @Test - public void testSimpleFor() throws TokenException - { - assertStatement( "1", - "for( var i : int = 0; i < length; i++ ){ trace( i ); }", - "<for line=\"1\"><init line=\"1\">" - + "<var-list line=\"1\"><name-type-init line=\"1\"" - + "><name line=\"1\">i</name><type line=\"1\">int</type><init line=\"1\">" - + "<primary line=\"1\">0</primary></init>" - + "</name-type-init></var-list></init>" - + "<cond line=\"1\"><relation line=\"1\">" - + "<primary line=\"1\">i</primary><op line=\"1\"" - + "><</op><primary line=\"1\">length" - + "</primary></relation></cond><iter line=\"1\">" - + "<post-inc line=\"1\"><primary line=\"1\">i" - + "</primary></post-inc></iter><block line=\"1\"><call line=\"1\"" - + "><primary line=\"1\">trace" - + "</primary><arguments line=\"1\"><primary line=\"1\">i" - + "</primary></arguments></call></block></for>" ); - - assertStatement( "", - " for (i = 0; i < n; i++)", - "<for line=\"1\"><init line=\"1\">" - + "<assign line=\"1\"><primary line=\"1\">i</primary><op line=\"1\">=</op>" - + "<primary line=\"1\">0</primary></assign></init>" - + "<cond line=\"1\"><relation line=\"1\"><primary line=\"1\">i</primary>" - + "<op line=\"1\"><</op><primary line=\"1\">n" - + "</primary></relation></cond><iter line=\"1\">" - + "<post-inc line=\"1\"><primary line=\"1\">i" - + "</primary></post-inc></iter><primary line=\"2\">__END__</primary></for>" ); - } - - @Test - public void testSimpleForEach() throws TokenException - { - assertStatement( "1", - "for each( var obj : Object in list ){ obj.print( i ); }", - "<foreach line=\"1\"><var line=\"1\">" - + "<name-type-init line=\"1\"><name line=\"1\"" - + ">obj</name><type line=\"1\">Object" - + "</type></name-type-init></var><in line=\"1\">" - + "<primary line=\"1\">list</primary></in>" - + "<block line=\"1\"><dot line=\"1\">" - + "<primary line=\"1\">obj</primary><call line=\"1\"" - + "><primary line=\"1\">print</primary>" - + "<arguments line=\"1\"><primary line=\"1\">" - + "i</primary></arguments></call></dot></block></foreach>" ); - - assertStatement( "1", - "for each( obj in list ){}", - "<foreach line=\"1\"><name line=\"1\">obj</name>" - + "<in line=\"1\"><primary line=\"1\">list</primary>" - + "</in><block line=\"1\"></block></foreach>" ); - - // assertStatement( - // "", "for each (var a:XML in classInfo..accessor) {}", "" ); - } - - @Test - public void testSimpleForIn() throws TokenException - { - assertStatement( "1", - "for( var s : String in obj ){ trace( s, obj[ s ]); }", - "<forin line=\"1\"><init line=\"1\">" - + "<var-list line=\"1\"><name-type-init line=\"1\"" - + "><name line=\"1\">s</name>" - + "<type line=\"1\">String</type></name-type-init>" - + "</var-list></init><in line=\"1\"><primary line=\"1\"" - + ">obj</primary></in></forin>" ); - - assertStatement( "for in", - " for (p in events);", - "<forin line=\"1\"><init line=\"1\">" - + "<primary line=\"1\">p</primary></init><in line=\"1\"" - + "><primary line=\"1\">events</primary></in></forin>" ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestIfStatement.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestIfStatement.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestIfStatement.java deleted file mode 100644 index aecc7c2..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestIfStatement.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestIfStatement extends AbstractStatementTest -{ - @Test - public void testBug232() throws TokenException - { - assertStatement( "", - "if (true || /* comment */!false) ) )", - "<if line=\"1\"><condition line=\"1\"><or line=\"1\"><primary line=\"1\">" - + "true</primary><op line=\"1\">||</op><not line=\"1\"><primary " - + "line=\"1\">false</primary></not></or></condition><primary " - + "line=\"1\">)</primary></if>" ); - } - - @Test - public void testIf() throws TokenException - { - assertStatement( "1", - "if( true ){ trace( true ); }", - "<if line=\"1\">" - + "<condition line=\"1\">" + "<primary line=\"1\">true</primary></condition>" - + "<block line=\"1\"><call line=\"1\">" + "<primary line=\"1\">trace" - + "</primary><arguments line=\"1\">" + "<primary line=\"1\">true</primary>" - + "</arguments></call></block></if>" ); - - assertStatement( "1", - "if( \"i\" in oaderContext ){ }", - "<if line=\"1\"><condition line=\"1\">" - + "<relation line=\"1\"><primary line=\"1\">" - + "\"i\"</primary><op line=\"1\">in</op>" - + "<primary line=\"1\">oaderContext</primary>" - + "</relation></condition><block line=\"1\"></block></if>" ); - - assertStatement( "internal", - "if (col.mx_internal::contentSize) {col.mx_internal::_width = NaN;}", - "<if line=\"1\"><condition line=\"1\">" - + "<dot line=\"1\"><primary line=\"1\">col" - + "</primary><dot line=\"1\"><primary line=\"1\">" - + "mx_internal</primary><primary line=\"1\">contentSize" - + "</primary></dot></dot></condition><block line=\"1\">" - + "<dot line=\"1\"><primary line=\"1\">col" - + "</primary><dot line=\"1\"><primary line=\"1\">" - + "mx_internal</primary><assign line=\"1\">" - + "<primary line=\"1\">_width</primary>" - + "<op line=\"1\">=</op><primary line=\"1\">" - + "NaN</primary></assign></dot></dot></block></if>" ); - } - - @Test - public void testIfElse() throws TokenException - { - assertStatement( "1", - "if( true ){ trace( true ); } else { trace( false )}", - "<if line=\"1\"><condition line=\"1\">" - + "<primary line=\"1\">true" + "</primary></condition><block line=\"1\">" - + "<call line=\"1\"><primary line=\"1\">trace" - + "</primary><arguments line=\"1\">" - + "<primary line=\"1\">true</primary></arguments>" - + "</call></block><block line=\"1\">" + "<call line=\"1\">" - + "<primary line=\"1\">trace</primary>" + "<arguments line=\"1\">" - + "<primary line=\"1\">false</primary>" + "</arguments></call></block></if>" ); - } - - @Test - public void testIfWithArrayAccessor() throws TokenException - { - assertStatement( "", - "if ( chart.getItemAt( 0 )[ xField ] > targetXFieldValue ){}", - "<if line=\"1\"><condition line=\"1\"><dot line=\"1\"" - + "><primary line=\"1\">chart</primary><relation line=\"1\"" - + "><call line=\"1\"><primary line=\"1\"" - + ">getItemAt</primary><arguments line=\"1\"" + "><primary line=\"1\"" - + ">0</primary></arguments><array line=\"1\"" + "><primary line=\"1\"" - + ">xField</primary></array></call><op line=\"1\"" + ">></op><primary " - + "line=\"1\">targetXFieldValue</primary>" - + "</relation></dot></condition><block line=\"1\"" + "></block></if>" ); - } - - @Test - public void testIfWithEmptyStatement() throws TokenException - { - assertStatement( "1", - "if( i++ ); ", - "<if line=\"1\"><condition line=\"1\">" - + "<post-inc line=\"1\"><primary line=\"1\">" - + "i</primary></post-inc></condition><stmt-empty line=\"1\">;" - + "</stmt-empty></if>" ); - } - - @Test - public void testIfWithoutBlock() throws TokenException - { - assertStatement( "1", - "if( i++ ) trace( i ); ", - "<if line=\"1\"><condition line=\"1\">" - + "<post-inc line=\"1\"><primary line=\"1\">i" - + "</primary></post-inc></condition><call line=\"1\">" - + "<primary line=\"1\">trace</primary><arguments line=\"1\"" - + "><primary line=\"1\">i</primary>" + "</arguments></call></if>" ); - } - - @Test - public void testIfWithReturn() throws TokenException - { - assertStatement( "", - "if ( true )return;", - "<if line=\"1\"><condition line=\"1\"><primary line=\"1\"" - + ">true</primary></condition><return line=\"2\"" + "></return></if>" ); - - assertStatement( "", - "if ( true )throw new Error();", - "<if line=\"1\"><condition line=\"1\"><primary line=\"1\"" - + ">true</primary></condition><primary line=\"1\">" + "throw</primary></if>" ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestInterface.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestInterface.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestInterface.java deleted file mode 100644 index 6cc46ae..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestInterface.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestInterface extends AbstractAs3ParserTest -{ - @Test - public void testExtends() throws TokenException - { - assertPackageContent( "1", - "public interface A extends B { } ", - "<content line=\"2\"><interface line=\"2\">" - + "<name line=\"2\">A</name><mod-list line=\"2\">" - + "<mod line=\"2\">public</mod>" - + "</mod-list><extends line=\"2\">B</extends>" - + "<content line=\"2\"></content></interface></content>" ); - - assertPackageContent( "", - " public interface ITimelineEntryRenderer extends IFlexDisplayObject, IDataRenderer{}", - "<content line=\"2\"><interface line=\"2\"><name line=\"2\"" - + ">ITimelineEntryRenderer</name><mod-list line=\"2\">" - + "<mod line=\"2\">public</mod></mod-list><extends line=\"2\"" - + ">IFlexDisplayObject</extends><extends line=\"2\">" - + "IDataRenderer</extends><content line=\"2\">" - + "</content></interface></content>" ); - } - - @Test - public void testInclude() throws TokenException - { - assertPackageContent( "1", - "public interface A extends B { include \"ITextFieldInterface.asz\" } ", - "<content line=\"2\"><interface line=\"2\">" - + "<name line=\"2\">A</name><mod-list line=\"2\">" - + "<mod line=\"2\">public</mod></mod-list>" + "<extends line=\"2\">" - + "B</extends><content line=\"2\"><include line=\"2\">" - + "<primary line=\"2\">\"ITextFieldInterface.asz\"</primary>" - + "</include></content></interface></content>" ); - } - - private void assertPackageContent( final String message, - final String input, - final String expected ) throws TokenException - { - scn.setLines( new String[] - { "{", - input, - "}", - "__END__" } ); - asp.nextToken(); // first call - asp.nextToken(); // skip { - final String result = new ASTToXMLConverter().convert( asp.parsePackageContent() ); - assertEquals( message, - expected, - result ); - } - -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestInterfaceContent.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestInterfaceContent.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestInterfaceContent.java deleted file mode 100644 index 9c4508e..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestInterfaceContent.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestInterfaceContent extends AbstractAs3ParserTest -{ - @Test(timeout = 2) - public void testConditionalCompilation() throws TokenException - { - assertInterfaceContent( "with conditional compilation", - - "CONFIG::DEBUG { function output():String; } ", - "<function line=\"2\"><name line=\"2\">" - + "output</name><parameter-list line=\"2\"></parameter-list>" - + "<type line=\"2\">String</type></function>" ); - - } - - @Test - public void testImports() throws TokenException - { - assertInterfaceContent( "1", - "import a.b.c;", - "<import line=\"2\">a.b.c</import>" ); - - assertInterfaceContent( "2", - "import a.b.c import x.y.z", - "<import line=\"2\">a.b.c</import>" - + "<import line=\"2\">x.y.z</import>" ); - } - - @Test - public void testMethods() throws TokenException - { - assertInterfaceContent( "1", - "function a()", - "<function line=\"3\">" - + "<name line=\"2\">a</name>" - + "<parameter-list line=\"2\">" - + "</parameter-list><type line=\"3\">" - + "</type></function>" ); - - assertInterfaceContent( "2", - "function set a( value : int ) : void", - "<set line=\"3\"><name line=\"2\">a" - + "</name><parameter-list line=\"2\">" - + "<parameter line=\"2\">" - + "<name-type-init line=\"2\">" - + "<name line=\"2\">value</name>" - + "<type line=\"2\">int</type>" - + "</name-type-init></parameter></parameter-list>" - + "<type line=\"2\">void</type></set>" ); - - assertInterfaceContent( "3", - "function get a() : int", - "<get line=\"3\"><name line=\"2\">a" - + "</name><parameter-list line=\"2\">" - + "</parameter-list><type line=\"2\">int" + "</type></get>" ); - } - - private void assertInterfaceContent( final String message, - final String input, - final String expected ) throws TokenException - { - scn.setLines( new String[] - { "{", - input, - "}", - "__END__" } ); - asp.nextToken(); // first call - asp.nextToken(); // skip { - final String result = new ASTToXMLConverter().convert( asp.parseInterfaceContent() ); - assertEquals( message, - "<content line=\"2\">" - + expected + "</content>", - result ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestPackageContent.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestPackageContent.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestPackageContent.java deleted file mode 100644 index f81df13..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestPackageContent.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestPackageContent extends AbstractAs3ParserTest -{ - @Test - public void testClass() throws TokenException - { - assertPackageContent( "1", - "public class A { }", - "<content line=\"2\"><class line=\"2\">" - + "<name line=\"2\">A</name><mod-list line=\"2\">" - + "<mod line=\"2\">public</mod>" + "</mod-list><content line=\"2\">" - + "</content></class></content>" ); - } - - @Test - public void testClassWithAsDoc() throws TokenException - { - assertPackageContent( "1", - "/** AsDoc */ public class A { }", - "<content line=\"2\"><class line=\"2\">" - + "<as-doc line=\"2\">/** AsDoc */</as-doc><name line=\"2\"" - + ">A</name><mod-list line=\"2\"><mod line=\"2\"" - + ">public</mod></mod-list><content line=\"2\">" - + "</content></class></content>" ); - } - - @Test - public void testClassWithAsDocComplex() throws TokenException - { - assertPackageContent( "1", - "/** AsDoc */ public class A { " - + "/** Member */ " + "public var tmp : Number; " - + "private var tmp2 : int; " + "/** Function */ " - + "protected function foo() : void { } }", - "<content line=\"2\"><class line=\"2\"><as-doc line=\"2\"" - + ">/** AsDoc */</as-doc><name line=\"2\">A</name>" - + "<mod-list line=\"2\"><mod line=\"2\">public</mod>" - + "</mod-list><content line=\"2\"><var-list line=\"2\">" - + "<mod-list line=\"2\"><mod line=\"2\">public</mod>" - + "</mod-list><name-type-init line=\"2\"><name line=\"2\">tmp</name>" - + "<type line=\"2\">Number</type></name-type-init><as-doc line=\"2\"" - + ">/** Member */</as-doc></var-list><var-list line=\"2\">" - + "<mod-list line=\"2\"><mod line=\"2\">private</mod></mod-list>" - + "<name-type-init line=\"2\"><name line=\"2\">tmp2</name>" - + "<type line=\"2\">int</type></name-type-init></var-list><function " - + "line=\"2\"><as-doc line=\"2\">/** Function */</as-doc>" - + "<mod-list line=\"2\"><mod line=\"2\">protected</mod></mod-list>" - + "<name line=\"2\">foo</name><parameter-list line=\"2\">" - + "</parameter-list><type line=\"2\">void</type><block line=\"2\"" - + "></block></function></content></class></content>" ); - } - - @Test - public void testClassWithComment() throws TokenException - { - assertPackageContent( "1", - "/* lala */ /** asDoc */ public class A { }", - "<content line=\"2\"><class line=\"2\">" - + "<as-doc line=\"2\">/** asDoc */</as-doc><multi-line-comment " - + "line=\"2\">/* lala */</multi-line-comment><name line=\"2\"" - + ">A</name><mod-list line=\"2\"><mod line=\"2\"" - + ">public</mod></mod-list><content line=\"2\">" - + "</content></class></content>" ); - } - - @Test - public void testClassWithMetadata() throws TokenException - { - assertPackageContent( "1", - "[Bindable(name=\"abc\", value=\"123\")] public class A { }", - "<content line=\"2\"><class line=\"2\">" - + "<name line=\"2\">A</name><meta-list line=\"2\">" + "<meta line=\"2\"" - + ">Bindable ( name = \"abc\" , value = \"123\" )</meta>" - + "</meta-list><mod-list line=\"2\">" + "<mod line=\"2\">public" - + "</mod></mod-list><content line=\"2\"></content></class></content>" ); - } - - @Test - public void testClassWithMetadataAsDoc() throws TokenException - { - assertPackageContent( "1", - "/** Comment */ [Bindable] public class A { }", - "<content line=\"2\"><class line=\"2\"><as-doc line=\"2\">" - + "/** Comment */</as-doc><name line=\"2\">A</name><meta-list " - + "line=\"2\"><meta line=\"2\">Bindable</meta></meta-list><mod-list " - + "line=\"2\"><mod line=\"2\">public</mod></mod-list><content " - + "line=\"2\"></content></class></content>" ); - } - - @Test - public void testClassWithMetadataComment() throws TokenException - { - assertPackageContent( "1", - "/* Comment */ [Bindable] public class A { }", - "<content line=\"2\"><class line=\"2\">" - + "<multi-line-comment line=\"2\">/* Comment */" - + "</multi-line-comment><name line=\"2\">A</name>" - + "<meta-list line=\"2\"><meta line=\"2\">" - + "Bindable</meta></meta-list><mod-list line=\"2\"><mod " - + "line=\"2\">public</mod></mod-list><content line=\"2\"" - + "></content></class></content>" ); - } - - @Test - public void testClassWithMetadataWithComment() throws TokenException - { - assertPackageContent( "1", - "/* lala */ /** asDoc */ [Bindable] public class A { }", - "<content line=\"2\"><class line=\"2\"><as-doc line=\"2\">" - + "/** asDoc */</as-doc><multi-line-comment line=\"2\">" - + "/* lala */</multi-line-comment><name line=\"2\">A</name>" - + "<meta-list line=\"2\"><meta line=\"2\">Bindable</meta>" - + "</meta-list><mod-list line=\"2\"><mod line=\"2\">public" - + "</mod></mod-list><content line=\"2\"></content></class></content>" ); - } - - @Test - public void testClassWithSimpleMetadata() throws TokenException - { - assertPackageContent( "1", - "[Bindable] public class A { }", - "<content line=\"2\"><class line=\"2\"><name line=\"2\"" - + ">A</name><meta-list line=\"2\"><meta line=\"2\"" - + ">Bindable</meta></meta-list><mod-list line=\"2\">" - + "<mod line=\"2\">public</mod></mod-list><content line=\"2\"" - + "></content></class></content>" ); - } - - @Test - public void testImports() throws TokenException - { - assertPackageContent( "1", - "import a.b.c;", - "<content line=\"2\"><import line=\"2\"" - + ">a.b.c</import></content>" ); - - assertPackageContent( "2", - "import a.b.c import x.y.z", - "<content line=\"2\"><import line=\"2\">a.b.c" - + "</import><import line=\"2\">x.y.z</import></content>" ); - } - - @Test - public void testInterface() throws TokenException - { - assertPackageContent( "1", - "public interface A { }", - "<content line=\"2\"><interface line=\"2\">" - + "<name line=\"2\">A</name><mod-list line=\"2\">" - + "<mod line=\"2\">public</mod>" + "</mod-list><content line=\"2\">" - + "</content></interface></content>" ); - } - - @Test - public void testMethodPackages() throws TokenException - { - assertPackageContent( "1", - "public function a() : void { }", - "<content line=\"2\"><function line=\"2\">" - + "<mod-list line=\"2\"><mod line=\"2\">public</mod>" - + "</mod-list><name line=\"2\">a</name><parameter-list line=\"2\"" - + "></parameter-list><type line=\"2\">void</type>" - + "<block line=\"2\"></block></function></content>" ); - } - - @Test - public void testUse() throws TokenException - { - assertPackageContent( "1", - "use namespace myNamespace", - "<content line=\"2\"><use line=\"2\"" - + ">myNamespace</use></content>" ); - } - - @Test - public void testUseNameSpace() throws TokenException - { - assertPackageContent( "FlexPMD-108", - "use namespace mx_internal;", - "<content line=\"2\"><use line=\"2\">mx_internal</use></content>" ); - } - - private void assertPackageContent( final String message, - final String input, - final String expected ) throws TokenException - { - scn.setLines( new String[] - { "{", - input, - "}", - "__END__" } ); - asp.nextToken(); // first call - asp.nextToken(); // skip { - final String result = new ASTToXMLConverter().convert( asp.parsePackageContent() ); - assertEquals( message, - expected, - result ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestPrimaryExpression.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestPrimaryExpression.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestPrimaryExpression.java deleted file mode 100644 index 0670bf6..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestPrimaryExpression.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestPrimaryExpression extends AbstractAs3ParserTest -{ - @Test - public void testArrayLiteral() throws TokenException - { - assertPrimary( "[1,2,3]", - "<array line=\"1\"><primary line=\"1\">1" - + "</primary><primary line=\"1\">2</primary>" - + "<primary line=\"1\">3</primary></array>" ); - } - - @Test - public void testBooleans() throws TokenException - { - assertPrimary( "true" ); - assertPrimary( "false" ); - } - - @Test - public void testFunctionLiteral() throws TokenException - { - assertPrimary( "function ( a : Object ) : * { trace('test'); }", - "<lambda line=\"1\"><parameter-list line=\"1\">" - + "<parameter line=\"1\"><name-type-init line=\"1\">" - + "<name line=\"1\">a</name><type line=\"1\">" - + "Object</type></name-type-init></parameter></parameter-list>" - + "<type line=\"1\">*</type><block line=\"1\">" - + "<call line=\"1\"><primary line=\"1\">trace</primary>" - + "<arguments line=\"1\"><primary line=\"1\">'test'" - + "</primary></arguments></call></block></lambda>" ); - } - - @Test - public void testNull() throws TokenException - { - assertPrimary( "null" ); - } - - @Test - public void testNumbers() throws TokenException - { - assertPrimary( "1" ); - assertPrimary( "0xff" ); - assertPrimary( "0777" ); - assertPrimary( ".12E5" ); - } - - @Test - public void testObjectLiteral() throws TokenException - { - assertPrimary( "{a:1,b:2}", - "<object line=\"1\"><prop line=\"1\">" - + "<name line=\"1\">a</name><value line=\"1\">" - + "<primary line=\"1\">1</primary></value></prop><prop line=\"1\">" - + "<name line=\"1\">b</name><value line=\"1\">" - + "<primary line=\"1\">2</primary></value></prop></object>" ); - } - - @Test - public void testStrings() throws TokenException - { - assertPrimary( "\"string\"" ); - assertPrimary( "'string'" ); - } - - @Test - public void testUndefined() throws TokenException - { - assertPrimary( "undefined" ); - } - - private void assertPrimary( final String input ) throws TokenException - { - assertPrimary( input, - input ); - } - - private void assertPrimary( final String input, - final String expected ) throws TokenException - { - scn.setLines( new String[] - { input, - "__END__" } ); - asp.nextToken(); - final String result = new ASTToXMLConverter().convert( asp.parsePrimaryExpression() ); - assertEquals( "unexpected", - "<primary line=\"1\">" - + expected + "</primary>", - result ); - } - -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestReturnStatement.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestReturnStatement.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestReturnStatement.java deleted file mode 100644 index f1dd833..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestReturnStatement.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestReturnStatement extends AbstractStatementTest -{ - @Test - public void testEmptyReturn() throws TokenException - { - assertStatement( "1", - "return", - "<return line=\"2\"></return>" ); - - assertStatement( "2", - "return;", - "<return line=\"2\"></return>" ); - } - - @Test - public void testFlexPMD181a() throws TokenException - { - assertStatement( "1", - "return (str1 === str2);", - "<return line=\"1\"><primary line=\"1\"><encapsulated line=\"1\">" - + "<equality line=\"1\"><primary line=\"1\">str1</primary><op line=\"1\">" - + "===</op><primary line=\"1\">str2</primary></equality>" - + "</encapsulated></primary></return>" ); - } - - @Test - public void testFlexPMD181b() throws TokenException - { - assertStatement( "1", - "return testString(str, /^[a-zA-Z\\s]*$/);", - "<return line=\"1\"><call line=\"1\"><primary line=\"1\">testString" - + "</primary><arguments line=\"1\"><primary line=\"1\">str</primary>" - + "<primary line=\"1\">/^[a-zA-Z\\s]*$/</primary></arguments></call></return>" ); - } - - @Test - public void testReturnArrayLiteral() throws TokenException - { - assertStatement( "1", - "return []", - "<return line=\"1\"><primary line=\"1\">" - + "<array line=\"1\"></array></primary></return>" ); - assertStatement( "2", - "return [];", - "<return line=\"1\"><primary line=\"1\">" - + "<array line=\"1\"></array></primary></return>" ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestSwitchStatement.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestSwitchStatement.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestSwitchStatement.java deleted file mode 100644 index 89ce628..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestSwitchStatement.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestSwitchStatement extends AbstractStatementTest -{ - @Test - public void testFullFeatured() throws TokenException - { - assertStatement( "1", - "switch( x ){ case 1 : trace('one'); break; default : trace('unknown'); }", - "<switch line=\"1\"><condition line=\"1\">" - + "<primary line=\"1\">x</primary>" + "</condition><cases line=\"1\">" - + "<case line=\"1\"><primary line=\"1\">1</primary>" - + "<switch-block line=\"1\"><call line=\"1\">" - + "<primary line=\"1\">trace</primary><arguments line=\"1\">" - + "<primary line=\"1\">'one'</primary></arguments>" - + "</call><primary line=\"1\">break</primary>" - + "</switch-block></case><case line=\"1\">" + "<default line=\"1\">" - + "default</default><switch-block line=\"1\">" - + "<call line=\"1\"><primary line=\"1\">trace" + "</primary>" - + "<arguments line=\"1\">" + "<primary line=\"1\">'unknown'</primary>" - + "</arguments></call></switch-block></case></cases></switch>" ); - assertStatement( "1", - "switch( x ){ case 1 : break; default:}", - "<switch line=\"1\"><condition line=\"1\"><primary line=\"1\"" - + ">x</primary></condition><cases line=\"1\"><case line=\"1\"" - + "><primary line=\"1\">1</primary><switch-block line=\"1\"" - + "><primary line=\"1\">break</primary></switch-block></case>" - + "<case line=\"1\"><default line=\"1\">default</default>" - + "<switch-block line=\"1\"></switch-block></case></cases></switch>" ); - - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestTryCatchFinallyStatement.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestTryCatchFinallyStatement.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestTryCatchFinallyStatement.java deleted file mode 100644 index 45da07e..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestTryCatchFinallyStatement.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestTryCatchFinallyStatement extends AbstractStatementTest -{ - @Test - public void testCatch() throws TokenException - { - assertStatement( "1", - "catch( e : Error ) {trace( true ); }", - "<catch line=\"1\"><name line=\"1\">e" - + "</name><type line=\"1\">Error</type><block line=\"1\">" - + "<call line=\"1\"><primary line=\"1\">trace</primary>" - + "<arguments line=\"1\"><primary line=\"1\">true" - + "</primary></arguments></call></block></catch>" ); - } - - @Test - public void testFinally() throws TokenException - { - assertStatement( "1", - "finally {trace( true ); }", - "<finally line=\"1\"><block line=\"1\">" - + "<call line=\"1\"><primary line=\"1\">" - + "trace</primary><arguments line=\"1\"><primary line=\"1\">" - + "true</primary></arguments></call></block></finally>" ); - } - - @Test - public void testTry() throws TokenException - { - assertStatement( "1", - "try {trace( true ); }", - "<try line=\"1\"><block line=\"1\">" - + "<call line=\"1\"><primary line=\"1\">" - + "trace</primary><arguments line=\"1\"><primary line=\"1\">" - + "true</primary></arguments></call></block></try>" ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestUnaryExpression.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestUnaryExpression.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestUnaryExpression.java deleted file mode 100644 index 41ca8d2..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestUnaryExpression.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestUnaryExpression extends AbstractStatementTest -{ - @Test - public void testArrayAccess() throws TokenException - { - assertStatement( "1", - "x[0]", - "<arr-acc line=\"1\"><primary line=\"1\">x<" - + "/primary><primary line=\"1\">0</primary></arr-acc>" ); - } - - @Test - public void testComplex() throws TokenException - { - assertStatement( "1", - "a.b['c'].d.e(1)", - "<dot line=\"1\"><primary line=\"1\">a" - + "</primary><dot line=\"1\"><arr-acc line=\"1\">" - + "<primary line=\"1\">b</primary><primary line=\"1\">" - + "'c'</primary></arr-acc><dot line=\"1\"><primary line=\"1\">" - + "d</primary><call line=\"1\"><primary line=\"1\">e" - + "</primary><arguments line=\"1\"><primary line=\"1\">1" - + "</primary></arguments></call></dot></dot></dot>" ); - - assertStatement( "2", - "a.b['c']['d'].e(1)", - "<dot line=\"1\"><primary line=\"1\">a" - + "</primary><dot line=\"1\"><arr-acc line=\"1\">" - + "<primary line=\"1\">b</primary><primary line=\"1\">" - + "'c'</primary><primary line=\"1\">'d'</primary>" - + "</arr-acc><call line=\"1\"><primary line=\"1\">" - + "e</primary><arguments line=\"1\"><primary line=\"1\">1" - + "</primary></arguments></call></dot></dot>" ); - } - - @Test - public void testMethodCall() throws TokenException - { - assertStatement( "1", - "method()", - "<call line=\"1\"><primary line=\"1\">" - + "method</primary><arguments line=\"1\"></arguments></call>" ); - - assertStatement( "2", - "method( 1, \"two\" )", - "<call line=\"1\"><primary line=\"1\">" - + "method</primary><arguments line=\"1\"><primary line=\"1\">1" - + "</primary><primary line=\"1\">\"two\"</primary></arguments></call>" ); - } - - @Test - public void testMultipleMethodCall() throws TokenException - { - assertStatement( "1", - "method()()", - "<call line=\"1\"><primary line=\"1\">" - + "method</primary><arguments line=\"1\"></arguments>" - + "<arguments line=\"1\"></arguments></call>" ); - } - - @Test - public void testParseUnaryExpressions() throws TokenException - { - assertStatement( "1", - "++x", - "<pre-inc line=\"1\"><primary line=\"1\">x</primary></pre-inc>" ); - assertStatement( "2", - "x++", - "<post-inc line=\"2\"><primary line=\"1\">x</primary></post-inc>" ); - assertStatement( "3", - "--x", - "<pre-dec line=\"1\"><primary line=\"1\">x</primary></pre-dec>" ); - assertStatement( "4", - "x--", - "<post-dec line=\"2\"><primary line=\"1\">x</primary></post-dec>" ); - assertStatement( "5", - "+x", - "<plus line=\"1\"><primary line=\"1\">x</primary></plus>" ); - assertStatement( "6", - "+ x", - "<plus line=\"1\"><primary line=\"1\">x</primary></plus>" ); - assertStatement( "7", - "-x", - "<minus line=\"1\"><primary line=\"1\">x</primary></minus>" ); - assertStatement( "8", - "- x", - "<minus line=\"1\"><primary line=\"1\">x</primary></minus>" ); - assertStatement( "9", - "delete x", - "<delete line=\"1\"><primary line=\"1\">x</primary></delete>" ); - assertStatement( "a", - "void x", - "<void line=\"1\"><primary line=\"1\">x</primary></void>" ); - assertStatement( "b", - "typeof x", - "<typeof line=\"1\"><primary line=\"1\">x</primary></typeof>" ); - assertStatement( "c", - "! x", - "<not line=\"1\"><primary line=\"1\">x</primary></not>" ); - assertStatement( "d", - "~ x", - "<b-not line=\"1\"><primary line=\"1\">x</primary></b-not>" ); - assertStatement( "e", - "x++", - "<post-inc line=\"2\"><primary line=\"1\">x</primary></post-inc>" ); - assertStatement( "f", - "x--", - "<post-dec line=\"2\"><primary line=\"1\">x</primary></post-dec>" ); - } -} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestVarStatement.java ---------------------------------------------------------------------- diff --git a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestVarStatement.java b/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestVarStatement.java deleted file mode 100644 index baa9584..0000000 --- a/FlexPMD/as3-parser/src/test/java/de/bokelberg/flex/parser/TestVarStatement.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.bokelberg.flex.parser; - -import org.junit.Test; - -import com.adobe.ac.pmd.parser.exceptions.TokenException; - -public class TestVarStatement extends AbstractStatementTest -{ - @Test - public void testFlexPMD211() throws TokenException - { - assertStatement( "", - "var a:Vector.<String> = new Vector.<String>();\nvar i:int;", - "<var-list line=\"1\"><name-type-init line=\"1\"><name line=\"1\">a</name>" - + "<vector line=\"1\"><type line=\"1\">String</type></vector>" - + "<init line=\"1\"><new line=\"1\"><primary line=\"1\">Vector</primary>" - + "<vector line=\"1\"><vector line=\"1\"><type line=\"1\">String</type>" - + "</vector></vector><arguments line=\"1\"></arguments></new></init>" - + "</name-type-init></var-list>" ); - } - - @Test - public void testFullFeaturedVar() throws TokenException - { - assertStatement( "1", - "var a : int = 4", - "<var-list line=\"1\">" - + "<name-type-init line=\"1\">" - + "<name line=\"1\">a</name><type line=\"1\">int</type>" - + "<init line=\"1\"><primary line=\"1\">4</primary>" - + "</init></name-type-init></var-list>" ); - - assertStatement( "1", - "var a : int = 4, b : int = 2;", - "<var-list line=\"1\"><name-type-init line=\"1\">" - + "<name line=\"1\">a</name><type line=\"1\">int</type>" - + "<init line=\"1\"><primary line=\"1\">4</primary></init>" - + "</name-type-init><name-type-init line=\"1\">" - + "<name line=\"1\">b</name><type line=\"1\">int</type>" - + "<init line=\"1\"><primary line=\"1\">2</primary></init>" - + "</name-type-init></var-list>" ); - - assertStatement( "with array", - "var colors:Array = [0x2bc9f6, 0x0086ad];", - "<var-list line=\"1\">" - + "<name-type-init line=\"1\">" - + "<name line=\"1\">colors</name><type line=\"1\">Array</type>" - + "<init line=\"1\">" + "<primary line=\"1\"><array line=\"1\">" - + "<primary line=\"1\">0x2bc9f6</primary>" - + "<primary line=\"1\">0x0086ad</primary>" - + "</array></primary></init></name-type-init></var-list>" ); - } - - @Test - public void testInitializedVar() throws TokenException - { - assertStatement( "1", - "var a = 4", - "<var-list line=\"1\"><name-type-init line=\"1\">" - + "<name line=\"1\">a</name><type line=\"1\">" - + "</type><init line=\"1\"><primary line=\"1\">4</primary>" - + "</init></name-type-init></var-list>" ); - } - - @Test - public void testSimpleVar() throws TokenException - { - assertStatement( "1", - "var a", - "<var-list line=\"1\"><name-type-init line=\"1\">" - + "<name line=\"1\">a</name><type line=\"2\">" - + "</type></name-type-init></var-list>" ); - } - - @Test - public void testTypedVar() throws TokenException - { - assertStatement( "1", - "var a : Object", - "<var-list line=\"1\"><name-type-init line=\"1\">" - + "<name line=\"1\">a</name><type line=\"1\">Object</type>" - + "</name-type-init></var-list>" ); - } - - @Test - public void testVector() throws TokenException - { - assertStatement( "vector", - "var v:Vector.<DisplayObject> = new Vector.<Sprite>();", - "<var-list line=\"1\"><name-type-init line=\"1\"><name line=\"1\">v</name><vector line=\"1\"><type line=\"1\">DisplayObject</type></vector><init line=\"1\"><new line=\"1\"><primary line=\"1\">Vector</primary><vector line=\"1\"><vector line=\"1\"><type line=\"1\">Sprite</type></vector></vector><arguments line=\"1\"></arguments></new></init></name-type-init></var-list>" ); - - assertStatement( "vector", - "var v:Vector.< Vector.< String > >", - "<var-list line=\"1\"><name-type-init line=\"1\">" - + "<name line=\"1\">" + "v</name><vector line=\"1\"><vector line=\"1\"" - + "><type line=\"1\"" - + ">String</type></vector></vector></name-type-init></var-list>" ); - - assertStatement( "vector", - "var v:Vector.<Vector.<String>>;", - "<var-list line=\"1\"><name-type-init line=\"1\">" - + "<name line=\"1\">" - + "v</name><vector line=\"1\"><vector line=\"1\"><type line=\"1\"" - + ">String</type></vector></vector></name-type-init></var-list>" ); - - assertStatement( "", - "var HT:Vector.<BitString> = new Vector.<BitString>(251, true);", - "<var-list line=\"1\"><name-type-init line=\"1\"><name line=\"1\">HT</name><vector line=\"1\"><type line=\"1\">BitString</type></vector><init line=\"1\"><new line=\"1\"><primary line=\"1\">Vector</primary><vector line=\"1\"><vector line=\"1\"><type line=\"1\">BitString</type></vector></vector><arguments line=\"1\"><primary line=\"1\">251</primary><primary line=\"1\">true</primary></arguments></new></init></name-type-init></var-list>" ); - } -}