You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by er...@apache.org on 2013/01/10 14:55:32 UTC
svn commit: r1431363 - in
/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal:
as/codegen/ js/codegen/goog/
Author: erikdebruin
Date: Thu Jan 10 13:55:32 2013
New Revision: 1431363
URL: http://svn.apache.org/viewvc?rev=1431363&view=rev
Log:
- added a few tests for the remaining language features from the 'Full Table' (Wiki)
- refactored tests such that all 'getXXXTypeNode()' utility methods now are in 'TestBase.java'
Modified:
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestAccessorMembers.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestBase.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestClass.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestComments.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestFieldMembers.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalClasses.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalConstants.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalFunctions.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestInterface.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestMethodMembers.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestAccessorMembers.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestAccessorMembers.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestAccessorMembers.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestAccessorMembers.java Thu Jan 10 13:55:32 2013
@@ -20,7 +20,6 @@
package org.apache.flex.compiler.internal.as.codegen;
import org.apache.flex.compiler.tree.as.IAccessorNode;
-import org.apache.flex.compiler.tree.as.IFileNode;
import org.junit.Test;
/**
@@ -98,13 +97,4 @@ public class TestAccessorMembers extends
visitor.visitFunction(node);
assertOut("public static function set foo(value:int):void {\n}");
}
-
- protected IAccessorNode getAccessor(String code)
- {
- String source = "package {public class A {" + code + "}}";
- IFileNode node = getFileNode(source);
- IAccessorNode child = (IAccessorNode) findFirstDescendantOfType(node,
- IAccessorNode.class);
- return child;
- }
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestBase.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestBase.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestBase.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestBase.java Thu Jan 10 13:55:32 2013
@@ -20,11 +20,15 @@ import org.apache.flex.compiler.mxml.IMX
import org.apache.flex.compiler.mxml.MXMLNamespaceMapping;
import org.apache.flex.compiler.problems.ICompilerProblem;
import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IAccessorNode;
import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
import org.apache.flex.compiler.tree.as.IDynamicAccessNode;
import org.apache.flex.compiler.tree.as.IExpressionNode;
import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IInterfaceNode;
import org.apache.flex.compiler.tree.as.IUnaryOperatorNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
import org.apache.flex.compiler.units.ICompilationUnit;
import org.apache.flex.compiler.utils.EnvProperties;
import org.apache.flex.utils.FilenameNormalization;
@@ -192,13 +196,12 @@ public class TestBase
return child;
}
- protected IUnaryOperatorNode getUnaryNode(String code)
+ protected IAccessorNode getAccessor(String code)
{
- String source = "package {public class A {function a():void {" + code
- + "}}";
+ String source = "package {public class A {" + code + "}}";
IFileNode node = getFileNode(source);
- IUnaryOperatorNode child = (IUnaryOperatorNode) findFirstDescendantOfType(
- node, IUnaryOperatorNode.class);
+ IAccessorNode child = (IAccessorNode) findFirstDescendantOfType(node,
+ IAccessorNode.class);
return child;
}
@@ -221,4 +224,56 @@ public class TestBase
node, IDynamicAccessNode.class);
return child;
}
+
+ protected IVariableNode getField(String code)
+ {
+ String source = "package {public class A {" + code + "}}";
+ IFileNode node = getFileNode(source);
+ IVariableNode child = (IVariableNode) findFirstDescendantOfType(node,
+ IVariableNode.class);
+ return child;
+ }
+
+ protected IInterfaceNode getInterfaceNode(String code)
+ {
+ String source = "package {" + code + "}";
+ IFileNode node = getFileNode(source);
+ IInterfaceNode child = (IInterfaceNode) findFirstDescendantOfType(node,
+ IInterfaceNode.class);
+ return child;
+ }
+
+ protected IFunctionNode getMethod(String code)
+ {
+ String source = "package {public class A {" + code + "}}";
+ IFileNode node = getFileNode(source);
+ IFunctionNode child = (IFunctionNode) findFirstDescendantOfType(node,
+ IFunctionNode.class);
+ return child;
+ }
+
+ protected IFunctionNode getMethodWithPackage(String code)
+ {
+ String source = "package foo.bar {public class A {" + code + "}}";
+ IFileNode node = getFileNode(source);
+ IFunctionNode child = (IFunctionNode) findFirstDescendantOfType(node,
+ IFunctionNode.class);
+ return child;
+ }
+
+ protected IUnaryOperatorNode getUnaryNode(String code)
+ {
+ String source = "package {public class A {function a():void {" + code
+ + "}}";
+ IFileNode node = getFileNode(source);
+ IUnaryOperatorNode child = (IUnaryOperatorNode) findFirstDescendantOfType(
+ node, IUnaryOperatorNode.class);
+ return child;
+ }
+
+ protected IVariableNode getVariable(String code)
+ {
+ IVariableNode node = (IVariableNode) getNode(code, IVariableNode.class);
+ return node;
+ }
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestClass.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestClass.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestClass.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestClass.java Thu Jan 10 13:55:32 2013
@@ -21,6 +21,7 @@ package org.apache.flex.compiler.interna
import org.apache.flex.compiler.tree.as.IClassNode;
import org.apache.flex.compiler.tree.as.IFileNode;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -59,6 +60,16 @@ public class TestClass extends TestWalke
assertOut("public final class A {\n}");
}
+ @Ignore
+ @Test
+ public void testSimpleDynamic()
+ {
+ // TODO (erikdebruin/mschmalle) 'dynamic' keyword is omitted by the compiler
+ IClassNode node = getClassNode("public dynamic class A{}");
+ visitor.visitClass(node);
+ assertOut("public dynamic class A {\n}");
+ }
+
@Test
public void testSimpleExtends()
{
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestComments.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestComments.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestComments.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestComments.java Thu Jan 10 13:55:32 2013
@@ -19,7 +19,6 @@
package org.apache.flex.compiler.internal.as.codegen;
-import org.apache.flex.compiler.tree.as.IFileNode;
import org.apache.flex.compiler.tree.as.IFunctionNode;
import org.junit.Ignore;
import org.junit.Test;
@@ -75,13 +74,4 @@ public class TestComments extends TestWa
visitor.visitFunction(node);
assertOut("function a():void {\n\t/**\n\t * line comment\n\t */};");
}
-
- protected IFunctionNode getMethod(String code)
- {
- String source = "package {public class A {" + code + "}}";
- IFileNode node = getFileNode(source);
- IFunctionNode child = (IFunctionNode) findFirstDescendantOfType(node,
- IFunctionNode.class);
- return child;
- }
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestFieldMembers.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestFieldMembers.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestFieldMembers.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestFieldMembers.java Thu Jan 10 13:55:32 2013
@@ -19,7 +19,6 @@
package org.apache.flex.compiler.internal.as.codegen;
-import org.apache.flex.compiler.tree.as.IFileNode;
import org.apache.flex.compiler.tree.as.IVariableNode;
import org.junit.Test;
@@ -163,13 +162,4 @@ public class TestFieldMembers extends Te
visitor.visitVariable(node);
assertOut("mx_internal static const foo:int = 420");
}
-
- protected IVariableNode getField(String code)
- {
- String source = "package {public class A {" + code + "}}";
- IFileNode node = getFileNode(source);
- IVariableNode child = (IVariableNode) findFirstDescendantOfType(node,
- IVariableNode.class);
- return child;
- }
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalClasses.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalClasses.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalClasses.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalClasses.java Thu Jan 10 13:55:32 2013
@@ -19,7 +19,6 @@
package org.apache.flex.compiler.internal.as.codegen;
-import org.apache.flex.compiler.tree.as.IFileNode;
import org.apache.flex.compiler.tree.as.IFunctionNode;
import org.apache.flex.compiler.tree.as.IVariableNode;
import org.junit.Ignore;
@@ -286,19 +285,4 @@ public class TestGlobalClasses extends T
visitor.visitVariable(node);
assertOut("var a:XMLList = new XMLList('<!-- comment -->')");
}
-
- protected IFunctionNode getMethod(String code)
- {
- String source = "package {public class A {" + code + "}}";
- IFileNode node = getFileNode(source);
- IFunctionNode child = (IFunctionNode) findFirstDescendantOfType(node,
- IFunctionNode.class);
- return child;
- }
-
- protected IVariableNode getVariable(String code)
- {
- IVariableNode node = (IVariableNode) getNode(code, IVariableNode.class);
- return node;
- }
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalConstants.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalConstants.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalConstants.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalConstants.java Thu Jan 10 13:55:32 2013
@@ -19,7 +19,6 @@
package org.apache.flex.compiler.internal.as.codegen;
-import org.apache.flex.compiler.tree.as.IFileNode;
import org.apache.flex.compiler.tree.as.IVariableNode;
import org.junit.Test;
@@ -59,13 +58,4 @@ public class TestGlobalConstants extends
visitor.visitVariable(node);
assertOut("var a:* = undefined");
}
-
- protected IVariableNode getField(String code)
- {
- String source = "package {public class A {" + code + "}}";
- IFileNode node = getFileNode(source);
- IVariableNode child = (IVariableNode) findFirstDescendantOfType(node,
- IVariableNode.class);
- return child;
- }
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalFunctions.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalFunctions.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalFunctions.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalFunctions.java Thu Jan 10 13:55:32 2013
@@ -206,10 +206,4 @@ public class TestGlobalFunctions extends
visitor.visitVariable(node);
assertOut("var a:XMLList = XMLList('<!-- comment -->')");
}
-
- protected IVariableNode getVariable(String code)
- {
- IVariableNode node = (IVariableNode) getNode(code, IVariableNode.class);
- return node;
- }
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestInterface.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestInterface.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestInterface.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestInterface.java Thu Jan 10 13:55:32 2013
@@ -19,7 +19,6 @@
package org.apache.flex.compiler.internal.as.codegen;
-import org.apache.flex.compiler.tree.as.IFileNode;
import org.apache.flex.compiler.tree.as.IInterfaceNode;
import org.junit.Test;
@@ -102,13 +101,4 @@ public class TestInterface extends TestW
+ "\n\tfunction set foo1(value:Object):void;\n\tfunction baz1()"
+ ":Object;\n\tfunction baz2(value:Object):void;\n}");
}
-
- protected IInterfaceNode getInterfaceNode(String code)
- {
- String source = "package {" + code + "}";
- IFileNode node = getFileNode(source);
- IInterfaceNode child = (IInterfaceNode) findFirstDescendantOfType(node,
- IInterfaceNode.class);
- return child;
- }
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestMethodMembers.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestMethodMembers.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestMethodMembers.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestMethodMembers.java Thu Jan 10 13:55:32 2013
@@ -19,7 +19,6 @@
package org.apache.flex.compiler.internal.as.codegen;
-import org.apache.flex.compiler.tree.as.IFileNode;
import org.apache.flex.compiler.tree.as.IFunctionNode;
import org.junit.Ignore;
import org.junit.Test;
@@ -146,13 +145,4 @@ public class TestMethodMembers extends T
visitor.visitFunction(node);
assertOut("public override function foo(bar:String, baz:int = null):int {\n\treturn -1;\n}");
}
-
- protected IFunctionNode getMethod(String code)
- {
- String source = "package {public class A {" + code + "}}";
- IFileNode node = getFileNode(source);
- IFunctionNode child = (IFunctionNode) findFirstDescendantOfType(node,
- IFunctionNode.class);
- return child;
- }
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogClass.java Thu Jan 10 13:55:32 2013
@@ -68,6 +68,17 @@ public class TestGoogClass extends TestC
@Override
@Test
+ public void testSimpleDynamic()
+ {
+ // TODO (erikdebruin) is there a 'goog' equivalent for the
+ // 'dynamic' keyword?
+ IClassNode node = getClassNode("public dynamic class A{}");
+ visitor.visitClass(node);
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n");
+ }
+
+ @Override
+ @Test
public void testSimpleExtends()
{
// TODO (erikdebruin) why do we need to put use an 'actual' component
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java Thu Jan 10 13:55:32 2013
@@ -61,7 +61,7 @@ public class TestGoogEmiter extends Test
public void testSimpleMethod()
{
JSSharedData.OUTPUT_JSDOC = false;
- IFunctionNode node = getMethodSimple("function method1():void{\n}");
+ IFunctionNode node = getMethod("function method1():void{\n}");
visitor.visitFunction(node);
assertOut("A.prototype.method1 = function() {\n}");
JSSharedData.OUTPUT_JSDOC = true;
@@ -71,7 +71,7 @@ public class TestGoogEmiter extends Test
public void testSimpleParameterReturnType()
{
JSSharedData.OUTPUT_JSDOC = false;
- IFunctionNode node = getMethod("function method1(bar:int):int{\n}");
+ IFunctionNode node = getMethodWithPackage("function method1(bar:int):int{\n}");
visitor.visitFunction(node);
assertOut("foo.bar.A.prototype.method1 = function(bar) {\n}");
JSSharedData.OUTPUT_JSDOC = true;
@@ -81,7 +81,7 @@ public class TestGoogEmiter extends Test
public void testSimpleMultipleParameter()
{
JSSharedData.OUTPUT_JSDOC = false;
- IFunctionNode node = getMethod("function method1(bar:int, baz:String, goo:A):void{\n}");
+ IFunctionNode node = getMethodWithPackage("function method1(bar:int, baz:String, goo:A):void{\n}");
visitor.visitFunction(node);
assertOut("foo.bar.A.prototype.method1 = function(bar, baz, goo) {\n}");
JSSharedData.OUTPUT_JSDOC = true;
@@ -90,7 +90,7 @@ public class TestGoogEmiter extends Test
@Test
public void testSimpleMultipleParameter_JSDoc()
{
- IFunctionNode node = getMethod("function method1(bar:int, baz:String, goo:A):void{\n}");
+ IFunctionNode node = getMethodWithPackage("function method1(bar:int, baz:String, goo:A):void{\n}");
visitor.visitFunction(node);
assertOut("/**\n * @param {number} bar\n * @param {string} baz\n * @param {A} goo\n */\nfoo.bar.A.prototype.method1 = function(bar, baz, goo) {\n}");
}
@@ -107,7 +107,7 @@ public class TestGoogEmiter extends Test
}
*/
JSSharedData.OUTPUT_JSDOC = false;
- IFunctionNode node = getMethod("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{return p1 + p2 + p3 + p4;}");
+ IFunctionNode node = getMethodWithPackage("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{return p1 + p2 + p3 + p4;}");
visitor.visitFunction(node);
assertOut("foo.bar.A.prototype.method1 = function(p1, p2, p3, p4) {\n"
+ "\tp3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
@@ -126,7 +126,7 @@ public class TestGoogEmiter extends Test
}
*/
JSSharedData.OUTPUT_JSDOC = false;
- IFunctionNode node = getMethod("function method1(bar:int = 42, bax:int = 4):void{if (a) foo();}");
+ IFunctionNode node = getMethodWithPackage("function method1(bar:int = 42, bax:int = 4):void{if (a) foo();}");
visitor.visitFunction(node);
assertOut("foo.bar.A.prototype.method1 = function(bar, bax) {\n"
+ "\tbar = typeof bar !== 'undefined' ? bar : 42;\n"
@@ -145,7 +145,7 @@ public class TestGoogEmiter extends Test
}
*/
JSSharedData.OUTPUT_JSDOC = false;
- IFunctionNode node = getMethod("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{}");
+ IFunctionNode node = getMethodWithPackage("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{}");
visitor.visitFunction(node);
assertOut("foo.bar.A.prototype.method1 = function(p1, p2, p3, p4) {\n"
+ "\tp3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
@@ -158,22 +158,4 @@ public class TestGoogEmiter extends Test
{
return new GoogBackend();
}
-
- protected IFunctionNode getMethodSimple(String code)
- {
- String source = "package {public class A {" + code + "}}";
- IFileNode node = getFileNode(source);
- IFunctionNode child = (IFunctionNode) findFirstDescendantOfType(node,
- IFunctionNode.class);
- return child;
- }
-
- protected IFunctionNode getMethod(String code)
- {
- String source = "package foo.bar {public class A {" + code + "}}";
- IFileNode node = getFileNode(source);
- IFunctionNode child = (IFunctionNode) findFirstDescendantOfType(node,
- IFunctionNode.class);
- return child;
- }
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogExpressions.java Thu Jan 10 13:55:32 2013
@@ -24,7 +24,9 @@ import org.apache.flex.compiler.internal
import org.apache.flex.compiler.internal.js.driver.goog.GoogBackend;
import org.apache.flex.compiler.internal.tree.as.NamespaceAccessExpressionNode;
import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
+import org.apache.flex.compiler.tree.as.IFunctionCallNode;
import org.apache.flex.compiler.tree.as.IIfNode;
+import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
import org.apache.flex.compiler.tree.as.IVariableNode;
import org.junit.Ignore;
import org.junit.Test;
@@ -35,6 +37,30 @@ import org.junit.Test;
*/
public class TestGoogExpressions extends TestExpressions
{
+
+ // TODO (erikdebruin) implement 'goog.base' call for 'super'
+
+ @Ignore
+ @Override
+ @Test
+ public void testVisitLanguageIdentifierNode_SuperMethod_1()
+ {
+ IMemberAccessExpressionNode node = (IMemberAccessExpressionNode) getNode(
+ "if (a) super.foo();", IMemberAccessExpressionNode.class);
+ visitor.visitMemberAccessExpression(node);
+ assertOut("goog.base(this, 'foo')");
+ }
+
+ @Ignore
+ @Override
+ @Test
+ public void testVisitLanguageIdentifierNode_SuperMethod_2()
+ {
+ IFunctionCallNode node = (IFunctionCallNode) getNode(
+ "if (a) super.foo(a, b, c);", IFunctionCallNode.class);
+ visitor.visitFunctionCall(node);
+ assertOut("goog.base(this, 'foo', a, b, c)");
+ }
//----------------------------------
// Primary expression keywords
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java Thu Jan 10 13:55:32 2013
@@ -34,9 +34,7 @@ import org.junit.Test;
public class TestGoogMethodMembers extends TestMethodMembers
{
// TODO (erikdebruin)
- // 1) ideally '@this' should only be included in the annotation if there is
- // actually a reference to 'this' in the function body
- // 10) can we safely ignore the 'public' and custom namespaces?
+ // 1) can we safely ignore custom namespaces?
@Override
@Test
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java?rev=1431363&r1=1431362&r2=1431363&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java Thu Jan 10 13:55:32 2013
@@ -241,7 +241,6 @@ public class TestGoogStatements extends
// label : for () {}
//----------------------------------
- @Ignore
@Override
@Test
public void testVisitLabel_1()
@@ -250,10 +249,9 @@ public class TestGoogStatements extends
"foo: for each(var i:int in obj) { break foo; }",
LabeledStatementNode.class);
visitor.visitLabeledStatement(node);
- assertOut("foo : for each (var i:int in obj) {\n\tbreak foo;\n}");
+ assertOutDebug("foo : for each (var /** @type {number} */ i in obj) {\n\tbreak foo;\n}");
}
- @Ignore
@Override
@Test
public void testVisitLabel_1a()
@@ -263,7 +261,7 @@ public class TestGoogStatements extends
"foo: for each(var i:int in obj) break foo;",
LabeledStatementNode.class);
visitor.visitLabeledStatement(node);
- assertOut("foo : for each (var i:int in obj)\n\tbreak foo;");
+ assertOutDebug("foo : for each (var /** @type {number} */ i in obj)\n\tbreak foo;");
}
//----------------------------------