You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ms...@apache.org on 2012/12/30 21:12:11 UTC

svn commit: r1426984 - in /incubator/flex/whiteboard/mschmalle/falconjx: compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/ compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/

Author: mschmalle
Date: Sun Dec 30 20:12:11 2012
New Revision: 1426984

URL: http://svn.apache.org/viewvc?rev=1426984&view=rev
Log:
Flex:FalconJx
- fixed failing tests
- added prototype to the method tsts in TestGoogEmiter
- removed the semi colon since FunctionNode tests will never have a semi colon due to the way the traverse emits from the TypeNode
- all tests pass

Modified:
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java
    incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/JSEmitter.java

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java?rev=1426984&r1=1426983&r2=1426984&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java (original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogEmiter.java Sun Dec 30 20:12:11 2012
@@ -64,7 +64,7 @@ public class TestGoogEmiter extends Test
         JSSharedData.OUTPUT_JSDOC = false;
         IFunctionNode node = getMethodSimple("function method1():void{\n}");
         visitor.visitFunction(node);
-        assertOut("A.method1 = function() {\n}");
+        assertOut("A.prototype.method1 = function() {\n}");
         JSSharedData.OUTPUT_JSDOC = true;
     }
 
@@ -74,7 +74,7 @@ public class TestGoogEmiter extends Test
         JSSharedData.OUTPUT_JSDOC = false;
         IFunctionNode node = getMethod("function method1(bar:int):int{\n}");
         visitor.visitFunction(node);
-        assertOut("foo.bar.A.method1 = function(bar) {\n}");
+        assertOut("foo.bar.A.prototype.method1 = function(bar) {\n}");
         JSSharedData.OUTPUT_JSDOC = true;
     }
 
@@ -84,7 +84,7 @@ public class TestGoogEmiter extends Test
         JSSharedData.OUTPUT_JSDOC = false;
         IFunctionNode node = getMethod("function method1(bar:int, baz:String, goo:A):void{\n}");
         visitor.visitFunction(node);
-        assertOut("foo.bar.A.method1 = function(bar, baz, goo) {\n}");
+        assertOut("foo.bar.A.prototype.method1 = function(bar, baz, goo) {\n}");
         JSSharedData.OUTPUT_JSDOC = true;
     }
 
@@ -96,7 +96,7 @@ public class TestGoogEmiter extends Test
         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.method1 = "
+                + " * @param {A} goo\n * @return {void}\n */\nfoo.bar.A.prototype.method1 = "
                 + "function(bar, baz, goo) {\n}");
     }
 
@@ -116,7 +116,7 @@ public class TestGoogEmiter extends Test
         JSSharedData.OUTPUT_JSDOC = false;
         IFunctionNode node = getMethod("function method1(bar:int = 42, bax:int = 4):void{\n}");
         visitor.visitFunction(node);
-        assertOut("foo.bar.A.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
+        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;
     }
@@ -137,7 +137,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();}");
         visitor.visitFunction(node);
-        assertOut("foo.bar.A.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
+        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\t"
                 + "if (a)\n\t\tfoo();\n}");
         JSSharedData.OUTPUT_JSDOC = true;
@@ -160,7 +160,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;}");
         visitor.visitFunction(node);
-        assertOut("foo.bar.A.method1 = function(p1, p2, p3, p4) {\n\tif (arguments.length < 4) "
+        assertOut("foo.bar.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;
@@ -181,7 +181,7 @@ public class TestGoogEmiter extends Test
         JSSharedData.OUTPUT_ALTERNATE = true;
         IFunctionNode node = getMethod("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.method1 = function(p1, p2, p3, p4) {\n"
+        assertOut("foo.bar.A.prototype.method1 = function(p1, p2, p3, p4) {\n"
                 + "\tp3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
                 + "\tp4 = typeof p4 !== 'undefined' ? p4 : 4;\n"
                 + "\treturn p1 + p2 + p3 + p4;\n}");
@@ -202,7 +202,7 @@ public class TestGoogEmiter extends Test
         JSSharedData.OUTPUT_ALTERNATE = true;
         IFunctionNode node = getMethod("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{}");
         visitor.visitFunction(node);
-        assertOut("foo.bar.A.method1 = function(p1, p2, p3, p4) {\n"
+        assertOut("foo.bar.A.prototype.method1 = function(p1, p2, p3, p4) {\n"
                 + "\tp3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
                 + "\tp4 = typeof p4 !== 'undefined' ? p4 : 4;\n}");
         JSSharedData.OUTPUT_ALTERNATE = false;

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java?rev=1426984&r1=1426983&r2=1426984&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java (original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogMethodMembers.java Sun Dec 30 20:12:11 2012
@@ -41,12 +41,24 @@ public class TestGoogMethodMembers exten
 	// 10) can we safely ignore the 'public' and custom namespaces?
 
     @Override
+    public void tearDown()
+    {
+        super.tearDown();
+        // XXX (mschmalle) We really have to get rid of these globals.
+        // I had all tests in TestGoogEmitter fail because this wasn't switched back
+        // to false in your tests below, this proves these are bad and are just 
+        // left from FalconJS
+        // not switching this back to false was leaving extra \t in method blocks
+        JSSharedData.OUTPUT_ALTERNATE = false;
+    }
+    
+    @Override
     @Test
     public void testMethod()
     {
         IFunctionNode node = getMethod("function foo(){}");
         visitor.visitFunction(node);
-        assertOut("A.prototype.foo = function() {\n};");
+        assertOut("A.prototype.foo = function() {\n}");
     }
 
     @Override
@@ -55,7 +67,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo():int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @return {number}\n */\nA.prototype.foo = function() {\n\treturn -1;\n};");
+        assertOut("/**\n * @return {number}\n */\nA.prototype.foo = function() {\n\treturn -1;\n}");
     }
 
     @Override
@@ -64,7 +76,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo(bar):int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {*} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\treturn -1;\n};");
+        assertOut("/**\n * @param {*} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\treturn -1;\n}");
     }
 
     @Override
@@ -73,7 +85,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo(bar:String):int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\treturn -1;\n};");
+        assertOut("/**\n * @param {string} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\treturn -1;\n}");
     }
 
     @Override
@@ -83,7 +95,7 @@ public class TestGoogMethodMembers exten
         IFunctionNode node = getMethod("function foo(bar:String = \"baz\"):int{\treturn -1;}");
     	JSSharedData.OUTPUT_ALTERNATE = true;
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string=} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\tbar = typeof bar !== 'undefined' ? bar : \"baz\";\n\treturn -1;\n};");
+        assertOut("/**\n * @param {string=} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\tbar = typeof bar !== 'undefined' ? bar : \"baz\";\n\treturn -1;\n}");
     }
 
     @Test
@@ -91,7 +103,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo(bar:String = \"baz\"):int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string=} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\tif (arguments.length < 1) {\n\t\tbar = \"baz\";\n\t}\n\treturn -1;\n};");
+        assertOut("/**\n * @param {string=} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\tif (arguments.length < 1) {\n\t\tbar = \"baz\";\n\t}\n\treturn -1;\n}");
     }
 
     @Override
@@ -101,7 +113,7 @@ public class TestGoogMethodMembers exten
         IFunctionNode node = getMethod("function foo(bar:String, baz:int = null):int{\treturn -1;}");
     	JSSharedData.OUTPUT_ALTERNATE = true;
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n};");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
 
     @Test
@@ -109,7 +121,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo(bar:String, baz:int = null):int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tif (arguments.length < 2) {\n\t\tbaz = null;\n\t}\n\treturn -1;\n};");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tif (arguments.length < 2) {\n\t\tbaz = null;\n\t}\n\treturn -1;\n}");
     }
 
     @Override
@@ -118,7 +130,7 @@ public class TestGoogMethodMembers exten
     {
         IFunctionNode node = getMethod("function foo(bar:String, ...rest):int{\treturn -1;}");
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string} bar\n * @param {...} rest\n * @return {number}\n */\nA.prototype.foo = function(bar, rest) {\n\trest = Array.prototype.slice.call(arguments, 1);\n\treturn -1;\n};");
+        assertOut("/**\n * @param {string} bar\n * @param {...} rest\n * @return {number}\n */\nA.prototype.foo = function(bar, rest) {\n\trest = Array.prototype.slice.call(arguments, 1);\n\treturn -1;\n}");
     }
 
     @Override
@@ -129,7 +141,7 @@ public class TestGoogMethodMembers exten
     	JSSharedData.OUTPUT_ALTERNATE = true;
         visitor.visitFunction(node);
         // we ignore the 'public' namespace completely
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n};");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
 
     @Override
@@ -140,7 +152,7 @@ public class TestGoogMethodMembers exten
     	JSSharedData.OUTPUT_ALTERNATE = true;
         visitor.visitFunction(node);
         // we ignore the custom namespaces completely (are there side effects I'm missing?)
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n};");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
     
     @Override
@@ -153,7 +165,7 @@ public class TestGoogMethodMembers exten
         // (erikdebruin) here we actually DO want to declare the method
         //               directly on the 'class' constructor instead of the
         //               prototype!
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n};");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
 
     @Override
@@ -163,7 +175,7 @@ public class TestGoogMethodMembers exten
         IFunctionNode node = getMethod("public override function foo(bar:String, baz:int = null):int{\treturn -1;}");
     	JSSharedData.OUTPUT_ALTERNATE = true;
         visitor.visitFunction(node);
-        assertOutDebug("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n};");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
 
     @Override
@@ -173,7 +185,7 @@ public class TestGoogMethodMembers exten
         IFunctionNode node = getMethod("override public function foo(bar:String, baz:int = null):int{return -1;}");
     	JSSharedData.OUTPUT_ALTERNATE = true;
         visitor.visitFunction(node);
-        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n};");
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nA.prototype.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
     }
 
     @Override

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/JSEmitter.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/JSEmitter.java?rev=1426984&r1=1426983&r2=1426984&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/JSEmitter.java (original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/JSEmitter.java Sun Dec 30 20:12:11 2012
@@ -122,6 +122,6 @@ public class JSEmitter extends ASEmitter
     {
     	super.writeBlockClose();
         
-    	write(";");
+    	//write(";");
     }
 }