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/11 17:23:29 UTC
svn commit: r1432134 - in /flex/whiteboard/mschmalle/falconjx:
compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/
compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/
compiler.jx.tests/src/org/apache/flex/compiler/in...
Author: erikdebruin
Date: Fri Jan 11 16:23:29 2013
New Revision: 1432134
URL: http://svn.apache.org/viewvc?rev=1432134&view=rev
Log:
- fixed a typo in the ASBlockWalker ('switch' instead of 'swtich')
- fixed issue where there always are two extra line breaks at the end of the output
- fixed issue where there was a line break to many in the 'header' if there are no imports
- cleaned up all tests:
- all asserts are now commented in: if test fails, it's given @Ignore and a TODO
- all @Ignore tests now have a TODO or at least a comment
- made a few more tests pass
Modified:
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/TestExpressions.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/TestMethodMembers.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestStatements.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDEmiter.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogAccessorMembers.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/TestGoogFieldMembers.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogInterface.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java
flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogStatements.java
flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java
flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
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=1432134&r1=1432133&r2=1432134&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 Fri Jan 11 16:23:29 2013
@@ -211,6 +211,7 @@ public class TestBase
code += line + "\n";
line = in.readLine();
}
+ code = code.substring(0, code.length() - 1); // (erikdebruin) remove last line break
in.close();
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestExpressions.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestExpressions.java?rev=1432134&r1=1432133&r2=1432134&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestExpressions.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestExpressions.java Fri Jan 11 16:23:29 2013
@@ -470,11 +470,11 @@ public class TestExpressions extends Tes
@Test
public void testParentheses_1()
{
- // TODO (erikdebruin/mschmalle) what happens to the parentheses?
+ // TODO (erikdebruin/mschmalle) why aren't parentheses preserved?
IVariableNode node = (IVariableNode) getNode("var a = (a + b);",
IVariableNode.class);
visitor.visitVariable(node);
- assertOutDebug("var a = (a + b)");
+ assertOut("var a = (a + b)");
}
@Ignore
@@ -484,7 +484,7 @@ public class TestExpressions extends Tes
IVariableNode node = (IVariableNode) getNode("var a = (a + b) - c;",
IVariableNode.class);
visitor.visitVariable(node);
- assertOutDebug("var a = (a + b) - c");
+ assertOut("var a = (a + b) - c");
}
@Ignore
@@ -494,7 +494,7 @@ public class TestExpressions extends Tes
IVariableNode node = (IVariableNode) getNode("var a = ((a + b) - (c + d)) * e;",
IVariableNode.class);
visitor.visitVariable(node);
- assertOutDebug("var a = ((a + b) - (c + d)) * e");
+ assertOut("var a = ((a + b) - (c + d)) * e");
}
@Test
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=1432134&r1=1432133&r2=1432134&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 Fri Jan 11 16:23:29 2013
@@ -101,14 +101,12 @@ public class TestGlobalClasses extends T
assertOut("var a:EvalError = new EvalError()");
}
- @Ignore
@Test
public void testFunction()
{
- // TODO (erikdebruin) how to test?
- IVariableNode node = getVariable("");
+ IVariableNode node = getVariable("var a:Function = new Function();");
visitor.visitVariable(node);
- assertOut("");
+ assertOut("var a:Function = new Function()");
}
@Test
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=1432134&r1=1432133&r2=1432134&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 Fri Jan 11 16:23:29 2013
@@ -101,6 +101,7 @@ public class TestMethodMembers extends T
@Test
public void testMethod_withRestParameterTypeReturnType()
{
+ // TODO (erikdebruin/mschmalle) handle ...rest parameter correctly
IFunctionNode node = getMethod("function foo(bar:String, ...rest):int{\treturn -1;}");
visitor.visitFunction(node);
assertOut("function foo(bar:String, ...rest):int {\n\treturn -1;\n}");
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestStatements.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestStatements.java?rev=1432134&r1=1432133&r2=1432134&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestStatements.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestStatements.java Fri Jan 11 16:23:29 2013
@@ -366,7 +366,7 @@ public class TestStatements extends Test
ISwitchNode node = (ISwitchNode) getNode("switch(i){case 1: break;}",
ISwitchNode.class);
visitor.visitSwitch(node);
- assertOut("swtich (i) {\n\tcase 1:\n\t\tbreak;\n}");
+ assertOut("switch (i) {\n\tcase 1:\n\t\tbreak;\n}");
}
@Test
@@ -377,7 +377,7 @@ public class TestStatements extends Test
visitor.visitSwitch(node);
// TODO case BLOCK statements are SYNTHESIZED so they will never show BRACES
// without extra help from us
- assertOut("swtich (i) {\n\tcase 1:\n\t\tbreak;\n}");
+ assertOut("switch (i) {\n\tcase 1:\n\t\tbreak;\n}");
}
@Test
@@ -386,7 +386,7 @@ public class TestStatements extends Test
ISwitchNode node = (ISwitchNode) getNode(
"switch(i){case 1: break; default: return;}", ISwitchNode.class);
visitor.visitSwitch(node);
- assertOut("swtich (i) {\n\tcase 1:\n\t\tbreak;\n\tdefault:\n\t\treturn;\n}");
+ assertOut("switch (i) {\n\tcase 1:\n\t\tbreak;\n\tdefault:\n\t\treturn;\n}");
}
//----------------------------------
@@ -437,6 +437,8 @@ public class TestStatements extends Test
@Test
public void testVisit()
{
+ // TODO (erikdebruin) there is an 'extra' semi-colon at the end (in the
+ // 'foo' block that doesn't seem to belong there...
IFileNode node = (IFileNode) getNode(
"try { a; } catch (e:Error) { if (a) { if (b) { if (c) b; else if (f) a; else e; }} } finally { }"
+ "if (d) for (var i:int = 0; i < len; i++) break;"
@@ -450,6 +452,6 @@ public class TestStatements extends Test
+ "foo: for each(var i:int in obj) break foo;",
IFileNode.class);
visitor.visitFile(node);
- //assertOut("");
+ assertOut("package {\n\tpublic class A {\n\t\tfunction a():void {\n\t\t\ttry {\n\t\t\t\ta;\n\t\t\t} catch (e:Error) {\n\t\t\t\tif (a) {\n\t\t\t\t\tif (b) {\n\t\t\t\t\t\tif (c)\n\t\t\t\t\t\t\tb;\n\t\t\t\t\t\telse if (f)\n\t\t\t\t\t\t\ta;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\te;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t}\n\t\t\tif (d)\n\t\t\t\tfor (var i:int = 0; i < len; i++)\n\t\t\t\t\tbreak;\n\t\t\tif (a) {\n\t\t\t\twith (ab) {\n\t\t\t\t\tc();\n\t\t\t\t}\n\t\t\t\tdo {\n\t\t\t\t\ta++;\n\t\t\t\t\tdo\n\t\t\t\t\t\ta++;\n\t\t\t\t\twhile (a > b);\n\t\t\t\t} while (c > d);\n\t\t\t}\n\t\t\tif (b) {\n\t\t\t\ttry {\n\t\t\t\t\ta;\n\t\t\t\t\tthrow new Error('foo');\n\t\t\t\t} catch (e:Error) {\n\t\t\t\t\tswitch (i) {\n\t\t\t\t\t\tcase 1:\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} catch (f:Error) {\n\t\t\t\t\tc;\n\t\t\t\t\teee.dd;\n\t\t\t\t} finally {\n\t\t\t\t\td;\n\t\t\t\t\tvar a:Object = function(foo:int, bar:String = 'goo')
:int {\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\t};\n\t\t\t\t\teee.dd;\n\t\t\t\t\teee.dd;\n\t\t\t\t\teee.dd;\n\t\t\t\t\teee.dd;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfoo : for each (var i:int in obj)\n\t\t\t\tbreak foo;;\n\t}\n}\n}");
}
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDEmiter.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDEmiter.java?rev=1432134&r1=1432133&r2=1432134&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDEmiter.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/amd/TestAMDEmiter.java Fri Jan 11 16:23:29 2013
@@ -25,7 +25,6 @@ import org.apache.flex.compiler.internal
import org.apache.flex.compiler.internal.js.driver.amd.AMDBackend;
import org.apache.flex.compiler.tree.as.IFileNode;
import org.apache.flex.compiler.tree.as.IFunctionNode;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -38,13 +37,11 @@ import org.junit.Test;
*/
public class TestAMDEmiter extends TestWalkerBase
{
- // emitPackageHeader()
- // emitImports()
- // emitClass()
-
- @Test
+ @Test
public void testSimple()
{
+ // (erikdebruin) this test isn't outputting JS; ignoring for now, as
+ // we are not (yet) working on AMD JS output
String code = "package com.example.components {"
+ "import org.apache.flex.html.staticControls.TextButton;"
+ "public class MyTextButton extends TextButton {"
@@ -55,49 +52,37 @@ public class TestAMDEmiter extends TestW
+ "return \"Don't \" + _privateVar + value; }";
IFileNode node = getFileNode(code);
visitor.visitFile(node);
- //assertOut("");
+ assertOutDebug("package com.example.components {\n\tpublic class MyTextButton extends TextButton {\n\t\tcom.example.components.MyTextButton = function() {\n\t\t\tif (foo() != 42) {\n\t\t\t\tbar();\n\t\t\t}\n\t\t}\n\t\tprivate var _privateVar:String = \"do \";\n\t\tpublic var publicProperty:Number = 100;\n\t\tcom.example.components.MyTextButton.prototype.myFunction = function(value) {\n\t\t\treturn \"Don't \" + _privateVar + value;\n\t\t}\n\t}\n}");
}
@Test
public void testSimpleMethod()
{
+ IFunctionNode node = getMethod("function method1():void{\n}");
JSSharedData.OUTPUT_JSDOC = false;
- IFunctionNode node = getMethodSimple("function method1():void{\n}");
visitor.visitFunction(node);
- assertOut("A.prototype.method1 = function() {\n}");
JSSharedData.OUTPUT_JSDOC = true;
+ assertOut("A.prototype.method1 = function() {\n}");
}
@Test
public void testSimpleParameterReturnType()
{
- JSSharedData.OUTPUT_JSDOC = false;
IFunctionNode node = getMethod("function method1(bar:int):int{\n}");
+ JSSharedData.OUTPUT_JSDOC = false;
visitor.visitFunction(node);
- assertOut("foo.bar.A.prototype.method1 = function(bar) {\n}");
JSSharedData.OUTPUT_JSDOC = true;
+ assertOut("A.prototype.method1 = function(bar) {\n}");
}
@Test
public void testSimpleMultipleParameter()
{
- JSSharedData.OUTPUT_JSDOC = false;
IFunctionNode node = getMethod("function method1(bar:int, baz:String, goo:A):void{\n}");
+ JSSharedData.OUTPUT_JSDOC = false;
visitor.visitFunction(node);
- assertOut("foo.bar.A.prototype.method1 = function(bar, baz, goo) {\n}");
JSSharedData.OUTPUT_JSDOC = true;
- }
-
- @Ignore
- @Test
- public void testSimpleMultipleParameter_JSDoc()
- {
- // jsdoc still needs to be sorted out before tests are executing
- IFunctionNode node = getMethod("function method1(bar:int, baz:String, goo:A):void{\n}");
- visitor.visitFunction(node);
- assertOut("/**\n * @this {foo.bar.A}\n * @param {int} bar\n * @param {String} baz\n"
- + " * @param {A} goo\n * @return {void}\n */\nfoo.bar.A.prototype.method1 = "
- + "function(bar, baz, goo) {\n}");
+ assertOut("A.prototype.method1 = function(bar, baz, goo) {\n}");
}
@Test
@@ -114,13 +99,13 @@ public class TestAMDEmiter extends TestW
return p1 + p2 + p3 + p4;
}
*/
- 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;}");
+ JSSharedData.OUTPUT_JSDOC = false;
visitor.visitFunction(node);
- assertOut("foo.bar.A.prototype.method1 = function(p1, p2, p3, p4) {\n\tif (arguments.length < 4) "
+ JSSharedData.OUTPUT_JSDOC = true;
+ assertOut("A.prototype.method1 = function(p1, p2, p3, p4) {\n\tif (arguments.length < 4) "
+ "{\n\t\tif (arguments.length < 3) {\n\t\t\tp3 = 3;\n\t\t}\n\t\tp4 = 4;\n\t}"
+ "\n\treturn p1 + p2 + p3 + p4;\n}");
- JSSharedData.OUTPUT_JSDOC = true;
}
@Test
@@ -136,13 +121,13 @@ public class TestAMDEmiter extends TestW
}
}
*/
- JSSharedData.OUTPUT_JSDOC = false;
IFunctionNode node = getMethod("function method1(bar:int = 42, bax:int = 4):void{if (a) foo();}");
+ JSSharedData.OUTPUT_JSDOC = false;
visitor.visitFunction(node);
- assertOut("foo.bar.A.prototype.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
+ JSSharedData.OUTPUT_JSDOC = true;
+ assertOut("A.prototype.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
+ "if (arguments.length < 1) {\n\t\t\tbar = 42;\n\t\t}\n\t\tbax = 4;\n\t}\n\t"
+ "if (a)\n\t\tfoo();\n}");
- JSSharedData.OUTPUT_JSDOC = true;
}
@Test
@@ -158,12 +143,12 @@ public class TestAMDEmiter extends TestW
}
}
*/
- JSSharedData.OUTPUT_JSDOC = false;
IFunctionNode node = getMethod("function method1(bar:int = 42, bax:int = 4):void{\n}");
+ JSSharedData.OUTPUT_JSDOC = false;
visitor.visitFunction(node);
- assertOut("foo.bar.A.prototype.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
- + "if (arguments.length < 1) {\n\t\t\tbar = 42;\n\t\t}\n\t\tbax = 4;\n\t}\n}");
JSSharedData.OUTPUT_JSDOC = true;
+ assertOut("A.prototype.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
+ + "if (arguments.length < 1) {\n\t\t\tbar = 42;\n\t\t}\n\t\tbax = 4;\n\t}\n}");
}
@Override
@@ -171,22 +156,4 @@ public class TestAMDEmiter extends TestW
{
return new AMDBackend();
}
-
- 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/TestGoogAccessorMembers.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogAccessorMembers.java?rev=1432134&r1=1432133&r2=1432134&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogAccessorMembers.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogAccessorMembers.java Fri Jan 11 16:23:29 2013
@@ -25,6 +25,7 @@ import org.apache.flex.compiler.internal
import org.apache.flex.compiler.tree.as.IAccessorNode;
import org.apache.flex.compiler.tree.as.IGetterNode;
import org.apache.flex.compiler.tree.as.ISetterNode;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -69,24 +70,26 @@ public class TestGoogAccessorMembers ext
+ "\n\t{get:function() {\n\t\treturn -1;\n\t}, configurable:true}\n)");
}
+ @Ignore
@Override
@Test
public void testGetAccessor_withNamespaceOverride()
{
+ // TODO (erikdebruin) public override get
IAccessorNode node = getAccessor("public override function get foo():int{return -1;}");
visitor.visitFunction(node);
- // TODO [TestGoog] public override get
- //assertOut("");
+ assertOut("");
}
+ @Ignore
@Override
@Test
public void testGetAccessor_withStatic()
{
+ // TODO (erikdebruin) public static get
IAccessorNode node = getAccessor("public static function get foo():int{return -1;}");
visitor.visitFunction(node);
- // TODO [TestGoog] public static get
- //assertOut("");
+ assertOut("");
}
@Override
@@ -117,24 +120,26 @@ public class TestGoogAccessorMembers ext
+ " {\n\t}, configurable:true}\n)");
}
+ @Ignore
@Override
@Test
public void testSetAccessor_withNamespaceOverride()
{
+ // TODO (erikdebruin) public override set
IAccessorNode node = getAccessor("public override function set foo(value:int):void{}");
visitor.visitFunction(node);
- // TODO [TestGoog] public override set
- //assertOut("");
+ assertOut("");
}
+ @Ignore
@Override
@Test
public void testSetAccessor_withStatic()
{
+ // TODO (erikdebruin) public static set
IAccessorNode node = getAccessor("public static function set foo(value:int):void{}");
visitor.visitFunction(node);
- // TODO [TestGoog] public static set
- //assertOut("");
+ assertOut("");
}
@Override
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=1432134&r1=1432133&r2=1432134&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 Fri Jan 11 16:23:29 2013
@@ -41,7 +41,7 @@ public class TestGoogClass extends TestC
{
IClassNode node = getClassNode("public class A{}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n");
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};");
}
@Override
@@ -52,7 +52,7 @@ public class TestGoogClass extends TestC
// 'internal' namespace?
IClassNode node = getClassNode("internal class A{}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n");
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};");
}
@Override
@@ -63,7 +63,7 @@ public class TestGoogClass extends TestC
// 'final' keyword?
IClassNode node = getClassNode("public final class A{}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n");
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};");
}
@Override
@@ -74,7 +74,7 @@ public class TestGoogClass extends TestC
// 'dynamic' keyword?
IClassNode node = getClassNode("public dynamic class A{}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n");
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};");
}
@Override
@@ -86,7 +86,7 @@ public class TestGoogClass extends TestC
// trigger the '@extends' notation?
IClassNode node = getClassNode("public class A extends Button {public function A() {}}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);\n\n");
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
}
@Override
@@ -95,7 +95,7 @@ public class TestGoogClass extends TestC
{
IClassNode node = getClassNode("public class A implements IEventDispatcher {public function A() {}}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n * @implements {IEventDispatcher}\n */\norg.apache.flex.A = function() {\n};\n\n");
+ assertOut("/**\n * @constructor\n * @implements {IEventDispatcher}\n */\norg.apache.flex.A = function() {\n};");
}
@Override
@@ -104,7 +104,7 @@ public class TestGoogClass extends TestC
{
IClassNode node = getClassNode("public class A implements IEventDispatcher, ILogger {public function A() {}}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n * @implements {IEventDispatcher}\n * @implements {ILogger}\n */\norg.apache.flex.A = function() {\n};\n\n");
+ assertOut("/**\n * @constructor\n * @implements {IEventDispatcher}\n * @implements {ILogger}\n */\norg.apache.flex.A = function() {\n};");
}
@Override
@@ -113,7 +113,7 @@ public class TestGoogClass extends TestC
{
IClassNode node = getClassNode("public class A extends Button implements IEventDispatcher {public function A() {}}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {IEventDispatcher}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);\n\n");
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {IEventDispatcher}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
}
@Override
@@ -122,7 +122,7 @@ public class TestGoogClass extends TestC
{
IClassNode node = getClassNode("public class A extends Button implements IEventDispatcher, ILogger {public function A() {}}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {IEventDispatcher}\n * @implements {ILogger}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);\n\n");
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {IEventDispatcher}\n * @implements {ILogger}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
}
@Override
@@ -132,7 +132,7 @@ public class TestGoogClass extends TestC
// TODO (erikdebruin) 'final' keyword: see 'testSimpleFinal' above
IClassNode node = getClassNode("public final class A extends Button implements IEventDispatcher, ILogger {public function A() {}}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {IEventDispatcher}\n * @implements {ILogger}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);\n\n");
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {IEventDispatcher}\n * @implements {ILogger}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
}
@Override
@@ -141,7 +141,7 @@ public class TestGoogClass extends TestC
{
IClassNode node = getClassNode("public class A extends spark.components.Button implements flash.events.IEventDispatcher, mx.logging.ILogger {public function A() {}}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {IEventDispatcher}\n * @implements {ILogger}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);\n\n");
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {IEventDispatcher}\n * @implements {ILogger}\n */\norg.apache.flex.A = function() {\n\tgoog.base(this);\n}\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
}
@Ignore
@@ -163,7 +163,7 @@ public class TestGoogClass extends TestC
IClassNode node = getClassNode("public class A {public var a:Object;protected var b:String; "
+ "private var c:int; internal var d:uint; var e:Number}");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.a;\n\n/**\n * @protected\n * @type {string}\n */\norg.apache.flex.A.prototype.b;\n\n/**\n * @private\n * @type {number}\n */\norg.apache.flex.A.prototype.c;\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.d;\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.e;\n\n");
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.a;\n\n/**\n * @protected\n * @type {string}\n */\norg.apache.flex.A.prototype.b;\n\n/**\n * @private\n * @type {number}\n */\norg.apache.flex.A.prototype.c;\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.d;\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.e;");
}
@Override
@@ -176,7 +176,7 @@ public class TestGoogClass extends TestC
"private static const C:Number = 42;" +
"foo_bar static const C:String = 'me' + 'you';");
visitor.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n/**\n * @protected\n * @const\n * @type {number}\n */\norg.apache.flex.A.B = 42;\n\n/**\n * @private\n * @const\n * @type {number}\n */\norg.apache.flex.A.C = 42;\n\n/**\n * @const\n * @type {string}\n */\norg.apache.flex.A.C = 'me' + 'you';\n\n");
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n/**\n * @protected\n * @const\n * @type {number}\n */\norg.apache.flex.A.B = 42;\n\n/**\n * @private\n * @const\n * @type {number}\n */\norg.apache.flex.A.C = 42;\n\n/**\n * @const\n * @type {string}\n */\norg.apache.flex.A.C = 'me' + 'you';");
}
@Ignore
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=1432134&r1=1432133&r2=1432134&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 Fri Jan 11 16:23:29 2013
@@ -37,10 +37,6 @@ import org.junit.Test;
*/
public class TestGoogEmiter extends TestWalkerBase
{
- // emitPackageHeader()
- // emitImports()
- // emitClass()
-
@Test
public void testSimple()
{
@@ -54,7 +50,7 @@ public class TestGoogEmiter extends Test
+ "return \"Don't \" + _privateVar + value; }";
IFileNode node = getFileNode(code);
visitor.visitFile(node);
- assertOutDebug("goog.provide('com.example.components.MyTextButton');\n\ngoog.require('spark.components.Button');\n\n/**\n * @constructor\n * @extends {spark.components.Button}\n */\ncom.example.components.MyTextButton = function() {\n\tgoog.base(this);\n\tif (foo() != 42) {\n\t\tbar();\n\t}\n}\ngoog.inherits(com.example.components.MyTextButton, spark.components.Button);\n\n/**\n * @private\n * @type {string}\n */\ncom.example.components.MyTextButton.prototype._privateVar = \"do \";\n\n/**\n * @type {number}\n */\ncom.example.components.MyTextButton.prototype.publicProperty = 100;\n\n/**\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyTextButton.prototype.myFunction = function(value) {\n\treturn \"Don't \" + _privateVar + value;\n};\n\n");
+ assertOut("goog.provide('com.example.components.MyTextButton');\n\ngoog.require('spark.components.Button');\n\n/**\n * @constructor\n * @extends {spark.components.Button}\n */\ncom.example.components.MyTextButton = function() {\n\tgoog.base(this);\n\tif (foo() != 42) {\n\t\tbar();\n\t}\n}\ngoog.inherits(com.example.components.MyTextButton, spark.components.Button);\n\n/**\n * @private\n * @type {string}\n */\ncom.example.components.MyTextButton.prototype._privateVar = \"do \";\n\n/**\n * @type {number}\n */\ncom.example.components.MyTextButton.prototype.publicProperty = 100;\n\n/**\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyTextButton.prototype.myFunction = function(value) {\n\treturn \"Don't \" + _privateVar + value;\n};");
}
@Test
@@ -98,14 +94,6 @@ public class TestGoogEmiter extends Test
@Test
public void testDefaultParameter()
{
- /*
- foo.bar.A.method1 = function(p1, p2, p3, p4) {
- p3 = typeof p3 !== 'undefined' ? p3 : 3;
- p4 = typeof p4 !== 'undefined' ? p4 : 4;
-
- return p1 + p2 + p3 + p4;
- }
- */
JSSharedData.OUTPUT_JSDOC = false;
IFunctionNode node = getMethodWithPackage("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{return p1 + p2 + p3 + p4;}");
visitor.visitFunction(node);
@@ -119,12 +107,6 @@ public class TestGoogEmiter extends Test
@Test
public void testDefaultParameter_Body()
{
- /*
- foo.bar.A.method1 = function(p1, p2, p3, p4) {
- p3 = typeof p3 !== 'undefined' ? p3 : 3;
- p4 = typeof p4 !== 'undefined' ? p4 : 4;
- }
- */
JSSharedData.OUTPUT_JSDOC = false;
IFunctionNode node = getMethodWithPackage("function method1(bar:int = 42, bax:int = 4):void{if (a) foo();}");
visitor.visitFunction(node);
@@ -138,12 +120,6 @@ public class TestGoogEmiter extends Test
@Test
public void testDefaultParameter_NoBody()
{
- /*
- foo.bar.A.method1 = function(p1, p2, p3, p4) {
- p3 = typeof p3 !== 'undefined' ? p3 : 3;
- p4 = typeof p4 !== 'undefined' ? p4 : 4;
- }
- */
JSSharedData.OUTPUT_JSDOC = false;
IFunctionNode node = getMethodWithPackage("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{}");
visitor.visitFunction(node);
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=1432134&r1=1432133&r2=1432134&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 Fri Jan 11 16:23:29 2013
@@ -37,14 +37,12 @@ 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()
{
+ // TODO (erikdebruin) implement 'goog.base' call for 'super'
IMemberAccessExpressionNode node = (IMemberAccessExpressionNode) getNode(
"if (a) super.foo();", IMemberAccessExpressionNode.class);
visitor.visitMemberAccessExpression(node);
@@ -165,7 +163,7 @@ public class TestGoogExpressions extends
NamespaceAccessExpressionNode node = (NamespaceAccessExpressionNode) getExpressionNode(
"a::b", NamespaceAccessExpressionNode.class);
visitor.visitNamespaceAccessExpression(node);
- assertOut("a::b");
+ assertOut("");
}
@Ignore
@@ -178,7 +176,7 @@ public class TestGoogExpressions extends
NamespaceAccessExpressionNode node = (NamespaceAccessExpressionNode) getExpressionNode(
"a::b::c", NamespaceAccessExpressionNode.class);
visitor.visitNamespaceAccessExpression(node);
- assertOut("a::b::c");
+ assertOut("");
}
protected IBackend createBackend()
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFieldMembers.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFieldMembers.java?rev=1432134&r1=1432133&r2=1432134&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFieldMembers.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFieldMembers.java Fri Jan 11 16:23:29 2013
@@ -105,8 +105,8 @@ public class TestGoogFieldMembers extend
assertOut("/**\n * @protected\n * @type {Array.<Foo>}\n */\nA.prototype.foo");
}
- @Override
@Ignore
+ @Override
@Test
public void testField_withNamespaceTypeCollectionComplex()
{
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java?rev=1432134&r1=1432133&r2=1432134&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalClasses.java Fri Jan 11 16:23:29 2013
@@ -72,7 +72,7 @@ public class TestGoogGlobalClasses exten
@Test
public void testClass()
{
- // TODO (erikdebruin) how to test?
+ // TODO (erikdebruin) how to represent this in 'goog' JS?
IVariableNode node = getVariable("");
visitor.visitVariable(node);
assertOut("");
@@ -114,15 +114,13 @@ public class TestGoogGlobalClasses exten
assertOut("var /** @type {EvalError} */ a = new EvalError()");
}
- @Ignore
@Override
@Test
public void testFunction()
{
- // TODO (erikdebruin) how to test?
- IVariableNode node = getVariable("");
+ IVariableNode node = getVariable("var a:Function = new Function();");
visitor.visitVariable(node);
- assertOut("");
+ assertOut("var /** @type {Function} */ a = new Function()");
}
@Override
@@ -286,7 +284,7 @@ public class TestGoogGlobalClasses exten
@Test
public void testVector()
{
- // TODO (erikdebruin) loose the '.<String>' notation in the JS output
+ // TODO (erikdebruin) loose the '.<String>' in the output: Vector.<String>
IVariableNode node = getVariable("var a:Vector.<String> = new Vector.<String>(['Hello', 'World']);");
visitor.visitVariable(node);
assertOut("var /** @type {Array.<String>} */ a = new Vector.<String>(['Hello','World'])");
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogInterface.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogInterface.java?rev=1432134&r1=1432133&r2=1432134&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogInterface.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogInterface.java Fri Jan 11 16:23:29 2013
@@ -34,10 +34,8 @@ import org.junit.Test;
*/
public class TestGoogInterface extends TestInterface
{
- //--------------------------------------------------------------------------
- // Interface
- //--------------------------------------------------------------------------
-
+ // TODO (erikdebruin/mschmalle) handle interfaces and accessors first ;-)
+
@Ignore
@Override
@Test
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java?rev=1432134&r1=1432133&r2=1432134&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java Fri Jan 11 16:23:29 2013
@@ -23,7 +23,6 @@ import org.apache.flex.compiler.clients.
import org.apache.flex.compiler.internal.as.codegen.TestPackage;
import org.apache.flex.compiler.internal.js.driver.goog.GoogBackend;
import org.apache.flex.compiler.tree.as.IFileNode;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -34,14 +33,6 @@ import org.junit.Test;
*/
public class TestGoogPackage extends TestPackage
{
- // TODO (erikdebruin)
- // 2) empty classes don't get a JS block (curly brackets)
- // - do we produce implicit constructors?
- // 4) there is an extra line after the 'goog.provide' line: remove
- // 5) there are two extra lines at the end of the code: remove
- // 6) constructor body in 'testPackageQualified_ClassBodyMethodContents'
- // contains code that is not yet 'goog'-ified
-
@Override
@Test
public void testPackage_Simple()
@@ -61,7 +52,6 @@ public class TestGoogPackage extends Tes
}
@Override
- @Ignore
@Test
public void testPackageSimple_Class()
{
@@ -69,40 +59,41 @@ public class TestGoogPackage extends Tes
// All class nodes in AST get either an implicit or explicit constructor
// this is an implicit and the way I have the before/after handler working
// with block disallows implicit blocks from getting { }
+
+ // (erikdebruin) the constuctor IS the class definition, in 'goog' JS,
+ // therefor we need to write out implicit constructors
+ // (if I understand the term correctly)
+
IFileNode node = getFileNode("package {public class A{}}");
visitor.visitFile(node);
- assertOut("");
+ assertOut("goog.provide('A');\n\n/**\n * @constructor\n */\nA = function() {\n};");
}
@Override
- @Ignore
@Test
public void testPackageQualified_Class()
{
- // same here; see testPackageSimple_Class
IFileNode node = getFileNode("package foo.bar.baz {public class A{}}");
visitor.visitFile(node);
- assertOut("");
+ assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n};");
}
@Override
@Test
public void testPackageQualified_ClassBody()
{
- // there is still two newlines at the end and after provide which shouldn't happen
- // I'll look into that if you don't get to it
IFileNode node = getFileNode("package foo.bar.baz {public class A{public function A(){}}}");
visitor.visitFile(node);
- assertOut("goog.provide('foo.bar.baz.A');\n\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n};\n\n");
+ assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n};");
}
@Override
@Test
public void testPackageQualified_ClassBodyMethodContents()
{
- IFileNode node = getFileNode("package foo.bar.baz {public class A{public function A(){if (a){for each(var i:Object in obj){doit();}}}}}");
+ IFileNode node = getFileNode("package foo.bar.baz {public class A{public function A(){if (a){for (var i:Object in obj){doit();}}}}}");
visitor.visitFile(node);
- //assertOut("");
+ assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n\tif (a) {\n\t\tfor (var /** @type {Object} */ i in obj) {\n\t\t\tdoit();\n\t\t}\n\t}\n};");
}
@Override
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=1432134&r1=1432133&r2=1432134&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 Fri Jan 11 16:23:29 2013
@@ -184,7 +184,6 @@ public class TestGoogStatements extends
@Test
public void testVisitForEach_1a()
{
- // TODO (erikdebruin) handle workaround for "for-each" loop
IForLoopNode node = (IForLoopNode) getNode(
"for each(var i:int in obj) break; ", IForLoopNode.class);
visitor.visitForLoop(node);
@@ -249,7 +248,7 @@ public class TestGoogStatements extends
"foo: for each(var i:int in obj) { break foo; }",
LabeledStatementNode.class);
visitor.visitLabeledStatement(node);
- assertOutDebug("foo : for each (var /** @type {number} */ i in obj) {\n\tbreak foo;\n}");
+ assertOut("foo : for each (var /** @type {number} */ i in obj) {\n\tbreak foo;\n}");
}
@Override
@@ -261,18 +260,18 @@ public class TestGoogStatements extends
"foo: for each(var i:int in obj) break foo;",
LabeledStatementNode.class);
visitor.visitLabeledStatement(node);
- assertOutDebug("foo : for each (var /** @type {number} */ i in obj)\n\tbreak foo;");
+ assertOut("foo : for each (var /** @type {number} */ i in obj)\n\tbreak foo;");
}
//----------------------------------
// all together now!
//----------------------------------
- @Ignore
@Override
@Test
public void testVisit()
{
+ // TODO (erikdebruin) check if resulting 'goog' JS is valid
IFileNode node = (IFileNode) getNode(
"try { a; } catch (e:Error) { if (a) { if (b) { if (c) b; else if (f) a; else e; }} } finally { }"
+ "if (d) for (var i:int = 0; i < len; i++) break;"
@@ -286,7 +285,7 @@ public class TestGoogStatements extends
+ "foo: for each(var i:int in obj) break foo;",
IFileNode.class);
visitor.visitFile(node);
- assertOut("");
+ assertOut("goog.provide('A');\n\n/**\n * @constructor\n */\nA = function() {\n};\n\nA.prototype.a = function() {\n\ttry {\n\t\ta;\n\t} catch (e) {\n\t\tif (a) {\n\t\t\tif (b) {\n\t\t\t\tif (c)\n\t\t\t\t\tb;\n\t\t\t\telse if (f)\n\t\t\t\t\ta;\n\t\t\t\telse\n\t\t\t\t\te;\n\t\t\t}\n\t\t}\n\t} finally {\n\t}\n\tif (d)\n\t\tfor (var /** @type {number} */ i = 0; i < len; i++)\n\t\t\tbreak;\n\tif (a) {\n\t\twith (ab) {\n\t\t\tc();\n\t\t}\n\t\tdo {\n\t\t\ta++;\n\t\t\tdo\n\t\t\t\ta++;\n\t\t\twhile (a > b);\n\t\t} while (c > d);\n\t}\n\tif (b) {\n\t\ttry {\n\t\t\ta;\n\t\t\tthrow new Error('foo');\n\t\t} catch (e) {\n\t\t\tswitch (i) {\n\t\t\t\tcase 1:\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t} catch (f) {\n\t\t\tc;\n\t\t\teee.dd;\n\t\t} finally {\n\t\t\td;\n\t\t\tvar /** @type {Object} */ a = function(foo, bar) {\n\t\t\t\tbar = typeof bar !== 'undefined' ? bar : 'goo';\n\t\t\t\treturn -1;\n\t\t\t};\n\t\t\teee.dd;\n\t\t\teee.dd;\n\t\t\teee.dd;\n\t\t\
teee.dd;\n\t\t}\n\t}\n\tfoo : for each (var /** @type {number} */ i in obj)\n\t\tbreak foo;;\n};");
}
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java?rev=1432134&r1=1432133&r2=1432134&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBlockWalker.java Fri Jan 11 16:23:29 2013
@@ -494,7 +494,7 @@ public class ASBlockWalker implements IA
public void visitSwitch(ISwitchNode node)
{
debug("visitSwitch()");
- emitter.write("swtich");
+ emitter.write("switch");
emitter.write(" ");
emitter.write("(");
walk(node.getChild(0));
Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java?rev=1432134&r1=1432133&r2=1432134&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java (original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java Fri Jan 11 16:23:29 2013
@@ -99,7 +99,14 @@ public class JSGoogEmitter extends JSEmi
write("goog.require('" + imp + "');");
write("\n");
}
- write("\n");
+
+ // (erikdebruin) only write 'closing' line break when there are
+ // actually imports...
+ if (list.size() > 1 ||
+ (list.size() == 1 && list.get(0).indexOf("__AS3__") == -1))
+ {
+ write("\n");
+ }
}
@Override
@@ -130,17 +137,16 @@ public class JSGoogEmitter extends JSEmi
// constructor
emitMethod((IFunctionNode) definition.getConstructor().getNode());
- write(";\n");
- write("\n");
+ write(";");
IDefinitionNode[] members = node.getAllMemberNodes();
for (IDefinitionNode dnode : members)
{
if (dnode instanceof IVariableNode)
{
+ write("\n\n");
emitField((IVariableNode) dnode);
- write(";\n");
- write("\n");
+ write(";");
}
}
@@ -150,9 +156,9 @@ public class JSGoogEmitter extends JSEmi
{
if (!((IFunctionNode) dnode).isConstructor())
{
+ write("\n\n");
emitMethod((IFunctionNode) dnode);
- write(";\n");
- write("\n");
+ write(";");
}
}
}