flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [4/4] git commit: [flex-falcon] [refs/heads/develop] - fix up unit tests now that more things have @expose. Hopefully this will be temporary as we work out a scheme to handle dynamic access by property name in binding and other places in the future
Date Fri, 23 Jan 2015 17:28:33 GMT
fix up unit tests now that more things have @expose.  Hopefully this will be temporary as we
work out a scheme to handle dynamic access by property name in binding and other places in
the future


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/eeaab7f1
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/eeaab7f1
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/eeaab7f1

Branch: refs/heads/develop
Commit: eeaab7f1dc40846da0c7a0c5e35e46788ec7ac5d
Parents: dcfb44e
Author: Alex Harui <aharui@apache.org>
Authored: Fri Jan 23 09:28:14 2015 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Jan 23 09:28:14 2015 -0800

----------------------------------------------------------------------
 .../codegen/js/flexjs/TestFlexJSClass.java      |  10 +-
 .../codegen/js/flexjs/TestFlexJSEmiter.java     |   2 +-
 .../js/flexjs/TestFlexJSFieldMembers.java       | 182 +++++++++++++++++++
 .../js/flexjs/TestFlexJSGlobalConstants.java    |  37 ++++
 4 files changed, 225 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/eeaab7f1/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
index 1d2ac89..fa9768a 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
@@ -99,7 +99,7 @@ public class TestFlexJSClass extends TestGoogClass
     {
         IClassNode node = getClassNode("public class B {public function B(arg1:String) {this.arg1
= arg1}; public var arg1:String;}");
         asBlockWalker.visitClass(node);
-        String expected = "/**\n * @constructor\n * @param {string} arg1\n */\norg.apache.flex.B
= function(arg1) {\n  this.arg1 = arg1;\n};\n\n\n/**\n * @type {string}\n */\norg.apache.flex.B.prototype.arg1;";
+        String expected = "/**\n * @constructor\n * @param {string} arg1\n */\norg.apache.flex.B
= function(arg1) {\n  this.arg1 = arg1;\n};\n\n\n/**\n * @expose\n * @type {string}\n */\norg.apache.flex.B.prototype.arg1;";
         assertOut(expected);
     }
 
@@ -108,7 +108,7 @@ public class TestFlexJSClass extends TestGoogClass
     {
         IClassNode node = getClassNode("public class B {public function B() {}; public var
button:Button = new Button(); public function foo():String {return button.label;};}");
         asBlockWalker.visitClass(node);
-        String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n
* @type {spark.components.Button}\n */\norg.apache.flex.B.prototype.button = new spark.components.Button();\n\n\n/**\n
* @expose\n * @return {string}\n */\norg.apache.flex.B.prototype.foo = function() {\n  return
this.button.get_label();\n};";
+        String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n
* @expose\n * @type {spark.components.Button}\n */\norg.apache.flex.B.prototype.button = new
spark.components.Button();\n\n\n/**\n * @expose\n * @return {string}\n */\norg.apache.flex.B.prototype.foo
= function() {\n  return this.button.get_label();\n};";
         assertOut(expected);
     }
 
@@ -182,7 +182,7 @@ public class TestFlexJSClass extends TestGoogClass
         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}");
         asBlockWalker.visitClass(node);
-        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n
* @type {Object}\n */\norg.apache.flex.A.prototype.a;\n\n\n/**\n * @protected\n * @type {string}\n
*/\norg.apache.flex.A.prototype.b;\n\n\n/**\n * @private\n * @type {number}\n */\norg.apache.flex.A.prototype.c;\n\n\n/**\n
* @type {number}\n */\norg.apache.flex.A.prototype.d;\n\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.e;");
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n
* @expose\n * @type {Object}\n */\norg.apache.flex.A.prototype.a;\n\n\n/**\n * @protected\n
* @type {string}\n */\norg.apache.flex.A.prototype.b;\n\n\n/**\n * @private\n * @type {number}\n
*/\norg.apache.flex.A.prototype.c;\n\n\n/**\n * @expose\n * @type {number}\n */\norg.apache.flex.A.prototype.d;\n\n\n/**\n
* @expose\n * @type {number}\n */\norg.apache.flex.A.prototype.e;");
     }
 
     @Override
@@ -195,7 +195,7 @@ public class TestFlexJSClass extends TestGoogClass
                 + "private static const C:Number = 42;"
                 + "foo_bar static const C:String = 'me' + 'you';");
         asBlockWalker.visitClass(node);
-        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n
* @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n\n/**\n * @protected\n * @const\n
* @type {number}\n */\norg.apache.flex.A.B = 42;\n\n\n/**\n * @private\n * @const\n * @type
{number}\n */\norg.apache.flex.A.C = 42;\n\n\n/**\n * @const\n * @type {string}\n */\norg.apache.flex.A.C
= 'me' + 'you';");
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n
* @expose\n * @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n\n/**\n * @protected\n
* @const\n * @type {number}\n */\norg.apache.flex.A.B = 42;\n\n\n/**\n * @private\n * @const\n
* @type {number}\n */\norg.apache.flex.A.C = 42;\n\n\n/**\n * @expose\n * @const\n * @type
{string}\n */\norg.apache.flex.A.C = 'me' + 'you';");
     }
 
     @Override
@@ -255,7 +255,7 @@ public class TestFlexJSClass extends TestGoogClass
                 + "public function foo2():String{function bar2(param1:String):String {return
param1 + baz1;}; return bar2('foo');}"
                 + "}");
         asBlockWalker.visitClass(node);
-        assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n
* @type {string}\n */\norg.apache.flex.B.prototype.baz1;\n\n\n/**\n * @expose\n * @return
{string}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n  function bar1() {\n    return
this.baz1;\n  };\n  return goog.bind(bar1, this)();\n};\n\n\n/**\n * @expose\n * @return {string}\n
*/\norg.apache.flex.B.prototype.foo2 = function() {\n  function bar2(param1) {\n    return
param1 + this.baz1;\n  };\n  return goog.bind(bar2, this)('foo');\n};");
+        assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n
* @expose\n * @type {string}\n */\norg.apache.flex.B.prototype.baz1;\n\n\n/**\n * @expose\n
* @return {string}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n  function bar1()
{\n    return this.baz1;\n  };\n  return goog.bind(bar1, this)();\n};\n\n\n/**\n * @expose\n
* @return {string}\n */\norg.apache.flex.B.prototype.foo2 = function() {\n  function bar2(param1)
{\n    return param1 + this.baz1;\n  };\n  return goog.bind(bar2, this)('foo');\n};");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/eeaab7f1/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmiter.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmiter.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmiter.java
index 5b7abf4..8cf66a7 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmiter.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmiter.java
@@ -54,7 +54,7 @@ public class TestFlexJSEmiter extends TestGoogEmiter
                 + "return \"Don't \" + _privateVar + value; }";
         IFileNode node = compileAS(code);
         asBlockWalker.visitFile(node);
-        assertOut("/**\n * com.example.components.MyTextButton\n *\n * @fileoverview\n *\n
* @suppress {checkTypes}\n */\n\ngoog.provide('com.example.components.MyTextButton');\n\n\n\n/**\n
* @constructor\n * @extends {spark.components.Button}\n */\ncom.example.components.MyTextButton
= function() {\n  com.example.components.MyTextButton.base(this, 'constructor');\n  if (foo()
!= 42) {\n    bar();\n  }\n};\ngoog.inherits(com.example.components.MyTextButton, spark.components.Button);\n\n\n/**\n
* @private\n * @type {string}\n */\ncom.example.components.MyTextButton.prototype._privateVar
= \"do \";\n\n\n/**\n * @type {number}\n */\ncom.example.components.MyTextButton.prototype.publicProperty
= 100;\n\n\n/**\n * @expose\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyTextButton.prototype.myFunction
= function(value) {\n  return \"Don't \" + this._privateVar + value;\n};\n\n\n/**\n * Metadata\n
*\n * @type {Object.<string, Array.<Object>>}\n */\ncom.example
 .components.MyTextButton.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'MyTextButton',
qName: 'com.example.components.MyTextButton'}] };\n");
+        assertOut("/**\n * com.example.components.MyTextButton\n *\n * @fileoverview\n *\n
* @suppress {checkTypes}\n */\n\ngoog.provide('com.example.components.MyTextButton');\n\n\n\n/**\n
* @constructor\n * @extends {spark.components.Button}\n */\ncom.example.components.MyTextButton
= function() {\n  com.example.components.MyTextButton.base(this, 'constructor');\n  if (foo()
!= 42) {\n    bar();\n  }\n};\ngoog.inherits(com.example.components.MyTextButton, spark.components.Button);\n\n\n/**\n
* @private\n * @type {string}\n */\ncom.example.components.MyTextButton.prototype._privateVar
= \"do \";\n\n\n/**\n * @expose\n * @type {number}\n */\ncom.example.components.MyTextButton.prototype.publicProperty
= 100;\n\n\n/**\n * @expose\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyTextButton.prototype.myFunction
= function(value) {\n  return \"Don't \" + this._privateVar + value;\n};\n\n\n/**\n * Metadata\n
*\n * @type {Object.<string, Array.<Object>>}\n */\
 ncom.example.components.MyTextButton.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'MyTextButton',
qName: 'com.example.components.MyTextButton'}] };\n");
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/eeaab7f1/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFieldMembers.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFieldMembers.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFieldMembers.java
index 3785357..ca79089 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFieldMembers.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFieldMembers.java
@@ -22,6 +22,8 @@ package org.apache.flex.compiler.internal.codegen.js.flexjs;
 import org.apache.flex.compiler.driver.IBackend;
 import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogFieldMembers;
 import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Test;
 
 /**
  * @author Erik de Bruin
@@ -35,4 +37,184 @@ public class TestFlexJSFieldMembers extends TestGoogFieldMembers
         return new FlexJSBackend();
     }
 
+    @Override
+    @Test
+    public void testField()
+    {
+        IVariableNode node = getField("var foo;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @type {*}\n */\nFalconTest_A.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testField_withType()
+    {
+        IVariableNode node = getField("var foo:int;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testField_withTypeValue()
+    {
+        IVariableNode node = getField("var foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.foo =
420");
+    }
+
+    @Test
+    public void testField_withTypeValue_Negative()
+    {
+        IVariableNode node = getField("var foo:int = -420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.foo =
-420");
+    }
+
+    @Override
+    @Test
+    public void testField_withNamespaceTypeValue()
+    {
+        IVariableNode node = getField("private var foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @private\n * @type {number}\n */\nFalconTest_A.prototype.foo =
420");
+    }
+
+    @Override
+    @Test
+    public void testField_withCustomNamespaceTypeValue()
+    {
+        IVariableNode node = getField("mx_internal var foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        // (erikdebruin) we ignore custom namespaces completely (are there side effects I'm
missing?)
+        assertOut("/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.foo =
420");
+    }
+
+    @Override
+    @Test
+    public void testField_withNamespaceTypeCollection()
+    {
+        IVariableNode node = getField("protected var foo:Vector.<Foo>;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @protected\n * @type {Vector.<Foo>}\n */\nFalconTest_A.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testField_withNamespaceTypeCollectionComplex()
+    {
+        IVariableNode node = getField("protected var foo:Vector.<Vector.<Vector.<Foo>>>;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @protected\n * @type {Vector.<Vector.<Vector.<Foo>>>}\n
*/\nFalconTest_A.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testField_withNamespaceTypeValueComplex()
+    {
+        IVariableNode node = getField("protected var foo:Foo = new Foo('bar', 42);");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @protected\n * @type {Foo}\n */\nFalconTest_A.prototype.foo =
new Foo('bar', 42)");
+    }
+
+    @Override
+    @Test
+    public void testField_withList()
+    {
+        IVariableNode node = getField("protected var a:int = 4, b:int = 11, c:int = 42;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @protected\n * @type {number}\n */\nFalconTest_A.prototype.a =
4;\n\n/**\n * @protected\n * @type {number}\n */\nFalconTest_A.prototype.b = 11;\n\n/**\n
* @protected\n * @type {number}\n */\nFalconTest_A.prototype.c = 42");
+    }
+
+    //--------------------------------------------------------------------------
+    // Constants
+    //--------------------------------------------------------------------------
+
+    @Override
+    @Test
+    public void testConstant()
+    {
+        IVariableNode node = getField("static const foo;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @const\n * @type {*}\n */\nFalconTest_A.foo");
+    }
+
+    @Test
+    public void testConstant_nonStatic()
+    {
+        IVariableNode node = getField("const foo;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @const\n * @type {*}\n */\nFalconTest_A.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testConstant_withType()
+    {
+        IVariableNode node = getField("static const foo:int;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @const\n * @type {number}\n */\nFalconTest_A.foo");
+    }
+
+    @Test
+    public void testConstant_withType_nonStatic()
+    {
+        IVariableNode node = getField("const foo:int;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @const\n * @type {number}\n */\nFalconTest_A.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testConstant_withTypeValue()
+    {
+        IVariableNode node = getField("static const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @const\n * @type {number}\n */\nFalconTest_A.foo =
420");
+    }
+
+    @Test
+    public void testConstant_withTypeValue_nonStatic()
+    {
+        IVariableNode node = getField("const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @const\n * @type {number}\n */\nFalconTest_A.prototype.foo
= 420");
+    }
+
+    @Override
+    @Test
+    public void testConstant_withNamespaceTypeValue()
+    {
+        IVariableNode node = getField("private static const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @private\n * @const\n * @type {number}\n */\nFalconTest_A.foo
= 420");
+    }
+
+    @Test
+    public void testConstant_withNamespaceTypeValue_nonStatic()
+    {
+        IVariableNode node = getField("private const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @private\n * @const\n * @type {number}\n */\nFalconTest_A.prototype.foo
= 420");
+    }
+
+    @Override
+    @Test
+    public void testConstant_withCustomNamespaceTypeValue()
+    {
+        IVariableNode node = getField("mx_internal static const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        // (erikdebruin) we ignore custom namespaces completely (are there side effects I'm
missing?)
+        assertOut("/**\n * @expose\n * @const\n * @type {number}\n */\nFalconTest_A.foo =
420");
+    }
+
+    @Test
+    public void testConstant_withCustomNamespaceTypeValue_nonStatic()
+    {
+        IVariableNode node = getField("mx_internal const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        // (erikdebruin) we ignore custom namespaces completely (are there side effects I'm
missing?)
+        assertOut("/**\n * @expose\n * @const\n * @type {number}\n */\nFalconTest_A.prototype.foo
= 420");
+    }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/eeaab7f1/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalConstants.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalConstants.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalConstants.java
index 24e67e5..e8971e2 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalConstants.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalConstants.java
@@ -22,6 +22,8 @@ package org.apache.flex.compiler.internal.codegen.js.flexjs;
 import org.apache.flex.compiler.driver.IBackend;
 import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogGlobalConstants;
 import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Test;
 
 /**
  * @author Erik de Bruin
@@ -35,4 +37,39 @@ public class TestFlexJSGlobalConstants extends TestGoogGlobalConstants
         return new FlexJSBackend();
     }
 
+    @Override
+    @Test
+    public void testInfinity()
+    {
+        IVariableNode node = getField("var a:Number = Infinity;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.a = Infinity");
+    }
+
+    @Override
+    @Test
+    public void testNegativeInfinity()
+    {
+        IVariableNode node = getField("var a:Number = -Infinity;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.a = -Infinity");
+    }
+
+    @Override
+    @Test
+    public void testNaN()
+    {
+        IVariableNode node = getField("var a:Number = NaN;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @type {number}\n */\nFalconTest_A.prototype.a = NaN");
+    }
+
+    @Override
+    @Test
+    public void testUndefined()
+    {
+        IVariableNode node = getField("var a:* = undefined;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @expose\n * @type {*}\n */\nFalconTest_A.prototype.a = undefined");
+    }
 }


Mime
View raw message