You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2019/02/04 22:47:32 UTC

[royale-compiler] branch develop updated (7708d9e -> fc7be4c)

This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git.


    from 7708d9e  compiler-jx: simple numeric literals assigned to int or uint values are now coerced at compile time (references #74)
     new e8ff918  ASTestBase: added getLocalFunction() helper
     new fc7be4c  compiler-jx: added some missing tests for local named functions

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../internal/codegen/as/TestExpressions.java       | 17 ++++++++++++
 .../codegen/js/goog/TestGoogExpressions.java       |  9 ++++++
 .../codegen/js/royale/TestRoyaleExpressions.java   | 32 ++++++++++++++++++++++
 .../royale/compiler/internal/test/ASTestBase.java  |  6 ++++
 4 files changed, 64 insertions(+)


[royale-compiler] 01/02: ASTestBase: added getLocalFunction() helper

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit e8ff9180548fcea7767fffd08b44723e022e49b9
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Feb 4 14:24:11 2019 -0800

    ASTestBase: added getLocalFunction() helper
---
 .../java/org/apache/royale/compiler/internal/test/ASTestBase.java   | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/test/ASTestBase.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/test/ASTestBase.java
index f20bc09..88ea788 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/test/ASTestBase.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/test/ASTestBase.java
@@ -193,4 +193,10 @@ public class ASTestBase extends TestBase
         return (IVariableNode) getNode(code, IVariableNode.class);
     }
 
+    protected IASNode getLocalFunction(String code)
+    {
+        IFunctionNode method = (IFunctionNode) getNode(code, IFunctionNode.class);
+        return (IFunctionNode) findFirstDescendantOfType(method, IFunctionNode.class);
+    }
+
 }


[royale-compiler] 02/02: compiler-jx: added some missing tests for local named functions

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit fc7be4cade11f7923b870885bf027097cf8922a1
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Feb 4 14:47:26 2019 -0800

    compiler-jx: added some missing tests for local named functions
---
 .../internal/codegen/as/TestExpressions.java       | 17 ++++++++++++
 .../codegen/js/goog/TestGoogExpressions.java       |  9 ++++++
 .../codegen/js/royale/TestRoyaleExpressions.java   | 32 ++++++++++++++++++++++
 3 files changed, 58 insertions(+)

diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/as/TestExpressions.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/as/TestExpressions.java
index 0333265..e516bb9 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/as/TestExpressions.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/as/TestExpressions.java
@@ -25,6 +25,7 @@ import org.apache.royale.compiler.internal.tree.as.ObjectLiteralNode;
 import org.apache.royale.compiler.tree.as.IBinaryOperatorNode;
 import org.apache.royale.compiler.tree.as.IDynamicAccessNode;
 import org.apache.royale.compiler.tree.as.IFunctionCallNode;
+import org.apache.royale.compiler.tree.as.IFunctionNode;
 import org.apache.royale.compiler.tree.as.IIterationFlowNode;
 import org.apache.royale.compiler.tree.as.IMemberAccessExpressionNode;
 import org.apache.royale.compiler.tree.as.INamespaceAccessExpressionNode;
@@ -518,6 +519,22 @@ public class TestExpressions extends ASTestBase
         asBlockWalker.visitFunctionCall(node);
         assertOut("addListener('foo', function(event:Object):void {\n\tdoit();\n})");
     }
+    
+    @Test
+    public void testVisitLocalNamedFunction()
+    {
+        IFunctionNode node = (IFunctionNode) getLocalFunction("function a() {};");
+        asBlockWalker.visitFunction(node);
+        assertOut("function a() {\n}");
+    }
+    
+    @Test
+    public void testVisitLocalNamedFunctionWithParamsReturn()
+    {
+        IFunctionNode node = (IFunctionNode) getLocalFunction("function a(foo:int, bar:String = 'goo'):int{return -1;};");
+        asBlockWalker.visitFunction(node);
+        assertOut("function a(foo:int, bar:String = 'goo'):int {\n\treturn -1;\n}");
+    }
 
     @Test
     public void testVisitDynamicAccessNode_1()
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogExpressions.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogExpressions.java
index d7c2072..a377574 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogExpressions.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogExpressions.java
@@ -150,6 +150,15 @@ public class TestGoogExpressions extends TestExpressions
         asBlockWalker.visitFunctionCall(node);
         assertOut("addListener('foo', function(event) {\n\tdoit();\n})");
     }
+    
+    @Override
+    @Test
+    public void testVisitLocalNamedFunctionWithParamsReturn()
+    {
+        IFunctionNode node = (IFunctionNode) getLocalFunction("function a(foo:int, bar:String = 'goo'):int{return -1;};");
+        asBlockWalker.visitFunction(node);
+        assertOut("function a(foo, bar) {\n\tbar = typeof bar !== 'undefined' ? bar : 'goo';\n\treturn -1;\n}");
+    }
 
     @Override
     @Test
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
index c575b74..6e44fe1 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
@@ -1245,6 +1245,38 @@ public class TestRoyaleExpressions extends TestGoogExpressions
       		  "  });\n" +
       		  "}");
     }
+    
+    @Override
+    @Test
+    public void testVisitLocalNamedFunction()
+    {
+        IFunctionNode node = (IFunctionNode) getNode("function a() {};", IFunctionNode.class);
+        asBlockWalker.visitFunction(node);
+        System.err.println("**** " + removeGeneratedString(writer.toString()));
+        assertOut("RoyaleTest_A.prototype.royaleTest_a = function() {\n" +
+                  "  var self = this;\n" +
+                  "  function a() {\n" +
+                  "  };\n" +
+                  "  \n" +
+                  "}");
+    }
+    
+    @Override
+    @Test
+    public void testVisitLocalNamedFunctionWithParamsReturn()
+    {
+        IFunctionNode node = (IFunctionNode) getNode("function a(foo:int, bar:String = 'goo'):int{return -1;};", IFunctionNode.class);
+        asBlockWalker.visitFunction(node);
+        System.err.println("**** " + removeGeneratedString(writer.toString()));
+        assertOut("RoyaleTest_A.prototype.royaleTest_a = function() {\n" +
+                  "  var self = this;\n" +
+                  "  function a(foo, bar) {\n" +
+                  "    bar = typeof bar !== 'undefined' ? bar : 'goo';\n" +
+                  "    return -1;\n" +
+                  "  };\n" +
+                  "  \n" +
+                  "}");
+    }
 
     @Test
     public void testES5StrictAnonymousFunctions()