You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2017/11/30 23:24:41 UTC

[royale-compiler] 05/05: get tests to pass if Flash is available

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

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

commit b9abcfc8ee3205dcefc632c21a6c3f9780ca8f61
Author: Alex Harui <ah...@apache.org>
AuthorDate: Thu Nov 30 15:24:13 2017 -0800

    get tests to pass if Flash is available
---
 .../royale/compiler/internal/test/ASTestBase.java  |   2 +-
 compiler/src/test/java/aa/AAMavenTestSWCs.java     |   4 +-
 compiler/src/test/java/as/ASFeatureTestsBase.java  |   1 +
 compiler/src/test/java/as/ASNamespaceTests.java    | 136 +++++++++++++++++----
 compiler/src/test/java/as/ASVariableTests.java     |  59 ++++++---
 5 files changed, 157 insertions(+), 45 deletions(-)

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 401c0bf..a0daae8 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
@@ -69,7 +69,7 @@ public class ASTestBase extends TestBase
     @Override
     protected void addLibraries(List<File> libraries)
     {
-        libraries.addAll(testAdapter.getLibraries(false));
+        //libraries.addAll(testAdapter.getLibraries(false));
 
         super.addLibraries(libraries);
     }
diff --git a/compiler/src/test/java/aa/AAMavenTestSWCs.java b/compiler/src/test/java/aa/AAMavenTestSWCs.java
index 7f57c72..5018e3d 100644
--- a/compiler/src/test/java/aa/AAMavenTestSWCs.java
+++ b/compiler/src/test/java/aa/AAMavenTestSWCs.java
@@ -85,7 +85,7 @@ public class AAMavenTestSWCs
     }
     
     @Test
-    public void AA_JS_EXTERNC()
+    public void AAMavenTestSWCs_AA_JS_EXTERNC()
     {
         // Write the MXML into a temp file.
         ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter();
@@ -108,7 +108,7 @@ public class AAMavenTestSWCs
     }
     
     @Test
-    public void AB_JS_SWC()
+    public void AAMavenTestSWCs_AB_JS_SWC()
     {
         // Write the MXML into a temp file.
         ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter();
diff --git a/compiler/src/test/java/as/ASFeatureTestsBase.java b/compiler/src/test/java/as/ASFeatureTestsBase.java
index 09061a6..5c6d260 100644
--- a/compiler/src/test/java/as/ASFeatureTestsBase.java
+++ b/compiler/src/test/java/as/ASFeatureTestsBase.java
@@ -48,6 +48,7 @@ import static org.junit.Assert.fail;
  * Base class for AS feature tests which compile AS code with MXMLC and run it in the standalone Flash Player.
  * Copied and modified from MXMLFeatureTestsBase.java
  */
+@SuppressWarnings("deprecation")
 public class ASFeatureTestsBase
 {
 	private static boolean generateResultFile = false;
diff --git a/compiler/src/test/java/as/ASNamespaceTests.java b/compiler/src/test/java/as/ASNamespaceTests.java
index 44a79de..0c91d58 100644
--- a/compiler/src/test/java/as/ASNamespaceTests.java
+++ b/compiler/src/test/java/as/ASNamespaceTests.java
@@ -29,19 +29,45 @@ public class ASNamespaceTests extends ASFeatureTestsBase
     @Test
     public void ASNamespace_package()
     {
-        String[] imports = new String[]
+        String[] imports;
+        if (hasFlashPlayerGlobal)
         {
-            "import chrome.app",
-        };
-        String[] testCode = new String[]
+        	imports = new String[]
+	        {
+	            "import flash.net.NetConnection;",
+	        };
+        }
+        else
         {
-        	"var foo:app = new app();",
-        	"var bar:chrome.app = new chrome.app();",
-        	"var b1:Boolean = bar is app;",
-        	"var b2:Boolean = foo is chrome.app;",
-            "assertEqual('package qualifiers', b1, true);",
-            "assertEqual('package qualifiers', b2, true);",
-        };
+        	imports = new String[]
+ 	        {
+ 	            "import chrome.app;",
+ 	        };        	
+        }
+        String[] testCode;
+        if (hasFlashPlayerGlobal)
+        {
+            testCode = new String[]{
+                	"var foo:NetConnection = new NetConnection();",
+                	"var bar:flash.net.NetConnection = new flash.net.NetConnection();",
+                	"var b1:Boolean = bar is NetConnection;",
+                	"var b2:Boolean = foo is flash.net.NetConnection;",
+                    "assertEqual('package qualifiers', b1, true);",
+                    "assertEqual('package qualifiers', b2, true);",
+                };
+
+        }
+        else
+        {
+            testCode = new String[]{
+                	"var foo:app = new app();",
+                	"var bar:chrome.app = new chrome.app();",
+                	"var b1:Boolean = bar is app;",
+                	"var b2:Boolean = foo is chrome.app;",
+                    "assertEqual('package qualifiers', b1, true);",
+                    "assertEqual('package qualifiers', b2, true);",
+                };        	
+        }
         String source = getAS(imports, new String[0], testCode, new String[0]);
         compileAndRun(source);
     }
@@ -51,19 +77,53 @@ public class ASNamespaceTests extends ASFeatureTestsBase
     {
     	// all tests can assume that flash.display.Sprite
     	// flash.system.System and flash.events.Event have been imported
-        String[] imports = new String[]
+        String[] imports;
+        if (hasFlashPlayerGlobal)
         {
-            "import custom.custom_namespace;",
-        };
-        String[] declarations = new String[]
+        	imports = new String[]
+    	    {
+                "import flash.utils.flash_proxy",
+            };
+        }
+        else
         {
-	       	"custom_namespace var foo:Namespace = new Namespace('foo', 'bar');",
-        };
-        String[] testCode = new String[]
+        	imports = new String[]
+     	    {
+                "import custom.custom_namespace",
+            };
+        }
+        String[] declarations;
+        if (hasFlashPlayerGlobal)
         {
-        	"var qname:QName = new QName(custom_namespace, 'foo');",
-            "assertEqual('qualified names', custom_namespace::foo, this[qname]);",
-        };
+        	declarations = new String[]
+        	{
+        	    "flash_proxy var foo:Namespace = new Namespace('foo', 'bar');",
+            };
+        }
+        else
+        {
+        	declarations = new String[]
+        	{
+        	    "custom_namespace var foo:Namespace = new Namespace('foo', 'bar');",
+            };
+        }
+        String[] testCode;
+        if (hasFlashPlayerGlobal)
+        {
+        	testCode = new String[]
+        	{
+                "var qname:QName = new QName(flash_proxy, 'foo');",
+                "assertEqual('qualified names', flash_proxy::foo, this[qname]);",
+            };
+        }
+        else
+        {
+        	testCode = new String[]
+          	{
+                "var qname:QName = new QName(custom_namespace, 'foo');",
+                "assertEqual('qualified names', custom_namespace::foo, this[qname]);",
+            };        	
+        }
         String source = getAS(imports, declarations, testCode, new String[0]);
         compileAndRun(source);
     }
@@ -73,14 +133,36 @@ public class ASNamespaceTests extends ASFeatureTestsBase
     {
     	// all tests can assume that flash.display.Sprite
     	// flash.system.System and flash.events.Event have been imported
-        String[] imports = new String[]
+        String[] imports;
+        if (hasFlashPlayerGlobal)
         {
-            "import custom.custom_namespace;",
-        };
-        String[] declarations = new String[]
+        	imports = new String[]
+    	    {
+                "import flash.utils.flash_proxy;",
+            };
+        }
+        else
         {
-	       	"custom_namespace var foo:Namespace = new Namespace('foo', 'bar');",
-        };
+        	imports = new String[]
+     	    {
+                "import custom.custom_namespace;",
+            };
+        }
+        String[] declarations;
+        if (hasFlashPlayerGlobal)
+        {
+        	declarations = new String[]
+        	{
+        	    "flash_proxy var foo:Namespace = new Namespace('foo', 'bar');",
+            };
+        }
+        else
+        {
+        	declarations = new String[]
+        	{
+        	    "custom_namespace var foo:Namespace = new Namespace('foo', 'bar');",
+            };
+        }
         String[] testCode = new String[]
         {
         	"var ns:Namespace = new Namespace('baz', 'bar');",
diff --git a/compiler/src/test/java/as/ASVariableTests.java b/compiler/src/test/java/as/ASVariableTests.java
index 3bba7e1..f89d917 100644
--- a/compiler/src/test/java/as/ASVariableTests.java
+++ b/compiler/src/test/java/as/ASVariableTests.java
@@ -227,21 +227,50 @@ public class ASVariableTests extends ASFeatureTestsBase
     @Test
     public void ASVariableTests_setterBothCustomNamespace()
     {
-        String[] imports = new String[]
-        {
-        	"import custom.custom_namespace;",
-        	"use namespace custom_namespace;"
-        };
-        String[] declarations = new String[]
-        {
-            "private var _hello:String;",
-            "custom_namespace function get hello():String {",
-            "  return _hello; }",
-            "custom_namespace function set hello(value:String):void {",
-            "  _hello = value; }",
-            "public function test():void {",
-            "  this.hello = 'bye'; }",
-        };
+        String[] imports;
+        if (hasFlashPlayerGlobal)
+        {
+        	imports = new String[]
+        	{
+                "import flash.utils.flash_proxy;",
+                "use namespace flash_proxy;"
+            };
+        }
+        else
+        {
+        	imports = new String[]
+         	{
+                "import custom.custom_namespace;",
+                "use namespace custom_namespace;"
+            };        	
+        }
+        String[] declarations;
+        if (hasFlashPlayerGlobal)
+        {
+        	declarations = new String[]
+        	{
+                "private var _hello:String;",
+                "flash_proxy function get hello():String {",
+                "  return _hello; }",
+                "flash_proxy function set hello(value:String):void {",
+                "  _hello = value; }",
+                "public function test():void {",
+                "  this.hello = 'bye'; }",
+            };        	                          
+        }
+        else
+        {
+        	declarations = new String[]
+        	{
+                "private var _hello:String;",
+                "custom_namespace function get hello():String {",
+                "  return _hello; }",
+                "custom_namespace function set hello(value:String):void {",
+                "  _hello = value; }",
+                "public function test():void {",
+                "  this.hello = 'bye'; }",
+            };        	
+        }
         String[] testCode = new String[]
         {
             "test();",

-- 
To stop receiving notification emails like this one, please contact
"commits@royale.apache.org" <co...@royale.apache.org>.