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 2023/11/27 21:57:18 UTC
(royale-compiler) 02/10: Migrate all goog tests to jsroyale
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 926668c95d8f413d348761c0323c0f8663520039
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Nov 13 14:19:47 2023 -0800
Migrate all goog tests to jsroyale
Only those that weren't already overridden. Then, remove all goog tests because it is an obsolete backend.
---
.../codegen/js/goog/TestGoogAccessorMembers.java | 171 ----------
.../internal/codegen/js/goog/TestGoogClass.java | 260 ---------------
.../internal/codegen/js/goog/TestGoogEmitter.java | 154 ---------
.../codegen/js/goog/TestGoogExpressions.java | 213 -------------
.../codegen/js/goog/TestGoogFieldMembers.java | 261 ----------------
.../internal/codegen/js/goog/TestGoogFile.java | 93 ------
.../codegen/js/goog/TestGoogGlobalClasses.java | 309 ------------------
.../codegen/js/goog/TestGoogGlobalConstants.java | 74 -----
.../codegen/js/goog/TestGoogGlobalFunctions.java | 241 --------------
.../codegen/js/goog/TestGoogInterface.java | 113 -------
.../codegen/js/goog/TestGoogMethodMembers.java | 183 -----------
.../internal/codegen/js/goog/TestGoogPackage.java | 112 -------
.../internal/codegen/js/goog/TestGoogProject.java | 136 --------
.../codegen/js/goog/TestGoogStatements.java | 347 ---------------------
.../js/royale/TestRoyaleAccessorMembers.java | 6 +-
.../codegen/js/royale/TestRoyaleClass.java | 18 +-
.../codegen/js/royale/TestRoyaleEmitter.java | 22 +-
.../codegen/js/royale/TestRoyaleExpressions.java | 30 +-
.../codegen/js/royale/TestRoyaleFieldMembers.java | 33 +-
.../internal/codegen/js/royale/TestRoyaleFile.java | 50 +++
.../codegen/js/royale/TestRoyaleGlobalClasses.java | 184 ++++++++++-
.../js/royale/TestRoyaleGlobalConstants.java | 4 +-
.../js/royale/TestRoyaleGlobalFunctions.java | 113 ++++++-
.../codegen/js/royale/TestRoyaleInterface.java | 4 +-
.../codegen/js/royale/TestRoyaleMethodMembers.java | 15 +-
.../codegen/js/royale/TestRoyalePackage.java | 31 +-
.../codegen/js/royale/TestRoyaleProject.java | 83 ++++-
.../codegen/js/royale/TestRoyaleStatements.java | 59 +++-
.../resources/amd/simple-project/src/HelloWorld.as | 55 ----
.../resources/amd/simple-project/src/com/acme/A.as | 57 ----
.../resources/amd/simple-project/src/com/acme/B.as | 47 ---
.../resources/amd/simple-project/src/com/acme/I.as | 26 --
.../amd/simple-project/src/com/acme/sub/IOther.as | 25 --
.../amd/simple-project/src/com/acme/sub/ISub.as | 28 --
.../goog/projects/imports/comps/A_result.js | 22 --
.../resources/{goog => royale}/files/call-super.as | 0
.../{goog => royale}/files/call-super_result.js | 0
.../resources/{goog => royale}/files/get-set.as | 0
.../{goog => royale}/files/get-set_result.js | 0
.../test/resources/{goog => royale}/files/input.as | 0
.../resources/{goog => royale}/files/output.js | 0
.../test/resources/{goog => royale}/files/poc.as | 0
.../resources/{goog => royale}/files/poc_result.js | 0
.../{goog => royale}/files/qualify-new-object.as | 0
.../files/qualify-new-object_result.js | 0
.../{goog => royale}/projects/imports/Case.as | 0
.../projects/imports/Case_result.js | 43 ++-
.../{goog => royale}/projects/imports/comps/A.as | 0
.../royale/projects/imports/comps/A_result.js | 63 ++++
.../{goog => royale}/projects/imports/comps/B.as | 0
.../projects/imports/comps/B_result.js | 40 +++
51 files changed, 746 insertions(+), 2979 deletions(-)
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogAccessorMembers.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogAccessorMembers.java
deleted file mode 100644
index 00b1fb135..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogAccessorMembers.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.as.TestAccessorMembers;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.tree.as.IGetterNode;
-import org.apache.royale.compiler.tree.as.ISetterNode;
-import org.junit.Test;
-
-/**
- * This class tests the production of valid 'goog' JS code for Class Accessor
- * members.
- *
- * @author Michael Schmalle
- * @author Erik de Bruin
- */
-public class TestGoogAccessorMembers extends TestAccessorMembers
-{
- @Override
- @Test
- public void testGetAccessor()
- {
- IGetterNode node = (IGetterNode) getAccessor("function get foo():int{}");
- asBlockWalker.visitGetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype, \n\t'foo', "
- + "\n\t{get:function() {\n\t}, configurable:true}\n)");
- }
-
- @Test
- public void testGetAccessor_withBody()
- {
- IGetterNode node = (IGetterNode) getAccessor("function get foo():int{return -1;}");
- asBlockWalker.visitGetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype, \n\t'foo', "
- + "\n\t{get:function() {\n\t\tvar self = this;\n\t\treturn -1;\n\t}, configurable:true}\n)");
- }
-
- @Override
- @Test
- public void testGetAccessor_withNamespace()
- {
- IGetterNode node = (IGetterNode) getAccessor("public function get foo():int{return -1;}");
- asBlockWalker.visitGetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype, \n\t'foo', "
- + "\n\t{get:function() {\n\t\tvar self = this;\n\t\treturn -1;\n\t}, configurable:true}\n)");
- }
-
- @Override
- @Test
- public void testGetAccessor_withNamespaceOverride()
- {
- // TODO (erikdebruin) need to figure out how to handle calls to
- // 'super' since the JS getter is actually an
- // anonymous function... goog.bind or goog.partial?
- IGetterNode node = (IGetterNode) getAccessor("public override function get foo():int{super.foo(); return -1;}");
- asBlockWalker.visitGetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype, \n\t'foo', \n\t{get:function() {\n\t\tvar self = this;\n\t\tRoyaleTest_A.base(this, 'foo');\n\t\treturn -1;\n\t}, configurable:true}\n)");
- }
-
- @Override
- @Test
- public void testGetAccessor_withStatic()
- {
- IGetterNode node = (IGetterNode) getAccessor("public static function get foo():int{return -1;}");
- asBlockWalker.visitGetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A, \n\t'foo', \n\t{get:function() {\n\t\treturn -1;\n\t}, configurable:true}\n)");
- }
-
- @Override
- @Test
- public void testGetAccessor_withoutReturnType()
- {
- IGetterNode node = (IGetterNode) getAccessor("function get foo(){}");
- asBlockWalker.visitGetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype, \n\t'foo', "
- + "\n\t{get:function() {\n\t}, configurable:true}\n)");
- }
-
- @Override
- @Test
- public void testGetAccessor_withNamespace_withoutReturnType()
- {
- IGetterNode node = (IGetterNode) getAccessor("public function get foo(){}");
- asBlockWalker.visitGetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype, \n\t'foo', "
- + "\n\t{get:function() {\n\t}, configurable:true}\n)");
- }
-
- @Override
- @Test
- public void testSetAccessor()
- {
- ISetterNode node = (ISetterNode) getAccessor("function set foo(value:int):void{}");
- asBlockWalker.visitSetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype, \n\t'foo', \n\t{set:function(value)"
- + " {\n\t}, configurable:true}\n)");
- }
-
- @Test
- public void testSetAccessor_withBody()
- {
- ISetterNode node = (ISetterNode) getAccessor("function set foo(value:int):void{'haai';}");
- asBlockWalker.visitSetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype, \n\t'foo', "
- + "\n\t{set:function(value) {\n\t\tvar self = this;\n\t\t'haai';\n\t}, configurable:true}\n)");
- }
-
- @Override
- @Test
- public void testSetAccessor_withNamespace()
- {
- ISetterNode node = (ISetterNode) getAccessor("public function set foo(value:int):void{}");
- asBlockWalker.visitSetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype, \n\t'foo', \n\t{set:function(value)"
- + " {\n\t}, configurable:true}\n)");
- }
-
- @Override
- @Test
- public void testSetAccessor_withNamespaceOverride()
- {
- // TODO (erikdebruin) see: testGetAccessor_withNamespaceOverride
- ISetterNode node = (ISetterNode) getAccessor("public override function set foo(value:int):void{super.foo();}");
- asBlockWalker.visitSetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype, \n\t'foo', \n\t{set:function(value) {\n\t\tvar self = this;\n\t\tRoyaleTest_A.base(this, 'foo');\n\t}, configurable:true}\n)");
- }
-
- @Override
- @Test
- public void testSetAccessor_withStatic()
- {
- ISetterNode node = (ISetterNode) getAccessor("public static function set foo(value:int):void{}");
- asBlockWalker.visitSetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A, \n\t'foo', \n\t{set:function(value) {\n\t}, configurable:true}\n)");
- }
-
- @Override
- @Test
- public void testSetAccessor_withoutParameterType()
- {
- ISetterNode node = (ISetterNode) getAccessor("function set foo(value):void{}");
- asBlockWalker.visitSetter(node);
- assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype, \n\t'foo', \n\t{set:function(value)"
- + " {\n\t}, configurable:true}\n)");
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogClass.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogClass.java
deleted file mode 100644
index 961d4fe86..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogClass.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.as.TestClass;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.tree.as.IClassNode;
-import org.apache.royale.compiler.tree.as.IFileNode;
-import org.junit.Test;
-
-/**
- * This class tests the production of 'goog' JS code for Classes.
- *
- * @author Michael Schmalle
- * @author Erik de Bruin
- */
-public class TestGoogClass extends TestClass
-{
- @Override
- @Test
- public void testSimple()
- {
- IClassNode node = getClassNode("public class A{}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};");
- }
-
- @Override
- @Test
- public void testSimpleInternal()
- {
- // (erikdebruin) the AS compiler will enforce 'internal' namespace,
- // in JS we ignore it
- IClassNode node = getClassNode("internal class A{}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};");
- }
-
- @Override
- @Test
- public void testSimpleFinal()
- {
- // (erikdebruin) the AS compiler will enforce the 'final' keyword,
- // in JS we ignore it
- IClassNode node = getClassNode("public final class A{}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};");
- }
-
- @Override
- @Test
- public void testSimpleDynamic()
- {
- // (erikdebruin) all JS objects are 'dynamic' by design
- IClassNode node = getClassNode("public dynamic class A{}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};");
- }
-
- @Override
- @Test
- public void testSimpleExtends()
- {
- IClassNode node = getClassNode("public class A extends TestImplementation {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {custom.TestImplementation}\n */\norg.apache.royale.A = function() {\n\torg.apache.royale.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.royale.A, custom.TestImplementation);");
- }
-
- @Override
- @Test
- public void testSimpleImplements()
- {
- IClassNode node = getClassNode("public class A implements TestInterface {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @implements {custom.TestInterface}\n */\norg.apache.royale.A = function() {\n};");
- }
-
- @Override
- @Test
- public void testSimpleImplementsMultiple()
- {
- IClassNode node = getClassNode("public class A implements TestInterface, TestOtherInterface {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @implements {custom.TestInterface}\n * @implements {custom.TestOtherInterface}\n */\norg.apache.royale.A = function() {\n};");
- }
-
- @Override
- @Test
- public void testSimpleExtendsImplements()
- {
- IClassNode node = getClassNode("public class A extends TestImplementation implements TestInterface {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {custom.TestImplementation}\n * @implements {custom.TestInterface}\n */\norg.apache.royale.A = function() {\n\torg.apache.royale.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.royale.A, custom.TestImplementation);");
- }
-
- @Override
- @Test
- public void testSimpleExtendsImplementsMultiple()
- {
- IClassNode node = getClassNode("public class A extends TestImplementation implements TestInterface, TestOtherInterface {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {custom.TestImplementation}\n * @implements {custom.TestInterface}\n * @implements {custom.TestOtherInterface}\n */\norg.apache.royale.A = function() {\n\torg.apache.royale.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.royale.A, custom.TestImplementation);");
- }
-
- @Override
- @Test
- public void testSimpleFinalExtendsImplementsMultiple()
- {
- IClassNode node = getClassNode("public final class A extends TestImplementation implements TestInterface, TestOtherInterface {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {custom.TestImplementation}\n * @implements {custom.TestInterface}\n * @implements {custom.TestOtherInterface}\n */\norg.apache.royale.A = function() {\n\torg.apache.royale.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.royale.A, custom.TestImplementation);");
- }
-
- @Override
- @Test
- public void testQualifiedExtendsImplementsMultiple()
- {
- IClassNode node = getClassNode("public class A extends custom.TestImplementation implements custom.TestInterface, custom.TestOtherInterface {public function A() {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {custom.TestImplementation}\n * @implements {custom.TestInterface}\n * @implements {custom.TestOtherInterface}\n */\norg.apache.royale.A = function() {\n\torg.apache.royale.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.royale.A, custom.TestImplementation);");
- }
-
- @Override
- @Test
- public void testConstructor()
- {
- IClassNode node = getClassNode("public class A {public function A() { }}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};");
- }
-
- @Test
- public void testConstructor_super()
- {
- IClassNode node = getClassNode("public class A {public function A() { super(); }}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n\tvar self = this;\n\t;\n};");
- }
-
- @Test
- public void testExtendsConstructor_super()
- {
- IClassNode node = getClassNode("public class A extends custom.TestImplementation { public function A() { super('foo', 42);}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {custom.TestImplementation}\n */\norg.apache.royale.A = function() {\n\tvar self = this;\n\torg.apache.royale.A.base(this, 'constructor', 'foo', 42);\n};\ngoog.inherits(org.apache.royale.A, custom.TestImplementation);");
- }
-
- @Override
- @Test
- public void testConstructor_withArguments()
- {
- IClassNode node = getClassNode("public class A {public function A(arg1:String, arg2:int) {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.royale.A = function(arg1, arg2) {\n};");
- }
-
- @Override
- @Test
- public void testExtendsConstructor_withArguments()
- {
- IClassNode node = getClassNode("public class A extends custom.TestImplementation {public function A(arg1:String, arg2:int) {}}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {custom.TestImplementation}\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.royale.A = function(arg1, arg2) {\n\torg.apache.royale.A.base(this, 'constructor', arg1, arg2);\n};\ngoog.inherits(org.apache.royale.A, custom.TestImplementation);");
- }
-
- @Override
- @Test
- public void testFields()
- {
- 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.royale.A = function() {\n};\n\n/**\n * @type {Object}\n */\norg.apache.royale.A.prototype.a;\n\n/**\n * @protected\n * @type {string}\n */\norg.apache.royale.A.prototype.b;\n\n/**\n * @private\n * @type {number}\n */\norg.apache.royale.A.prototype.c;\n\n/**\n * @package\n * @type {number}\n */\norg.apache.royale.A.prototype.d;\n\n/**\n * @package\n * @type {number}\n */\norg.apache.royale.A.prototype.e;");
- }
-
- @Override
- @Test
- public void testConstants()
- {
- IClassNode node = getClassNode("public class A {"
- + "public static const A:int = 42;"
- + "protected static const B:Number = 42;"
- + "private static const C:Number = 42;"
- + "foo_bar static const C:String = 'me' + 'you';}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n/**\n * @const\n * @type {number}\n */\norg.apache.royale.A.A = 42;\n\n/**\n * @protected\n * @const\n * @type {number}\n */\norg.apache.royale.A.B = 42;\n\n/**\n * @private\n * @const\n * @type {number}\n */\norg.apache.royale.A.C = 42;\n\n/**\n * @const\n * @type {string}\n */\norg.apache.royale.A.C = 'me' + 'you';");
- }
-
- @Override
- @Test
- public void testAccessors()
- {
- IClassNode node = getClassNode("public class A {"
- + "public function get foo1():Object{return null;}"
- + "public function set foo1(value:Object):void{}"
- + "protected function get foo2():Object{return null;}"
- + "protected function set foo2(value:Object):void{}"
- + "private function get foo3():Object{return null;}"
- + "private function set foo3(value:Object):void{}"
- + "internal function get foo5():Object{return null;}"
- + "internal function set foo5(value:Object):void{}"
- + "foo_bar function get foo6():Object{return null;}"
- + "foo_bar function set foo6(value:Object):void{}" + "}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n/**\n * @type {Object}\n */\norg.apache.royale.A.prototype.foo1;\n\nObject.defineProperty(\n\torg.apache.royale.A.prototype, \n\t'foo1', \n\t{get:function() {\n\t\tvar self = this;\n\t\treturn null;\n\t}, configurable:true}\n);\n\nObject.defineProperty(\n\torg.apache.royale.A.prototype, \n\t'foo1', \n\t{set:function(value) {\n\t}, configurable:true}\n);\n\n/**\n * @protected\n * @type {Object}\n */\no [...]
- }
-
- @Override
- @Test
- public void testMethods()
- {
- IClassNode node = getClassNode("public class A {"
- + "public function foo1():Object{return null;}"
- + "public final function foo1a():Object{return null;}"
- + "override public function foo1b():Object{return super.foo1b();}"
- + "protected function foo2(value:Object):void{}"
- + "private function foo3(value:Object):void{}"
- + "internal function foo5(value:Object):void{}"
- + "foo_bar function foo6(value:Object):void{}"
- + "public static function foo7(value:Object):void{}"
- + "foo_bar static function foo7(value:Object):void{}" + "}");
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n/**\n * @return {Object}\n */\norg.apache.royale.A.prototype.foo1 = function() {\n\tvar self = this;\n\treturn null;\n};\n\n/**\n * @return {Object}\n */\norg.apache.royale.A.prototype.foo1a = function() {\n\tvar self = this;\n\treturn null;\n};\n\n/**\n * @return {Object}\n * @override\n */\norg.apache.royale.A.prototype.foo1b = function() {\n\tvar self = this;\n\treturn org.apache.royale.A.base(this [...]
- }
-
- @Override
- protected IClassNode getClassNode(String code)
- {
- String source = "package org.apache.royale {import custom.TestInterface;import custom.TestImplementation;import custom.TestEvent;import custom.TestOtherInterface;"
- + code + "}";
- IFileNode node = compileAS(source);
- IClassNode child = (IClassNode) findFirstDescendantOfType(node,
- IClassNode.class);
- return child;
- }
-
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogEmitter.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogEmitter.java
deleted file mode 100644
index c40adb9e2..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogEmitter.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.internal.test.ASTestBase;
-import org.apache.royale.compiler.tree.as.IFileNode;
-import org.apache.royale.compiler.tree.as.IFunctionNode;
-import org.junit.Test;
-
-/**
- * This class tests the production of 'goog' JavaScript output.
- * <p>
- * Note; this is a complete prototype more used in figuring out where
- * abstraction and indirection is needed concerning the AS -> JS translations.
- *
- * @author Michael Schmalle
- */
-public class TestGoogEmitter extends ASTestBase
-{
-
- @Test
- public void testSimple()
- {
- String code = "package com.example.components {"
- + "import custom.TestImplementation;"
- + "public class MyEventTarget extends TestImplementation {"
- + "public function MyEventTarget() {if (foo() != 42) { bar(); } }"
- + "private var _privateVar:String = \"do \";"
- + "public var publicProperty:Number = 100;"
- + "public function myFunction(value: String): String{"
- + "return \"Don't \" + _privateVar + value; }}}";
- IFileNode node = compileAS(code);
- asBlockWalker.visitFile(node);
- assertOut("goog.provide('com.example.components.MyEventTarget');\n\ngoog.require('custom.TestImplementation');\n\n/**\n * @constructor\n * @extends {custom.TestImplementation}\n */\ncom.example.components.MyEventTarget = function() {\n\tvar self = this;\n\tcom.example.components.MyEventTarget.base(this, 'constructor');\n\tif (foo() != 42) {\n\t\tbar();\n\t}\n};\ngoog.inherits(com.example.components.MyEventTarget, custom.TestImplementation);\n\n/**\n * @private\n * @type {string}\ [...]
- }
-
- @Test
- public void testSimpleInterface()
- {
- String code = "package com.example.components {"
- + "public interface TestInterface { } }";
- IFileNode node = compileAS(code);
- asBlockWalker.visitFile(node);
- assertOut("goog.provide('com.example.components.TestInterface');\n\n/**\n * @interface\n */\ncom.example.components.TestInterface = function() {\n};");
- }
-
- @Test
- public void testSimpleClass()
- {
- String code = "package com.example.components {"
- + "public class TestClass { } }";
- IFileNode node = compileAS(code);
- asBlockWalker.visitFile(node);
- assertOut("goog.provide('com.example.components.TestClass');\n\n/**\n * @constructor\n */\ncom.example.components.TestClass = function() {\n};");
- }
-
- @Test
- public void testSimpleMethod()
- {
- IFunctionNode node = getMethod("function method1():void{\n}");
- asBlockWalker.visitFunction(node);
- assertOut("RoyaleTest_A.prototype.method1 = function() {\n}");
- }
-
- @Test
- public void testSimpleParameterReturnType()
- {
- IFunctionNode node = getMethodWithPackage("function method1(bar:int):int{\n}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {number} bar\n * @return {number}\n */\n"
- + "foo.bar.RoyaleTest_A.prototype.method1 = function(bar) {\n}");
- }
-
- @Test
- public void testSimpleMultipleParameter()
- {
- IFunctionNode node = getMethodWithPackage("function method1(bar:int, baz:String, goo:Array):void{\n}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {number} bar\n * @param {string} baz\n * @param {Array} goo\n */\n"
- + "foo.bar.RoyaleTest_A.prototype.method1 = function(bar, baz, goo) {\n}");
- }
-
- @Test
- public void testSimpleMultipleParameter_JSDoc()
- {
- IFunctionNode node = getMethodWithPackage("function method1(bar:int, baz:String, goo:Array):void{\n}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {number} bar\n * @param {string} baz\n * @param {Array} goo\n */\n"
- + "foo.bar.RoyaleTest_A.prototype.method1 = function(bar, baz, goo) {\n}");
- }
-
- @Test
- public void testDefaultParameter()
- {
- IFunctionNode node = getMethodWithPackage("function method1(p1:Number, p2:Number, p3:Number = 3, p4:Number = 4):Number{return p1 + p2 + p3 + p4;}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {number} p1\n * @param {number} p2\n * @param {number=} p3\n * @param {number=} p4\n * @return {number}\n */\n"
- + "foo.bar.RoyaleTest_A.prototype.method1 = function(p1, p2, p3, p4) {\n"
- + "\tvar self = this;\n"
- + "\tp3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
- + "\tp4 = typeof p4 !== 'undefined' ? p4 : 4;\n"
- + "\treturn p1 + p2 + p3 + p4;\n}");
- }
-
- @Test
- public void testDefaultParameter_Body()
- {
- IFunctionNode node = getMethodWithPackage("function method1(bar:int = 42, bax:int = 4):void{if (a) foo();}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {number=} bar\n * @param {number=} bax\n */\n"
- + "foo.bar.RoyaleTest_A.prototype.method1 = function(bar, bax) {\n"
- + "\tvar self = this;\n"
- + "\tbar = typeof bar !== 'undefined' ? bar : 42;\n"
- + "\tbax = typeof bax !== 'undefined' ? bax : 4;\n"
- + "\tif (a)\n\t\tfoo();\n}");
- }
-
- @Test
- public void testDefaultParameter_NoBody()
- {
- IFunctionNode node = getMethodWithPackage("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {number} p1\n * @param {number} p2\n * @param {number=} p3\n * @param {number=} p4\n * @return {number}\n */\n"
- + "foo.bar.RoyaleTest_A.prototype.method1 = function(p1, p2, p3, p4) {\n"
- + "\tp3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
- + "\tp4 = typeof p4 !== 'undefined' ? p4 : 4;\n}");
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-
-}
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
deleted file mode 100644
index a377574a8..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogExpressions.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.as.TestExpressions;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.tree.as.IBinaryOperatorNode;
-import org.apache.royale.compiler.tree.as.IFunctionCallNode;
-import org.apache.royale.compiler.tree.as.IFunctionNode;
-import org.apache.royale.compiler.tree.as.INamespaceAccessExpressionNode;
-import org.apache.royale.compiler.tree.as.IVariableNode;
-import org.junit.Test;
-
-/**
- * @author Michael Schmalle
- * @author Erik de Bruin
- */
-public class TestGoogExpressions extends TestExpressions
-{
- @Override
- @Test
- public void testVisitLanguageIdentifierNode_SuperMethod_1()
- {
- IFunctionNode node = getMethod("function foo(){if (a) super.foo();}");
- asBlockWalker.visitFunction(node);
- assertOut("RoyaleTest_A.prototype.foo = function() {\n\tvar self = this;\n\tif (a)\n\t\tRoyaleTest_A.base(this, 'foo');\n}");
- }
-
- @Override
- @Test
- public void testVisitLanguageIdentifierNode_SuperMethod_2()
- {
- IFunctionNode node = getMethod("function foo(){if (a) super.foo(a, b, c);}");
- asBlockWalker.visitFunction(node);
- assertOut("RoyaleTest_A.prototype.foo = function() {\n\tvar self = this;\n\tif (a)\n\t\tRoyaleTest_A.base(this, 'foo', a, b, c);\n}");
- }
-
- //----------------------------------
- // Primary expression keywords
- //----------------------------------
-
- //----------------------------------
- // Logical
- //----------------------------------
-
- @Override
- @Test
- public void testVisitBinaryOperatorNode_LogicalAndAssignment()
- {
- IBinaryOperatorNode node = getBinaryNode("a &&= b");
- asBlockWalker.visitBinaryOperator(node);
- assertOut("a = a && b");
- }
-
- @Test
- public void testVisitBinaryOperatorNode_LogicalAndAssignmentInClass()
- {
- IBinaryOperatorNode node = (IBinaryOperatorNode)getNode("public var foo:Boolean;private function test(target:RoyaleTest_A):void { target.foo &&= foo }", IBinaryOperatorNode.class, WRAP_LEVEL_CLASS);
- asBlockWalker.visitBinaryOperator(node);
- // the last foo should probably be this.foo
- assertOut("target.foo = target.foo && foo");
- }
-
- @Override
- @Test
- public void testVisitBinaryOperatorNode_LogicalOrAssignment()
- {
- IBinaryOperatorNode node = getBinaryNode("a ||= b");
- asBlockWalker.visitBinaryOperator(node);
- assertOut("a = a || b");
- }
-
- //----------------------------------
- // Other
- //----------------------------------
-
- @Test
- public void testParentheses_1()
- {
- IVariableNode node = (IVariableNode) getNode("var a = (a + b);",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {*} */ a = (a + b)");
- }
-
- @Test
- public void testParentheses_2()
- {
- IVariableNode node = (IVariableNode) getNode("var a = (a + b) - c;",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {*} */ a = (a + b) - c");
- }
-
- @Test
- public void testParentheses_3()
- {
- IVariableNode node = (IVariableNode) getNode(
- "var a = ((a + b) - (c + d)) * e;", IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {*} */ a = ((a + b) - (c + d)) * e");
- }
-
- @Override
- @Test
- public void testAnonymousFunction()
- {
- IVariableNode node = (IVariableNode) getNode("var a = function(){};",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {*} */ a = function() {\n}");
- }
-
- @Override
- @Test
- public void testAnonymousFunctionWithParamsReturn()
- {
- IVariableNode node = (IVariableNode) getNode(
- "var a:Object = function(foo:int, bar:String = 'goo'):int{return -1;};",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Object} */ a = function(foo, bar) {\n\tbar = typeof bar !== 'undefined' ? bar : 'goo';\n\treturn -1;\n}");
- }
-
- @Override
- @Test
- public void testAnonymousFunctionAsArgument()
- {
- IFunctionCallNode node = (IFunctionCallNode) getNode(
- "addListener('foo', function(event:Object):void{doit();})",
- IFunctionCallNode.class);
- 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
- public void testVisitAs()
- {
- IBinaryOperatorNode node = getBinaryNode("a as b");
- asBlockWalker.visitBinaryOperator(node);
- assertOut("(is(a, b) ? a : null)");
- }
-
- @Override
- @Test
- public void testVisitBinaryOperator_Instancof()
- {
- IBinaryOperatorNode node = getBinaryNode("a instanceof b");
- asBlockWalker.visitBinaryOperator(node);
- assertOut("a instanceof b");
- }
-
- @Override
- @Test
- public void testVisitBinaryOperator_Is()
- {
- IBinaryOperatorNode node = getBinaryNode("a is b");
- asBlockWalker.visitBinaryOperator(node);
- assertOut("is(a, b)");
- }
-
- @Override
- @Test
- public void testVisitBinaryOperator_NamespaceAccess_1()
- {
- INamespaceAccessExpressionNode node = getNamespaceAccessExpressionNode("a::b");
- asBlockWalker.visitNamespaceAccessExpression(node);
- assertOut("a.b");
- }
-
- @Override
- @Test
- public void testVisitBinaryOperator_NamespaceAccess_2()
- {
- INamespaceAccessExpressionNode node = getNamespaceAccessExpressionNode("a::b::c");
- asBlockWalker.visitNamespaceAccessExpression(node);
- assertOut("a.b.c");
- }
-
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogFieldMembers.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogFieldMembers.java
deleted file mode 100644
index e410ab398..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogFieldMembers.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.as.TestFieldMembers;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.tree.as.IVariableNode;
-import org.junit.Test;
-
-/**
- * This class tests the production of 'goog' JavaScript for Class Field members.
- *
- * @author Michael Schmalle
- * @author Erik de Bruin
- */
-public class TestGoogFieldMembers extends TestFieldMembers
-{
- //--------------------------------------------------------------------------
- // Fields
- //--------------------------------------------------------------------------
-
- @Override
- @Test
- public void testField()
- {
- IVariableNode node = getField("var foo;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @package\n * @type {*}\n */\nRoyaleTest_A.prototype.foo");
- }
-
- @Override
- @Test
- public void testField_withType()
- {
- IVariableNode node = getField("var foo:int;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @package\n * @type {number}\n */\nRoyaleTest_A.prototype.foo");
- }
-
- @Override
- @Test
- public void testField_withTypeValue()
- {
- IVariableNode node = getField("var foo:int = 420;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @package\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 420");
- }
-
- @Test
- public void testField_withTypeValue_Negative()
- {
- IVariableNode node = getField("var foo:int = -420;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @package\n * @type {number}\n */\nRoyaleTest_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 */\nRoyaleTest_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 * @type {number}\n */\nRoyaleTest_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 {Array.<Foo>}\n */\nRoyaleTest_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 {Array.<Array.<Array.<Foo>>>}\n */\nRoyaleTest_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 */\nRoyaleTest_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 */\nRoyaleTest_A.prototype.a = 4;\n\n/**\n * @protected\n * @type {number}\n */\nRoyaleTest_A.prototype.b = 11;\n\n/**\n * @protected\n * @type {number}\n */\nRoyaleTest_A.prototype.c = 42");
- }
-
- //--------------------------------------------------------------------------
- // Constants
- //--------------------------------------------------------------------------
-
- @Override
- @Test
- public void testConstant()
- {
- IVariableNode node = getField("static const foo;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @package\n * @const\n * @type {*}\n */\nRoyaleTest_A.foo");
- }
-
- @Test
- public void testConstant_nonStatic()
- {
- IVariableNode node = getField("const foo;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @package\n * @const\n * @type {*}\n */\nRoyaleTest_A.prototype.foo");
- }
-
- @Override
- @Test
- public void testConstant_withType()
- {
- IVariableNode node = getField("static const foo:int;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @package\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo");
- }
-
- @Test
- public void testConstant_withType_nonStatic()
- {
- IVariableNode node = getField("const foo:int;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @package\n * @const\n * @type {number}\n */\nRoyaleTest_A.prototype.foo");
- }
-
- @Override
- @Test
- public void testConstant_withTypeValue()
- {
- IVariableNode node = getField("static const foo:int = 420;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @package\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = 420");
- }
-
- @Test
- public void testConstant_withTypeValue_nonStatic()
- {
- IVariableNode node = getField("const foo:int = 420;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @package\n * @const\n * @type {number}\n */\nRoyaleTest_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 */\nRoyaleTest_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 */\nRoyaleTest_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 * @const\n * @type {number}\n */\nRoyaleTest_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 * @const\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 420");
- }
-
- //--------------------------------------------------------------------------
- // Namespace
- //--------------------------------------------------------------------------
-
- // TODO (erikdebruin) not sure what to do with these when emitting JS...
-
- @Override
- @Test
- public void testNamespace()
- {
-// INamespaceNode node = getNamespace("namespace ns = \"http://whatever\";");
-// asBlockWalker.visitNamespace(node);
-// assertOut("namespace ns = \"http://whatever\"");
- }
-
- @Override
- @Test
- public void testNamespace_public()
- {
-// INamespaceNode node = getNamespace("public namespace ns = \"http://whatever\";");
-// asBlockWalker.visitNamespace(node);
-// assertOut("public namespace ns = \"http://whatever\"");
- }
-
- @Override
- @Test
- public void testNamespace_protected()
- {
-// INamespaceNode node = getNamespace("protected namespace ns = \"http://whatever\";");
-// asBlockWalker.visitNamespace(node);
-// assertOut("protected namespace ns = \"http://whatever\"");
- }
-
- //--------------------------------------------------------------------------
-
- @Override
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogFile.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogFile.java
deleted file mode 100644
index 5cb6e5bbe..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogFile.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import java.io.File;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.internal.test.ASTestBase;
-import org.apache.royale.compiler.tree.as.IFileNode;
-import org.junit.Test;
-
-/**
- * This class tests the production of valid 'goog' JS code from an external
- * file.
- *
- * @author Erik de Bruin
- */
-public class TestGoogFile extends ASTestBase
-{
- @Test
- public void testFile_plain()
- {
- IFileNode node = compileAS("input", true, "goog" + File.separator
- + "files");
- asBlockWalker.visitFile(node);
- assertOut(getCodeFromFile("output", true, "goog" + File.separator
- + "files"));
- }
-
- @Test
- public void testFile_getset()
- {
- IFileNode node = compileAS("get-set", true, "goog" + File.separator
- + "files");
- asBlockWalker.visitFile(node);
- assertOut(getCodeFromFile("get-set_result", true, "goog"
- + File.separator + "files"));
- }
-
- @Test
- public void testFile_callsuper()
- {
- IFileNode node = compileAS("call-super", true, "goog" + File.separator
- + "files");
- asBlockWalker.visitFile(node);
- assertOut(getCodeFromFile("call-super_result", true, "goog"
- + File.separator + "files"));
- }
-
- @Test
- public void testFile_qualifynewobject()
- {
- IFileNode node = compileAS("qualify-new-object", true, "goog"
- + File.separator + "files");
- asBlockWalker.visitFile(node);
- assertOut(getCodeFromFile("qualify-new-object_result", true, "goog"
- + File.separator + "files"));
- }
-
- @Test
- public void testFile_poc()
- {
- IFileNode node = compileAS("poc", true, "goog" + File.separator
- + "files");
- asBlockWalker.visitFile(node);
- assertOut(getCodeFromFile("poc_result", true, "goog" + File.separator
- + "files"));
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogGlobalClasses.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogGlobalClasses.java
deleted file mode 100644
index 28aab2a6d..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogGlobalClasses.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.as.TestGlobalClasses;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.tree.as.IFunctionNode;
-import org.apache.royale.compiler.tree.as.IVariableNode;
-import org.junit.Test;
-
-/**
- * @author Erik de Bruin
- */
-public class TestGoogGlobalClasses extends TestGlobalClasses
-{
- @Override
- @Test
- public void testArgumentError()
- {
- IVariableNode node = getVariable("var a:ArgumentError = new ArgumentError();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {ArgumentError} */ a = new ArgumentError()");
- }
-
- @Override
- @Test
- public void testArguments()
- {
- IFunctionNode node = getMethod("function a():void {\ttrace(arguments);}");
- asBlockWalker.visitFunction(node);
- assertOut("RoyaleTest_A.prototype.a = function() {\n\tvar self = this;\n\ttrace(arguments);\n}");
- }
-
- @Override
- @Test
- public void testArray()
- {
- IVariableNode node = getVariable("var a:Array = new Array(1);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Array} */ a = new Array(1)");
- }
-
- @Override
- @Test
- public void testBoolean()
- {
- IVariableNode node = getVariable("var a:Boolean = new Boolean(1);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {boolean} */ a = new Boolean(1)");
- }
-
- @Override
- @Test
- public void testClass()
- {
- IVariableNode node = getVariable("var a:Class = new Class();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Object} */ a = new Class()");
- }
-
- @Override
- @Test
- public void testDate()
- {
- IVariableNode node = getVariable("var a:Date = new Date();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Date} */ a = new Date()");
- }
-
- @Override
- @Test
- public void testDefinitionError()
- {
- IVariableNode node = getVariable("var a:DefinitionError = new DefinitionError();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {DefinitionError} */ a = new DefinitionError()");
- }
-
- @Override
- @Test
- public void testError()
- {
- IVariableNode node = getVariable("var a:Error = new Error();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Error} */ a = new Error()");
- }
-
- @Override
- @Test
- public void testEvalError()
- {
- IVariableNode node = getVariable("var a:EvalError = new EvalError();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {EvalError} */ a = new EvalError()");
- }
-
- @Override
- @Test
- public void testFunction()
- {
- IVariableNode node = getVariable("var a:Function = new Function();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Function} */ a = new Function()");
- }
-
- @Override
- @Test
- public void testInt()
- {
- IVariableNode node = getVariable("var a:int = new int(1.8);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = new int(1.8)");
- }
-
- @Override
- @Test
- public void testJSON()
- {
- IVariableNode node = getVariable("var a:JSON = new JSON();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {JSON} */ a = new JSON()");
- }
-
- @Override
- @Test
- public void testMath()
- {
- IVariableNode node = getVariable("var a:Number = Math.PI;");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = Math.PI");
- }
-
- @Override
- @Test
- public void testNamespace()
- {
- IVariableNode node = getVariable("var a:Namespace = new Namespace(\"http://example.com\");");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Namespace} */ a = new Namespace(\"http://example.com\")");
- }
-
- @Override
- @Test
- public void testNumber()
- {
- IVariableNode node = getVariable("var a:Number = new Number(\"1\");");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = new Number(\"1\")");
- }
-
- @Override
- @Test
- public void testObject()
- {
- IVariableNode node = getVariable("var a:Object = new Object();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Object} */ a = new Object()");
- }
-
- @Override
- @Test
- public void testQName()
- {
- IVariableNode node = getVariable("var a:QName = new QName();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {QName} */ a = new QName()");
- }
-
- @Override
- @Test
- public void testRangeError()
- {
- IVariableNode node = getVariable("var a:RangeError = new RangeError();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {RangeError} */ a = new RangeError()");
- }
-
- @Override
- @Test
- public void testReferenceError()
- {
- IVariableNode node = getVariable("var a:ReferenceError = new ReferenceError();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {ReferenceError} */ a = new ReferenceError()");
- }
-
- @Override
- @Test
- public void testRegExp_Literal()
- {
- IVariableNode node = getVariable("var a:RegExp = /test-\\d/i;");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {RegExp} */ a = /test-\\d/i");
- }
-
- @Override
- @Test
- public void testSecurityError()
- {
- IVariableNode node = getVariable("var a:SecurityError = new SecurityError();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {SecurityError} */ a = new SecurityError()");
- }
-
- @Override
- @Test
- public void testString()
- {
- IVariableNode node = getVariable("var a:String = new String(\"100\");");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {string} */ a = new String(\"100\")");
- }
-
- @Override
- @Test
- public void testSyntaxError()
- {
- IVariableNode node = getVariable("var a:SyntaxError = new SyntaxError();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {SyntaxError} */ a = new SyntaxError()");
- }
-
- @Override
- @Test
- public void testTypeError()
- {
- IVariableNode node = getVariable("var a:TypeError = new TypeError();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {TypeError} */ a = new TypeError()");
- }
-
- @Override
- @Test
- public void testUint()
- {
- IVariableNode node = getVariable("var a:uint = new uint(-100);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = new uint(-100)");
- }
-
- @Override
- @Test
- public void testURIError()
- {
- IVariableNode node = getVariable("var a:URIError = new URIError();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {URIError} */ a = new URIError()");
- }
-
- @Override
- @Test
- public void testVector()
- {
- IVariableNode node = getVariable("var a:Vector.<String> = new Vector.<String>(['Hello', 'World']);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Array.<string>} */ a = new Array(['Hello', 'World'])");
- }
-
- @Override
- @Test
- public void testVerifyError()
- {
- IVariableNode node = getVariable("var a:VerifyError = new VerifyError();");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {VerifyError} */ a = new VerifyError()");
- }
-
- @Override
- @Test
- public void testXML()
- {
- IVariableNode node = getVariable("var a:XML = new XML('@');");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {XML} */ a = new XML('@')");
- }
-
- @Override
- @Test
- public void testXMLList()
- {
- IVariableNode node = getVariable("var a:XMLList = new XMLList('<!-- comment -->');");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {XMLList} */ a = new XMLList('<!-- comment -->')");
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogGlobalConstants.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogGlobalConstants.java
deleted file mode 100644
index a3706c781..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogGlobalConstants.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.as.TestGlobalConstants;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.tree.as.IVariableNode;
-import org.junit.Test;
-
-/**
- * @author Erik de Bruin
- */
-public class TestGoogGlobalConstants extends TestGlobalConstants
-{
- @Override
- @Test
- public void testInfinity()
- {
- IVariableNode node = getField("public var a:Number = Infinity;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @type {number}\n */\nRoyaleTest_A.prototype.a = Infinity");
- }
-
- @Override
- @Test
- public void testNegativeInfinity()
- {
- IVariableNode node = getField("public var a:Number = -Infinity;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @type {number}\n */\nRoyaleTest_A.prototype.a = -Infinity");
- }
-
- @Override
- @Test
- public void testNaN()
- {
- IVariableNode node = getField("public var a:Number = NaN;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @type {number}\n */\nRoyaleTest_A.prototype.a = NaN");
- }
-
- @Override
- @Test
- public void testUndefined()
- {
- IVariableNode node = getField("public var a:* = undefined;");
- asBlockWalker.visitVariable(node);
- assertOut("/**\n * @type {*}\n */\nRoyaleTest_A.prototype.a = undefined");
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogGlobalFunctions.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogGlobalFunctions.java
deleted file mode 100644
index ad11e15a6..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogGlobalFunctions.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.as.TestGlobalFunctions;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.tree.as.IFunctionCallNode;
-import org.apache.royale.compiler.tree.as.IVariableNode;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author Erik de Bruin
- */
-public class TestGoogGlobalFunctions extends TestGlobalFunctions
-{
- @Override
- @Test
- public void testArray()
- {
- IVariableNode node = getVariable("var a:Array = Array(1);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Array} */ a = Array(1)");
- }
-
- @Override
- @Test
- public void testBoolean()
- {
- IVariableNode node = getVariable("var a:Boolean = Boolean(1);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {boolean} */ a = Boolean(1)");
- }
-
- @Override
- @Test
- public void testDecodeURI()
- {
- IVariableNode node = getVariable("var a:String = decodeURI('http://whatever.com');");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {string} */ a = decodeURI('http://whatever.com')");
- }
-
- @Override
- @Test
- public void testDecodeURIComponent()
- {
- IVariableNode node = getVariable("var a:String = decodeURIComponent('http://whatever.com');");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {string} */ a = decodeURIComponent('http://whatever.com')");
- }
-
- @Override
- @Test
- public void testEncodeURI()
- {
- IVariableNode node = getVariable("var a:String = encodeURI('http://whatever.com');");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {string} */ a = encodeURI('http://whatever.com')");
- }
-
- @Override
- @Test
- public void testEncodeURIComponent()
- {
- IVariableNode node = getVariable("var a:String = encodeURIComponent('http://whatever.com');");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {string} */ a = encodeURIComponent('http://whatever.com')");
- }
-
- @Override
- @Test
- public void testEscape()
- {
- IVariableNode node = getVariable("var a:String = escape('http://whatever.com');");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {string} */ a = escape('http://whatever.com')");
- }
-
- @Override
- @Test
- public void testInt()
- {
- IVariableNode node = getVariable("var a:int = int(1.8);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = int(1.8)");
- }
-
- @Override
- @Test
- public void testIsFinite()
- {
- IVariableNode node = getVariable("var a:Boolean = isFinite(1000000.9);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {boolean} */ a = isFinite(1000000.9)");
- }
-
- @Override
- @Test
- public void testIsNaN()
- {
- IVariableNode node = getVariable("var a:Boolean = isNaN(NaN);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {boolean} */ a = isNaN(NaN)");
- }
-
- //isXMLName is in E4X, which is not supported by JavaScript
-/* @Ignore*/
- @Override
- @Test
- public void testIsXMLName()
- {
- IVariableNode node = getVariable("var a:Boolean = isXMLName(\"?\");");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {boolean} */ a = isXMLName(\"?\")");
- }
-
- @Override
- @Test
- public void testNumber()
- {
- IVariableNode node = getVariable("var a:Number = Number(\"1\");");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = Number(\"1\")");
- }
-
- @Override
- @Test
- public void testObject()
- {
- IVariableNode node = getVariable("var a:Object = Object(\"1\");");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Object} */ a = Object(\"1\")");
- }
-
- @Override
- @Test
- public void testParseFloat()
- {
- IVariableNode node = getVariable("var a:Number = parseFloat(\"1.8\");");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = parseFloat(\"1.8\")");
- }
-
- @Override
- @Test
- public void testParseInt()
- {
- IVariableNode node = getVariable("var a:Number = parseInt(\"666\", 10);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = parseInt(\"666\", 10)");
- }
-
- @Override
- @Test
- public void testString()
- {
- IVariableNode node = getVariable("var a:String = String(100);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {string} */ a = String(100)");
- }
-
- @Override
- @Test
- public void testTrace()
- {
- IFunctionCallNode node = (IFunctionCallNode) getNode(
- "trace('Hello World');", IFunctionCallNode.class);
- asBlockWalker.visitFunctionCall(node);
- assertOut("trace('Hello World')");
- }
-
- @Override
- @Test
- public void testUint()
- {
- IVariableNode node = getVariable("var a:uint = uint(-100);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = uint(-100)");
- }
-
- @Override
- @Test
- public void testUnescape()
- {
- IVariableNode node = getVariable("var a:String = unescape('%25');");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {string} */ a = unescape('%25')");
- }
-
- @Override
- @Test
- public void testVector()
- {
- IVariableNode node = getVariable("var a:Vector.<String> = Vector.<String>(['Hello', 'World']);");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Array.<string>} */ a = Array(['Hello', 'World'])");
- }
-
- @Override
- @Test
- public void testXML()
- {
- IVariableNode node = getVariable("var a:XML = XML('@');");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {XML} */ a = XML('@')");
- }
-
- @Override
- @Test
- public void testXMLList()
- {
- IVariableNode node = getVariable("var a:XMLList = XMLList('<!-- comment -->');");
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {XMLList} */ a = XMLList('<!-- comment -->')");
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogInterface.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogInterface.java
deleted file mode 100644
index e4b64c33d..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogInterface.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.as.TestInterface;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.tree.as.IInterfaceNode;
-import org.junit.Test;
-
-/**
- * This class tests the production of valid 'goog' JS code for Interface
- * production.
- *
- * @author Michael Schmalle
- * @author Erik de Bruin
- */
-public class TestGoogInterface extends TestInterface
-{
- @Override
- @Test
- public void testSimple()
- {
- IInterfaceNode node = getInterfaceNode("public interface IA{}");
- asBlockWalker.visitInterface(node);
- assertOut("/**\n * @interface\n */\nIA = function() {\n};");
- }
-
- @Override
- @Test
- public void testSimpleExtends()
- {
- IInterfaceNode node = getInterfaceNode("public interface IA extends IB{}");
- asBlockWalker.visitInterface(node);
- assertOut("/**\n * @interface\n * @extends {IB}\n */\nIA = function() {\n};");
- }
-
- @Override
- @Test
- public void testSimpleExtendsMultiple()
- {
- IInterfaceNode node = getInterfaceNode("public interface IA extends IB, IC, ID {}");
- asBlockWalker.visitInterface(node);
- assertOut("/**\n * @interface\n * @extends {IB}\n * @extends {IC}\n * @extends {ID}\n */\nIA = function() {\n};");
- }
-
- @Override
- @Test
- public void testQualifiedExtendsMultiple()
- {
- IInterfaceNode node = getInterfaceNode("public interface IA extends foo.bar.IB, baz.goo.IC, foo.ID {}");
- asBlockWalker.visitInterface(node);
- assertOut("/**\n * @interface\n * @extends {foo.bar.IB}\n * @extends {baz.goo.IC}\n * @extends {foo.ID}\n */\nIA = function() {\n};");
- }
-
- @Override
- @Test
- public void testAccessors()
- {
- IInterfaceNode node = getInterfaceNode("public interface IA {"
- + "function get foo1():Object;"
- + "function set foo1(value:Object):void;}");
- asBlockWalker.visitInterface(node);
- assertOut("/**\n * @interface\n */\nIA = function() {\n};\nIA.prototype.foo1;");
- }
-
- @Override
- @Test
- public void testMethods()
- {
- IInterfaceNode node = getInterfaceNode("public interface IA {"
- + "function baz1():Object;"
- + "function baz2(value:Object):void;}");
- asBlockWalker.visitInterface(node);
- assertOut("/**\n * @interface\n */\nIA = function() {\n};\nIA.prototype.baz1 = function() {\n};\nIA.prototype.baz2 = function(value) {\n};");
- }
-
- @Override
- @Test
- public void testAccessorsMethods()
- {
- IInterfaceNode node = getInterfaceNode("public interface IA {"
- + "function get foo1():Object;"
- + "function set foo1(value:Object):void;"
- + "function baz1():Object;"
- + "function baz2(value:Object):void;}");
- asBlockWalker.visitInterface(node);
- assertOut("/**\n * @interface\n */\nIA = function() {\n};\nIA.prototype.foo1;\nIA.prototype.baz1 = function() {\n};\nIA.prototype.baz2 = function(value) {\n};");
- }
-
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogMethodMembers.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogMethodMembers.java
deleted file mode 100644
index d29767525..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogMethodMembers.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.as.TestMethodMembers;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.tree.as.IClassNode;
-import org.apache.royale.compiler.tree.as.IFunctionNode;
-import org.junit.Test;
-
-/**
- * This class tests the production of 'goog'-ified JS code for Class Method
- * members.
- *
- * @author Michael Schmalle
- * @author Erik de Bruin
- */
-public class TestGoogMethodMembers extends TestMethodMembers
-{
- @Override
- @Test
- public void testMethod()
- {
- IFunctionNode node = getMethod("function foo(){}");
- asBlockWalker.visitFunction(node);
- assertOut("RoyaleTest_A.prototype.foo = function() {\n}");
- }
-
- @Override
- @Test
- public void testMethod_withReturnType()
- {
- IFunctionNode node = getMethod("function foo():int{\treturn -1;}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @return {number}\n */\nRoyaleTest_A.prototype.foo = function() {\n\tvar self = this;\n\treturn -1;\n}");
- }
-
- @Override
- @Test
- public void testMethod_withParameterReturnType()
- {
- IFunctionNode node = getMethod("function foo(bar):int{\treturn -1;}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {*} bar\n * @return {number}\n */\nRoyaleTest_A.prototype.foo = function(bar) {\n\tvar self = this;\n\treturn -1;\n}");
- }
-
- @Override
- @Test
- public void testMethod_withParameterTypeReturnType()
- {
- IFunctionNode node = getMethod("function foo(bar:String):int{\treturn -1;}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {string} bar\n * @return {number}\n */\nRoyaleTest_A.prototype.foo = function(bar) {\n\tvar self = this;\n\treturn -1;\n}");
- }
-
- @Override
- @Test
- public void testMethod_withDefaultParameterTypeReturnType()
- {
- IFunctionNode node = getMethod("function foo(bar:String = \"baz\"):int{\treturn -1;}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {string=} bar\n * @return {number}\n */\nRoyaleTest_A.prototype.foo = function(bar) {\n\tvar self = this;\n\tbar = typeof bar !== 'undefined' ? bar : \"baz\";\n\treturn -1;\n}");
- }
-
- @Override
- @Test
- public void testMethod_withMultipleDefaultParameterTypeReturnType()
- {
- IFunctionNode node = getMethod("function foo(bar:String, baz:int = null):int{\treturn -1;}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nRoyaleTest_A.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
- }
-
- @Test
- public void testMethod_withRestParameterTypeReturnType()
- {
- IFunctionNode node = getMethod("function foo(bar:String, ...rest):int{\treturn -1;}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {string} bar\n * @param {...} rest\n * @return {number}\n */\nRoyaleTest_A.prototype.foo = function(bar, rest) {\n\tvar self = this;\n\trest = Array.prototype.slice.call(arguments, 1);\n\treturn -1;\n}");
- }
-
- @Override
- @Test
- public void testMethod_withNamespace()
- {
- IFunctionNode node = getMethod("public function foo(bar:String, baz:int = null):int{\treturn -1;}");
- asBlockWalker.visitFunction(node);
- // we ignore the 'public' namespace completely
- assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nRoyaleTest_A.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
- }
-
- @Override
- @Test
- public void testMethod_withNamespaceCustom()
- {
- IFunctionNode node = getMethod("mx_internal function foo(bar:String, baz:int = null):int{\treturn -1;}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nRoyaleTest_A.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
- }
-
- @Override
- @Test
- public void testMethod_withNamespaceModifiers()
- {
- IFunctionNode node = getMethod("public static function foo(bar:String, baz:int = null):int{\treturn -1;}");
- asBlockWalker.visitFunction(node);
- // (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 */\nRoyaleTest_A.foo = function(bar, baz) {\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
- }
-
- @Override
- @Test
- public void testMethod_withNamespaceModifierOverride()
- {
- IFunctionNode node = getMethod("public override function foo(bar:String, baz:int = null):int{\treturn -1;}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nRoyaleTest_A.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
- }
-
- @Override
- @Test
- public void testMethod_withNamespaceModifierOverrideBackwards()
- {
- IFunctionNode node = getMethod("override public function foo(bar:String, baz:int = null):int{return -1;}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nRoyaleTest_A.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
- }
-
- //--------------------------------------------------------------------------
- // Doc Specific Tests
- //--------------------------------------------------------------------------
-
- @Test
- public void testConstructor_withThisInBody()
- {
- IClassNode node = (IClassNode) getNode("public function RoyaleTest_A() {this.foo;}", IClassNode.class, WRAP_LEVEL_CLASS);
- asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function() {\n\tvar self = this;\n\tthis.foo;\n};");
- }
-
- @Test
- public void testMethod_withThisInBody()
- {
- IFunctionNode node = getMethod("function foo(){this.foo;}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @this {RoyaleTest_A}\n */\nRoyaleTest_A.prototype.foo = function() {\n\tvar self = this;\n\tthis.foo;\n}");
- }
-
- @Test
- public void testMethod_withThisInBodyComplex()
- {
- IFunctionNode node = getMethod("function foo(){if(true){while(i){this.bar(42);}}}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * @this {RoyaleTest_A}\n */\nRoyaleTest_A.prototype.foo = function() {\n\tvar self = this;\n\tif (true) "
- + "{\n\t\twhile (i) {\n\t\t\tthis.bar(42);\n\t\t}\n\t}\n}");
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogPackage.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogPackage.java
deleted file mode 100644
index 4e3d982af..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogPackage.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.as.TestPackage;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.tree.as.IFileNode;
-import org.junit.Test;
-
-/**
- * This class tests the production of 'goog' JavaScript for AS package.
- *
- * @author Michael Schmalle
- * @author Erik de Bruin
- */
-public class TestGoogPackage extends TestPackage
-{
- @Override
- @Test
- public void testPackage_Simple()
- {
- IFileNode node = compileAS("package{}");
- asBlockWalker.visitFile(node);
- assertOut("");
- }
-
- @Test
- public void testPackage_SimpleName()
- {
- IFileNode node = compileAS("package foo {}");
- asBlockWalker.visitFile(node);
- assertOut("");
- }
-
- @Override
- @Test
- public void testPackage_Name()
- {
- IFileNode node = compileAS("package foo.bar.baz {}");
- asBlockWalker.visitFile(node);
- assertOut("");
- }
-
- @Override
- @Test
- public void testPackageSimple_Class()
- {
- // does JS need a implicit constructor function? ... always?
- // 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 = compileAS("package {public class A{}}");
- asBlockWalker.visitFile(node);
- assertOut("goog.provide('A');\n\n/**\n * @constructor\n */\nA = function() {\n};");
- }
-
- @Override
- @Test
- public void testPackageQualified_Class()
- {
- IFileNode node = compileAS("package foo.bar.baz {public class A{}}");
- asBlockWalker.visitFile(node);
- assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n};");
- }
-
- @Override
- @Test
- public void testPackageQualified_ClassBody()
- {
- IFileNode node = compileAS("package foo.bar.baz {public class A{public function A(){}}}");
- asBlockWalker.visitFile(node);
- 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 = compileAS("package foo.bar.baz {public class A{public function A(){if (a){for (var i:Object in obj){doit();}}}}}");
- asBlockWalker.visitFile(node);
- assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n\tvar self = this;\n\tif (a) {\n\t\tfor (var /** @type {Object} */ i in obj) {\n\t\t\tdoit();\n\t\t}\n\t}\n};");
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogProject.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogProject.java
deleted file mode 100644
index 94c8ee2d3..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogProject.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.filefilter.FileFileFilter;
-import org.apache.commons.io.filefilter.FileFilterUtils;
-import org.apache.commons.io.filefilter.IOFileFilter;
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.internal.test.ASTestBase;
-import org.apache.royale.utils.TestAdapterFactory;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.List;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-/**
- * This class tests the production of valid 'goog' JS code from an external
- * project.
- *
- * @author Erik de Bruin
- */
-public class TestGoogProject extends ASTestBase
-{
-
- private static String projectDirPath = "goog/projects";
-
- @Test
- public void test_imports()
- {
- String testDirPath = projectDirPath + "/imports";
-
- String fileName = "Case";
-
- List<String> compiledFileNames = compileProject(fileName, testDirPath);
-
- assertProjectOut(compiledFileNames, testDirPath);
- }
-
- @Override
- protected void addSourcePaths(List<File> sourcePaths)
- {
- sourcePaths.add(new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
- projectDirPath + "/imports"));
-
- super.addSourcePaths(sourcePaths);
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-
- protected void assertProjectOut(List<String> compiledFileNames,
- String testDirPath)
- {
- if (compiledFileNames.size() == 0)
- {
- fail("Expected compiled files");
- }
- for (String compiledFileName : compiledFileNames)
- {
- String compiledFilePath = tempDir.getAbsolutePath()
- + File.separator + testDirPath + File.separator
- + compiledFileName + "_output" + "."
- + backend.getOutputExtension();
- String compiledResult = readCodeFile(new File(compiledFilePath));
-
- //System.out.println(compiledResult);
-
- String expectedFilePath = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
- testDirPath + "/" + compiledFileName + "_result" + "." + backend.getOutputExtension()).getPath();
- String expectedResult = readCodeFile(new File(expectedFilePath));
- /*if (!compiledResult.equals(expectedResult)) {
- System.out.println("expected\n"+expectedResult);
- System.out.println("got\n"+compiledResult);
- }*/
- assertThat(compiledResult, is(expectedResult));
- }
- }
-
- protected void assertPublishedProjectOut(String projectFolderPath,
- String projectName)
- {
- String outputFolderName = tempDir + "/" + projectName + "/bin/js-debug";
- IOFileFilter jsFilter = FileFilterUtils.and(FileFileFilter.FILE,
- FileFilterUtils.suffixFileFilter("js"));
- IOFileFilter htmlFilter = FileFilterUtils.and(FileFileFilter.FILE,
- FileFilterUtils.suffixFileFilter("html"));
- IOFileFilter resultsFilter = FileFilterUtils.or(jsFilter, htmlFilter);
- File outputFolder = new File(outputFolderName);
- File projectFolder = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(), projectFolderPath);
- projectFolderPath = projectFolder.getAbsolutePath();
- Collection<File> files = FileUtils.listFiles(projectFolder, resultsFilter, null);
- for (File resultFile : files)
- {
- String compiledFilePath = resultFile.getAbsolutePath();
- if (compiledFilePath.startsWith(projectFolderPath))
- compiledFilePath = compiledFilePath.substring(projectFolderPath.length());
- compiledFilePath = compiledFilePath.replace("_result", "");
- File compiledFile = new File(outputFolder, compiledFilePath);
- String compiledResult = readCodeFile(compiledFile);
-
- String expectedResult = readCodeFile(resultFile);
- /*if (!compiledResult.equals(expectedResult)) {
- System.out.println("expected\n"+expectedResult);
- System.out.println("got\n"+compiledResult);
- }*/
- assertThat(compiledResult, is(expectedResult));
- }
- }
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogStatements.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogStatements.java
deleted file mode 100644
index 94a11c3c8..000000000
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogStatements.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.royale.compiler.internal.codegen.js.goog;
-
-import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.as.TestStatements;
-import org.apache.royale.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.royale.compiler.internal.tree.as.LabeledStatementNode;
-import org.apache.royale.compiler.tree.as.IFileNode;
-import org.apache.royale.compiler.tree.as.IForLoopNode;
-import org.apache.royale.compiler.tree.as.IIfNode;
-import org.apache.royale.compiler.tree.as.ISwitchNode;
-import org.apache.royale.compiler.tree.as.ITryNode;
-import org.apache.royale.compiler.tree.as.IVariableNode;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author Michael Schmalle
- * @author Erik de Bruin
- */
-public class TestGoogStatements extends TestStatements
-{
- //----------------------------------
- // var declaration
- //----------------------------------
-
- @Override
- @Test
- public void testVarDeclaration()
- {
- IVariableNode node = (IVariableNode) getNode("var a;",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {*} */ a");
- }
-
- @Override
- @Test
- public void testVarDeclaration_withType()
- {
- IVariableNode node = (IVariableNode) getNode("var a:int;",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a");
- }
-
- @Override
- @Test
- public void testVarDeclaration_withTypeAssignedValue()
- {
- IVariableNode node = (IVariableNode) getNode("var a:int = 42;",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = 42");
- }
-
- @Override
- @Test
- public void testVarDeclaration_withTypeAssignedValueComplex()
- {
- IVariableNode node = (IVariableNode) getNode(
- "class A { public function b():void { var a:Foo = new Foo(42, 'goo');}} class Foo {}", IVariableNode.class, WRAP_LEVEL_PACKAGE);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {Foo} */ a = new Foo(42, 'goo')");
- }
-
- @Override
- @Test
- public void testVarDeclaration_withList()
- {
- IVariableNode node = (IVariableNode) getNode(
- "var a:int = 4, b:int = 11, c:int = 42;", IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("var /** @type {number} */ a = 4, /** @type {number} */ b = 11, /** @type {number} */ c = 42");
- }
-
- //----------------------------------
- // const declaration
- //----------------------------------
-
- @Override
- @Test
- public void testConstDeclaration()
- {
- IVariableNode node = (IVariableNode) getNode("const a = 42;",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("\n/**\n * @const\n * @type {*}\n */\na = 42");
- }
-
- @Override
- @Test
- public void testConstDeclaration_withType()
- {
- IVariableNode node = (IVariableNode) getNode("const a:int = 42;",
- IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("\n/**\n * @const\n * @type {number}\n */\na = 42");
- }
-
- @Override
- @Test
- public void testConstDeclaration_withList()
- {
- IVariableNode node = (IVariableNode) getNode(
- "const a:int = 4, b:int = 11, c:int = 42;", IVariableNode.class);
- asBlockWalker.visitVariable(node);
- assertOut("\n/**\n * @const\n * @type {number}\n */\na = 4, \n/**\n * @const\n * @type {number}\n */\nb = 11, \n/**\n * @const\n * @type {number}\n */\nc = 42");
- }
-
- //----------------------------------
- // for () { }
- //----------------------------------
-
- @Override
- @Test
- public void testVisitFor_1a()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for (var i:int = 0; i < len; i++) { break; }",
- IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var /** @type {number} */ i = 0; i < len; i++) {\n\tbreak;\n}");
- }
-
- @Override
- @Test
- public void testVisitFor_1b()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for (var i:int = 0; i < len; i++) break;", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var /** @type {number} */ i = 0; i < len; i++)\n\tbreak;");
- }
-
- @Test
- public void testVisitFor_1c()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for (var i:int = 0, len:int = 10; i < len; i++) break;", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var /** @type {number} */ i = 0, /** @type {number} */ len = 10; i < len; i++)\n\tbreak;");
- }
-
- @Override
- @Test
- public void testVisitForIn_1()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for (var i:int in obj) { break; }", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var /** @type {number} */ i in obj) {\n\tbreak;\n}");
- }
-
- @Override
- @Test
- public void testVisitForIn_1a()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for (var i:int in obj) break; ", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("for (var /** @type {number} */ i in obj)\n\tbreak;");
- }
-
- @Override
- @Test
- public void testVisitForEach_1()
- {
- // TODO (erikdebruin) we need to insert a "goog.require('goog.array')"
- // into the header
- IForLoopNode node = (IForLoopNode) getNode(
- "for each(var i:int in obj) { break; }", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("goog.array.forEach(obj, function (i) {\n\tbreak;\n})");
- }
-
- @Override
- @Test
- public void testVisitForEach_1a()
- {
- IForLoopNode node = (IForLoopNode) getNode(
- "for each(var i:int in obj) break; ", IForLoopNode.class);
- asBlockWalker.visitForLoop(node);
- assertOut("goog.array.forEach(obj, function (i) {\n\tbreak;\n})");
- }
-
- //----------------------------------
- // try {} catch () {} finally {}
- //----------------------------------
-
- @Override
- @Test
- public void testVisitTry_Catch()
- {
- ITryNode node = (ITryNode) getNode("try { a; } catch (e:Error) { b; }",
- ITryNode.class);
- asBlockWalker.visitTry(node);
- assertOut("try {\n\ta;\n} catch (e) {\n\tb;\n}");
- }
-
- @Override
- @Test
- public void testVisitTry_Catch_Finally()
- {
- ITryNode node = (ITryNode) getNode(
- "try { a; } catch (e:Error) { b; } finally { c; }",
- ITryNode.class);
- asBlockWalker.visitTry(node);
- assertOut("try {\n\ta;\n} catch (e) {\n\tb;\n} finally {\n\tc;\n}");
- }
-
- @Override
- @Test
- public void testVisitTry_Catch_Catch_Finally()
- {
- ITryNode node = (ITryNode) getNode(
- "try { a; } catch (e:ReferenceError) { b; } catch (f:Error) { c; } finally { d; }",
- ITryNode.class);
- asBlockWalker.visitTry(node);
- assertOut("try {\n\ta;\n} catch ($$royaleMultiCatchErr) /* implicit multi-catch wrapper */ {\n\tif ($$royaleMultiCatchErr instanceof ReferenceError) {\n\t\tvar /** @type {ReferenceError} */ e = $$royaleMultiCatchErr;\n\t\tb;\n\t} else if ($$royaleMultiCatchErr instanceof Error) {\n\t\tvar /** @type {Error} */ f = $$royaleMultiCatchErr;\n\t\tc;\n\t} else {\n\t\tthrow $$royaleMultiCatchErr;\n\t}\n} finally {\n\td;\n}");
- }
-
- @Override
- @Test
- public void testVisitTry_CatchEmpty_FinallyEmpty_()
- {
- ITryNode node = (ITryNode) getNode(
- "try { a; } catch (e:Error) { } finally { }", ITryNode.class);
- asBlockWalker.visitTry(node);
- assertOut("try {\n\ta;\n} catch (e) {\n} finally {\n}");
- }
-
- //----------------------------------
- // switch {}
- //----------------------------------
-
- @Test
- public void testVisitSwitch_3()
- {
- ISwitchNode node = (ISwitchNode) getNode(
- "switch(i){case 1: { var x:int = 42; break; }; case 2: { var y:int = 66; break; }}", ISwitchNode.class);
- asBlockWalker.visitSwitch(node);
- assertOut("switch (i) {\n\tcase 1:\n\t\tvar /** @type {number} */ x = 42;\n\t\tbreak;\n\tcase 2:\n\t\tvar /** @type {number} */ y = 66;\n\t\tbreak;\n}");
- }
-
- //----------------------------------
- // label : for () {}
- //----------------------------------
-
- @Override
- @Test
- public void testVisitLabel_1()
- {
- LabeledStatementNode node = (LabeledStatementNode) getNode(
- "foo: for each(var i:int in obj) { break foo; }",
- LabeledStatementNode.class);
- asBlockWalker.visitLabeledStatement(node);
- assertOut("foo : goog.array.forEach(obj, function (i) {\n\tbreak foo;\n})");
- }
-
- @Override
- @Test
- public void testVisitLabel_1a()
- {
- LabeledStatementNode node = (LabeledStatementNode) getNode(
- "foo: for each(var i:int in obj) break foo;",
- LabeledStatementNode.class);
- asBlockWalker.visitLabeledStatement(node);
- assertOut("foo : goog.array.forEach(obj, function (i) {\n\tbreak foo;\n})");
- }
-
- //----------------------------------
- // all together now!
- //----------------------------------
-
- @Override
- @Test
- public void testVisit()
- {
- 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;"
- + "if (a) { with (ab) { c(); } "
- + "do {a++;do a++; while(a > b);} while(c > d); }"
- + "if (b) { try { a; throw new Error('foo'); } catch (e:Error) { "
- + " switch(i){case 1: break; default: return;}"
- + " } finally { "
- + " d; var a:Object = function(foo:int, bar:String = 'goo'):int{return -1;};"
- + " eee.dd; eee.dd; eee.dd; eee.dd;} }"
- + "foo: for each(var i:int in obj) break foo;",
- IFileNode.class);
- asBlockWalker.visitFile(node);
- assertOut("goog.provide('RoyaleTest_A');\n\n/**\n * @constructor\n */\nRoyaleTest_A = function() {\n};\n\nRoyaleTest_A.prototype.royaleTest_a = function() {\n\tvar self = this;\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\ [...]
- }
-
- @Test
- public void testVisitIf_NoBody()
- {
- IIfNode node = (IIfNode) getNode(
- "if (a) ;", IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (a) {}\n");
- }
-
- @Test
- public void testVisitElseIf_NoBody()
- {
- IIfNode node = (IIfNode) getNode(
- "if (a) b; else if (a);", IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (a)\n\tb;\nelse if (a) {}\n");
- }
-
- @Test
- public void testVisitElse_NoBody()
- {
- IIfNode node = (IIfNode) getNode(
- "if (a) b; else;", IIfNode.class);
- asBlockWalker.visitIf(node);
- assertOut("if (a)\n\tb;\nelse {}\n");
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new GoogBackend();
- }
-
-}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessorMembers.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessorMembers.java
index 1910d01d0..6701e08a3 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessorMembers.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessorMembers.java
@@ -20,7 +20,7 @@
package org.apache.royale.compiler.internal.codegen.js.royale;
import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogAccessorMembers;
+import org.apache.royale.compiler.internal.codegen.as.TestAccessorMembers;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.tree.as.IClassNode;
import org.junit.Test;
@@ -28,7 +28,7 @@ import org.junit.Test;
/**
* @author Erik de Bruin
*/
-public class TestRoyaleAccessorMembers extends TestGoogAccessorMembers
+public class TestRoyaleAccessorMembers extends TestAccessorMembers
{
@Override
@Test
@@ -43,7 +43,6 @@ public class TestRoyaleAccessorMembers extends TestGoogAccessorMembers
"Object.defineProperties(RoyaleTest_A.prototype, /** @lends {RoyaleTest_A.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nget: RoyaleTest_A.prototype.get__foo}}\n);");
}
- @Override
@Test
public void testGetAccessor_withBody()
{
@@ -144,7 +143,6 @@ public class TestRoyaleAccessorMembers extends TestGoogAccessorMembers
"Object.defineProperties(RoyaleTest_A.prototype, /** @lends {RoyaleTest_A.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nset: RoyaleTest_A.prototype.set__foo}}\n);");
}
- @Override
@Test
public void testSetAccessor_withBody()
{
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java
index 0088173f1..24c8a6994 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java
@@ -20,18 +20,19 @@
package org.apache.royale.compiler.internal.codegen.js.royale;
import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogClass;
+import org.apache.royale.compiler.internal.codegen.as.TestClass;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.internal.driver.js.goog.JSGoogConfiguration;
import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
import org.apache.royale.compiler.internal.tree.as.FileNode;
import org.apache.royale.compiler.tree.as.IClassNode;
+import org.apache.royale.compiler.tree.as.IFileNode;
import org.junit.Test;
/**
* @author Erik de Bruin
*/
-public class TestRoyaleClass extends TestGoogClass
+public class TestRoyaleClass extends TestClass
{
@Override
public void setUp()
@@ -42,7 +43,6 @@ public class TestRoyaleClass extends TestGoogClass
super.setUp();
}
- @Override
@Test
public void testConstructor_super()
{
@@ -112,7 +112,6 @@ public class TestRoyaleClass extends TestGoogClass
assertOut("/**\n * @constructor\n * @extends {custom.TestImplementation}\n * @implements {custom.TestInterface}\n * @implements {custom.TestOtherInterface}\n */\norg.apache.royale.A = function() {\n org.apache.royale.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.royale.A, custom.TestImplementation);");
}
- @Override
@Test
public void testExtendsConstructor_super()
{
@@ -886,6 +885,17 @@ public class TestRoyaleClass extends TestGoogClass
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n * @param {string=} arg1\n */\norg.apache.royale.A = function(arg1) {\n arg1 = typeof arg1 !== 'undefined' ? arg1 : org.apache.royale.A.NAME;\n this._name = arg1;\n};\n\n\n/**\n * @nocollapse\n * @const\n * @type {string}\n */\norg.apache.royale.A.NAME = 'Dummy';\n\n\n/**\n * @private\n * @type {string}\n */\norg.apache.royale.A.prototype._name = null;");
}
+
+ @Override
+ protected IClassNode getClassNode(String code)
+ {
+ String source = "package org.apache.royale {import custom.TestInterface;import custom.TestImplementation;import custom.TestEvent;import custom.TestOtherInterface;"
+ + code + "}";
+ IFileNode node = compileAS(source);
+ IClassNode child = (IClassNode) findFirstDescendantOfType(node,
+ IClassNode.class);
+ return child;
+ }
protected IBackend createBackend()
{
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java
index a45f7d0de..757e58709 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java
@@ -21,11 +21,11 @@ package org.apache.royale.compiler.internal.codegen.js.royale;
import org.apache.royale.compiler.driver.IBackend;
import org.apache.royale.compiler.exceptions.ConfigurationException;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogEmitter;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.internal.driver.js.goog.JSGoogConfiguration;
import org.apache.royale.compiler.internal.parsing.as.RoyaleASDocDelegate;
import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
+import org.apache.royale.compiler.internal.test.ASTestBase;
import org.apache.royale.compiler.tree.as.IFileNode;
import org.apache.royale.compiler.tree.as.IFunctionNode;
import org.junit.Test;
@@ -33,7 +33,7 @@ import org.junit.Test;
/**
* @author Erik de Bruin
*/
-public class TestRoyaleEmitter extends TestGoogEmitter
+public class TestRoyaleEmitter extends ASTestBase
{
@Override
public void setUp()
@@ -44,7 +44,6 @@ public class TestRoyaleEmitter extends TestGoogEmitter
super.setUp();
}
- @Override
@Test
public void testSimple()
{
@@ -143,7 +142,6 @@ public class TestRoyaleEmitter extends TestGoogEmitter
"com.example.components.MyEventTarget.prototype.ROYALE_COMPILE_FLAGS = 9;\n");
}
- @Override
@Test
public void testSimpleInterface()
{
@@ -193,7 +191,6 @@ public class TestRoyaleEmitter extends TestGoogEmitter
"com.example.components.TestInterface.prototype.ROYALE_COMPILE_FLAGS = 9;\n");
}
- @Override
@Test
public void testSimpleClass()
{
@@ -308,9 +305,15 @@ public class TestRoyaleEmitter extends TestGoogEmitter
" */\n" +
"com.example.components.TestClass.prototype.ROYALE_COMPILE_FLAGS = 9;\n");
}
-
- @Override
+ @Test
+ public void testSimpleMethod()
+ {
+ IFunctionNode node = getMethod("function method1():void{\n}");
+ asBlockWalker.visitFunction(node);
+ assertOut("RoyaleTest_A.prototype.method1 = function() {\n}");
+ }
+
@Test
public void testDefaultParameter()
{
@@ -323,7 +326,6 @@ public class TestRoyaleEmitter extends TestGoogEmitter
+ " return p1 + p2 + p3 + p4;\n}");
}
- @Override
@Test
public void testDefaultParameter_Body()
{
@@ -336,7 +338,6 @@ public class TestRoyaleEmitter extends TestGoogEmitter
+ " if (a)\n foo();\n}");
}
- @Override
@Test
public void testDefaultParameter_NoBody()
{
@@ -348,7 +349,6 @@ public class TestRoyaleEmitter extends TestGoogEmitter
+ " p4 = typeof p4 !== 'undefined' ? p4 : 4;\n}");
}
- @Override
@Test
public void testSimpleParameterReturnType()
{
@@ -358,7 +358,6 @@ public class TestRoyaleEmitter extends TestGoogEmitter
+ "foo.bar.RoyaleTest_A.prototype.method1 = function(bar) {\n}");
}
- @Override
@Test
public void testSimpleMultipleParameter()
{
@@ -368,7 +367,6 @@ public class TestRoyaleEmitter extends TestGoogEmitter
+ "foo.bar.RoyaleTest_A.prototype.method1 = function(bar, baz, goo) {\n}");
}
- @Override
@Test
public void testSimpleMultipleParameter_JSDoc()
{
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 7c40e166e..e2a4eb7d6 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
@@ -22,8 +22,8 @@ package org.apache.royale.compiler.internal.codegen.js.royale;
import org.apache.royale.compiler.definitions.IClassDefinition;
import org.apache.royale.compiler.driver.IBackend;
import org.apache.royale.compiler.exceptions.ConfigurationException;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogExpressions;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
+import org.apache.royale.compiler.internal.codegen.as.TestExpressions;
import org.apache.royale.compiler.internal.driver.js.goog.JSGoogConfiguration;
import org.apache.royale.compiler.internal.parsing.as.RoyaleASDocDelegate;
import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
@@ -37,7 +37,7 @@ import org.junit.Test;
/**
* @author Erik de Bruin
*/
-public class TestRoyaleExpressions extends TestGoogExpressions
+public class TestRoyaleExpressions extends TestExpressions
{
@Override
public void setUp()
@@ -1665,6 +1665,15 @@ public class TestRoyaleExpressions extends TestGoogExpressions
assertOut("/**\n * @param {Object} o\n * @return {number}\n */\nfoo.bar.LinkableString.prototype.b = function(o) {\n var /** @type {foo.bar.LinkableString} */ a = null;\n a = org.apache.royale.utils.Language.as(o, foo.bar.LinkableString);\n}");
}
+ @Override
+ @Test
+ public void testVisitBinaryOperator_Instancof()
+ {
+ IBinaryOperatorNode node = getBinaryNode("a instanceof b");
+ asBlockWalker.visitBinaryOperator(node);
+ assertOut("a instanceof b");
+ }
+
@Override
@Test
public void testVisitBinaryOperator_Is()
@@ -1673,6 +1682,23 @@ public class TestRoyaleExpressions extends TestGoogExpressions
asBlockWalker.visitBinaryOperator(node);
assertOut("org.apache.royale.utils.Language.is(a, b)");
}
+ @Test
+ public void testParentheses_1()
+ {
+ IVariableNode node = (IVariableNode) getNode("var a = (a + b);",
+ IVariableNode.class);
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {*} */ a = (a + b)");
+ }
+
+ @Test
+ public void testParentheses_2()
+ {
+ IVariableNode node = (IVariableNode) getNode("var a = (a + b) - c;",
+ IVariableNode.class);
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {*} */ a = (a + b) - c");
+ }
@Override
@Test
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java
index fb4b64dde..ba90e3cf5 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java
@@ -20,7 +20,7 @@
package org.apache.royale.compiler.internal.codegen.js.royale;
import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogFieldMembers;
+import org.apache.royale.compiler.internal.codegen.as.TestFieldMembers;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.tree.as.IClassNode;
import org.apache.royale.compiler.tree.as.IVariableNode;
@@ -29,7 +29,7 @@ import org.junit.Test;
/**
* @author Erik de Bruin
*/
-public class TestRoyaleFieldMembers extends TestGoogFieldMembers
+public class TestRoyaleFieldMembers extends TestFieldMembers
{
@Override
@@ -374,5 +374,34 @@ public class TestRoyaleFieldMembers extends TestGoogFieldMembers
assertOut("/**\n * @const\n * @type {number}\n */\nRoyaleTest_A.prototype.http_$$ns_apache_org$2017$custom$namespace__foo = 420");
}
+
+ // TODO (erikdebruin) not sure what to do with these when emitting JS...
+
+ @Override
+ @Test
+ public void testNamespace()
+ {
+// INamespaceNode node = getNamespace("namespace ns = \"http://whatever\";");
+// asBlockWalker.visitNamespace(node);
+// assertOut("namespace ns = \"http://whatever\"");
+ }
+
+ @Override
+ @Test
+ public void testNamespace_public()
+ {
+// INamespaceNode node = getNamespace("public namespace ns = \"http://whatever\";");
+// asBlockWalker.visitNamespace(node);
+// assertOut("public namespace ns = \"http://whatever\"");
+ }
+
+ @Override
+ @Test
+ public void testNamespace_protected()
+ {
+// INamespaceNode node = getNamespace("protected namespace ns = \"http://whatever\";");
+// asBlockWalker.visitNamespace(node);
+// assertOut("protected namespace ns = \"http://whatever\"");
+ }
}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFile.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFile.java
index 3dc3e4853..93f0c2882 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFile.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFile.java
@@ -45,6 +45,56 @@ public class TestRoyaleFile extends RoyaleTestBase
((RoyaleJSProject)project).config = new JSGoogConfiguration();
}
+ @Test
+ public void testFile_plain()
+ {
+ IFileNode node = compileAS("input", true, "royale" + File.separator
+ + "files");
+ asBlockWalker.visitFile(node);
+ assertOut(getCodeFromFile("output", true, "royale" + File.separator
+ + "files"));
+ }
+
+ @Test
+ public void testFile_getset()
+ {
+ IFileNode node = compileAS("get-set", true, "royale" + File.separator
+ + "files");
+ asBlockWalker.visitFile(node);
+ assertOut(getCodeFromFile("get-set_result", true, "royale"
+ + File.separator + "files"));
+ }
+
+ @Test
+ public void testFile_callsuper()
+ {
+ IFileNode node = compileAS("call-super", true, "royale" + File.separator
+ + "files");
+ asBlockWalker.visitFile(node);
+ assertOut(getCodeFromFile("call-super_result", true, "royale"
+ + File.separator + "files"));
+ }
+
+ @Test
+ public void testFile_qualifynewobject()
+ {
+ IFileNode node = compileAS("qualify-new-object", true, "royale"
+ + File.separator + "files");
+ asBlockWalker.visitFile(node);
+ assertOut(getCodeFromFile("qualify-new-object_result", true, "royale"
+ + File.separator + "files"));
+ }
+
+ @Test
+ public void testFile_poc()
+ {
+ IFileNode node = compileAS("poc", true, "royale" + File.separator
+ + "files");
+ asBlockWalker.visitFile(node);
+ assertOut(getCodeFromFile("poc_result", true, "royale" + File.separator
+ + "files"));
+ }
+
@Test
public void testLocalFunction()
{
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalClasses.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalClasses.java
index 8c7c15f78..954071a82 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalClasses.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalClasses.java
@@ -22,8 +22,8 @@ package org.apache.royale.compiler.internal.codegen.js.royale;
import java.io.File;
import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogGlobalClasses;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
+import org.apache.royale.compiler.internal.codegen.as.TestGlobalClasses;
import org.apache.royale.compiler.internal.driver.js.goog.JSGoogConfiguration;
import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
import org.apache.royale.compiler.internal.tree.as.BinaryOperatorAssignmentNode;
@@ -41,7 +41,7 @@ import org.junit.Ignore;
/**
* @author Erik de Bruin
*/
-public class TestRoyaleGlobalClasses extends TestGoogGlobalClasses
+public class TestRoyaleGlobalClasses extends TestGlobalClasses
{
@Override
public void setUp()
@@ -59,6 +59,15 @@ public class TestRoyaleGlobalClasses extends TestGoogGlobalClasses
return new RoyaleBackend();
}
+ @Override
+ @Test
+ public void testArgumentError()
+ {
+ IVariableNode node = getVariable("var a:ArgumentError = new ArgumentError();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {ArgumentError} */ a = new ArgumentError()");
+ }
+
@Override
@Test
public void testArguments()
@@ -68,6 +77,15 @@ public class TestRoyaleGlobalClasses extends TestGoogGlobalClasses
assertOut("RoyaleTest_A.prototype.a = function() {\n org.apache.royale.utils.Language.trace(arguments);\n}");
}
+ @Override
+ @Test
+ public void testArray()
+ {
+ IVariableNode node = getVariable("var a:Array = new Array(1);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Array} */ a = new Array(1)");
+ }
+
@Test
public void testArrayNoArgs()
{
@@ -316,6 +334,15 @@ public class TestRoyaleGlobalClasses extends TestGoogGlobalClasses
assertOut("var /** @type {*} */ b = org.apache.royale.utils.Language.resolveUncertain(new a('test'))");
}
+ @Override
+ @Test
+ public void testDate()
+ {
+ IVariableNode node = getVariable("var a:Date = new Date();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Date} */ a = new Date()");
+ }
+
@Test
public void testDateGetSeconds()
{
@@ -752,6 +779,51 @@ public class TestRoyaleGlobalClasses extends TestGoogGlobalClasses
assertOut("var /** @type {number} */ b = a.getTimezoneOffset()");
}
+ @Override
+ @Test
+ public void testDefinitionError()
+ {
+ IVariableNode node = getVariable("var a:DefinitionError = new DefinitionError();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {DefinitionError} */ a = new DefinitionError()");
+ }
+
+ @Override
+ @Test
+ public void testError()
+ {
+ IVariableNode node = getVariable("var a:Error = new Error();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Error} */ a = new Error()");
+ }
+
+ @Override
+ @Test
+ public void testEvalError()
+ {
+ IVariableNode node = getVariable("var a:EvalError = new EvalError();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {EvalError} */ a = new EvalError()");
+ }
+
+ @Override
+ @Test
+ public void testFunction()
+ {
+ IVariableNode node = getVariable("var a:Function = new Function();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Function} */ a = new Function()");
+ }
+
+ @Override
+ @Test
+ public void testJSON()
+ {
+ IVariableNode node = getVariable("var a:JSON = new JSON();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {JSON} */ a = new JSON()");
+ }
+
@Override
@Test
public void testVector()
@@ -1175,6 +1247,15 @@ public class TestRoyaleGlobalClasses extends TestGoogGlobalClasses
asBlockWalker.visitVariable(node);
assertOut("var /** @type {number} */ a = Number(\"1\")");
}
+
+ @Override
+ @Test
+ public void testObject()
+ {
+ IVariableNode node = getVariable("var a:Object = new Object();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Object} */ a = new Object()");
+ }
@Override
@Test
@@ -1384,6 +1465,15 @@ public class TestRoyaleGlobalClasses extends TestGoogGlobalClasses
assertOut("org.apache.royale.utils.Language.as(b.xml, XML).child('child').removeChild('grandchild')");
}
+ @Override
+ @Test
+ public void testXMLList()
+ {
+ IVariableNode node = getVariable("var a:XMLList = new XMLList('<!-- comment -->');");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {XMLList} */ a = new XMLList('<!-- comment -->')");
+ }
+
@Test
public void testXMLListDelete()
{
@@ -1760,6 +1850,15 @@ public class TestRoyaleGlobalClasses extends TestGoogGlobalClasses
asBlockWalker.visitForLoop(node);
assertOut("var foreachiter0_target = XMLList.conversion(a);\nfor (var foreachiter0 in foreachiter0_target.elementNames()) \n{\nvar p = foreachiter0_target[foreachiter0];\n\n var /** @type {number} */ i = (p.length()) >> 0;}\n");
}
+
+ @Override
+ @Test
+ public void testNamespace()
+ {
+ IVariableNode node = getVariable("var a:Namespace = new Namespace(\"http://example.com\");");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Namespace} */ a = new Namespace(\"http://example.com\")");
+ }
@Test
public void testNamespaceNoArg()
@@ -1784,6 +1883,15 @@ public class TestRoyaleGlobalClasses extends TestGoogGlobalClasses
asBlockWalker.visitVariable(node);
assertOut("var /** @type {Namespace} */ a = new Namespace('foo', 'bar')");
}
+
+ @Override
+ @Test
+ public void testQName()
+ {
+ IVariableNode node = getVariable("var a:QName = new QName();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {QName} */ a = new QName()");
+ }
@Test
public void testQNameNoArg()
@@ -1919,6 +2027,33 @@ public class TestRoyaleGlobalClasses extends TestGoogGlobalClasses
asBlockWalker.visitForLoop(node);
assertOut("var foreachiter0_target = a;\nfor (var foreachiter0 in foreachiter0_target && foreachiter0_target.propertyNames()) \n{\nvar p = foreachiter0_target.getProperty(foreachiter0);\n\n var /** @type {number} */ i = (p.length) >> 0;}\n");
}
+
+ @Override
+ @Test
+ public void testRangeError()
+ {
+ IVariableNode node = getVariable("var a:RangeError = new RangeError();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {RangeError} */ a = new RangeError()");
+ }
+
+ @Override
+ @Test
+ public void testReferenceError()
+ {
+ IVariableNode node = getVariable("var a:ReferenceError = new ReferenceError();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {ReferenceError} */ a = new ReferenceError()");
+ }
+
+ @Override
+ @Test
+ public void testRegExp_Literal()
+ {
+ IVariableNode node = getVariable("var a:RegExp = /test-\\d/i;");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {RegExp} */ a = /test-\\d/i");
+ }
@Test
public void testRegExp_LiteralUnicode()
@@ -2023,6 +2158,51 @@ public class TestRoyaleGlobalClasses extends TestGoogGlobalClasses
asBlockWalker.visitVariable(node);
assertOut("var /** @type {RegExp} */ a = /\\\\\\\\/g");
}
+
+ @Override
+ @Test
+ public void testSecurityError()
+ {
+ IVariableNode node = getVariable("var a:SecurityError = new SecurityError();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {SecurityError} */ a = new SecurityError()");
+ }
+
+ @Override
+ @Test
+ public void testSyntaxError()
+ {
+ IVariableNode node = getVariable("var a:SyntaxError = new SyntaxError();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {SyntaxError} */ a = new SyntaxError()");
+ }
+
+ @Override
+ @Test
+ public void testTypeError()
+ {
+ IVariableNode node = getVariable("var a:TypeError = new TypeError();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {TypeError} */ a = new TypeError()");
+ }
+
+ @Override
+ @Test
+ public void testURIError()
+ {
+ IVariableNode node = getVariable("var a:URIError = new URIError();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {URIError} */ a = new URIError()");
+ }
+
+ @Override
+ @Test
+ public void testVerifyError()
+ {
+ IVariableNode node = getVariable("var a:VerifyError = new VerifyError();");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {VerifyError} */ a = new VerifyError()");
+ }
}
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalConstants.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalConstants.java
index 71f5c6a83..7fdecac08 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalConstants.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalConstants.java
@@ -20,7 +20,7 @@
package org.apache.royale.compiler.internal.codegen.js.royale;
import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogGlobalConstants;
+import org.apache.royale.compiler.internal.codegen.as.TestGlobalConstants;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.tree.as.IVariableNode;
import org.junit.Test;
@@ -28,7 +28,7 @@ import org.junit.Test;
/**
* @author Erik de Bruin
*/
-public class TestRoyaleGlobalConstants extends TestGoogGlobalConstants
+public class TestRoyaleGlobalConstants extends TestGlobalConstants
{
@Override
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalFunctions.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalFunctions.java
index e293ad081..e80fcb4f3 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalFunctions.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalFunctions.java
@@ -20,8 +20,8 @@
package org.apache.royale.compiler.internal.codegen.js.royale;
import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogGlobalFunctions;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
+import org.apache.royale.compiler.internal.codegen.as.TestGlobalFunctions;
import org.apache.royale.compiler.internal.driver.js.goog.JSGoogConfiguration;
import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
import org.apache.royale.compiler.tree.as.IBinaryOperatorNode;
@@ -32,7 +32,7 @@ import org.junit.Test;
/**
* @author Erik de Bruin
*/
-public class TestRoyaleGlobalFunctions extends TestGoogGlobalFunctions
+public class TestRoyaleGlobalFunctions extends TestGlobalFunctions
{
@Override
public void setUp()
@@ -100,6 +100,78 @@ public class TestRoyaleGlobalFunctions extends TestGoogGlobalFunctions
asBlockWalker.visitVariable(node);
assertOut("var /** @type {Array} */ a = Array(['Hello', 'World'])");
}
+
+ @Override
+ @Test
+ public void testBoolean()
+ {
+ IVariableNode node = getVariable("var a:Boolean = Boolean(1);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {boolean} */ a = Boolean(1)");
+ }
+
+ @Override
+ @Test
+ public void testDecodeURI()
+ {
+ IVariableNode node = getVariable("var a:String = decodeURI('http://whatever.com');");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {string} */ a = decodeURI('http://whatever.com')");
+ }
+
+ @Override
+ @Test
+ public void testDecodeURIComponent()
+ {
+ IVariableNode node = getVariable("var a:String = decodeURIComponent('http://whatever.com');");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {string} */ a = decodeURIComponent('http://whatever.com')");
+ }
+
+ @Override
+ @Test
+ public void testEncodeURI()
+ {
+ IVariableNode node = getVariable("var a:String = encodeURI('http://whatever.com');");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {string} */ a = encodeURI('http://whatever.com')");
+ }
+
+ @Override
+ @Test
+ public void testEncodeURIComponent()
+ {
+ IVariableNode node = getVariable("var a:String = encodeURIComponent('http://whatever.com');");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {string} */ a = encodeURIComponent('http://whatever.com')");
+ }
+
+ @Override
+ @Test
+ public void testEscape()
+ {
+ IVariableNode node = getVariable("var a:String = escape('http://whatever.com');");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {string} */ a = escape('http://whatever.com')");
+ }
+
+ @Override
+ @Test
+ public void testIsFinite()
+ {
+ IVariableNode node = getVariable("var a:Boolean = isFinite(1000000.9);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {boolean} */ a = isFinite(1000000.9)");
+ }
+
+ @Override
+ @Test
+ public void testIsNaN()
+ {
+ IVariableNode node = getVariable("var a:Boolean = isNaN(NaN);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {boolean} */ a = isNaN(NaN)");
+ }
@Override
@Test
@@ -110,6 +182,15 @@ public class TestRoyaleGlobalFunctions extends TestGoogGlobalFunctions
assertOut("var /** @type {Object} */ a = org.apache.royale.utils.Language.resolveUncertain(Object(\"1\"))");
}
+ @Override
+ @Test
+ public void testParseFloat()
+ {
+ IVariableNode node = getVariable("var a:Number = parseFloat(\"1.8\");");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {number} */ a = parseFloat(\"1.8\")");
+ }
+
@Test
public void testParseInt()
{
@@ -143,6 +224,15 @@ public class TestRoyaleGlobalFunctions extends TestGoogGlobalFunctions
assertOut("var /** @type {number} */ a = org.apache.royale.utils.Language._int(\"123\")");
}
+ @Override
+ @Test
+ public void testString()
+ {
+ IVariableNode node = getVariable("var a:String = String(100);");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {string} */ a = String(100)");
+ }
+
@Override
@Test
public void testTrace()
@@ -162,6 +252,7 @@ public class TestRoyaleGlobalFunctions extends TestGoogGlobalFunctions
assertOut("var /** @type {number} */ a = org.apache.royale.utils.Language.uint(-100)");
}
+ //isXMLName is in E4X, which is not supported by JavaScript
@Override
@Test
public void testIsXMLName()
@@ -171,6 +262,24 @@ public class TestRoyaleGlobalFunctions extends TestGoogGlobalFunctions
assertOut("var /** @type {boolean} */ a = !!(isXMLName(\"?\"))");
}
+ @Override
+ @Test
+ public void testNumber()
+ {
+ IVariableNode node = getVariable("var a:Number = Number(\"1\");");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {number} */ a = Number(\"1\")");
+ }
+
+ @Override
+ @Test
+ public void testUnescape()
+ {
+ IVariableNode node = getVariable("var a:String = unescape('%25');");
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {string} */ a = unescape('%25')");
+ }
+
@Override
@Test
public void testVector()
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleInterface.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleInterface.java
index 3cadf615d..3d055f8b4 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleInterface.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleInterface.java
@@ -20,7 +20,7 @@
package org.apache.royale.compiler.internal.codegen.js.royale;
import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogInterface;
+import org.apache.royale.compiler.internal.codegen.as.TestInterface;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.tree.as.IInterfaceNode;
import org.junit.Test;
@@ -32,7 +32,7 @@ import org.junit.Test;
* @author Michael Schmalle
* @author Erik de Bruin
*/
-public class TestRoyaleInterface extends TestGoogInterface
+public class TestRoyaleInterface extends TestInterface
{
@Override
@Test
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java
index 1aff0c2b7..8a383fee6 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java
@@ -20,7 +20,7 @@
package org.apache.royale.compiler.internal.codegen.js.royale;
import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogMethodMembers;
+import org.apache.royale.compiler.internal.codegen.as.TestMethodMembers;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.tree.as.IClassNode;
import org.apache.royale.compiler.tree.as.IFunctionNode;
@@ -29,8 +29,16 @@ import org.junit.Test;
/**
* @author Erik de Bruin
*/
-public class TestRoyaleMethodMembers extends TestGoogMethodMembers
+public class TestRoyaleMethodMembers extends TestMethodMembers
{
+ @Override
+ @Test
+ public void testMethod()
+ {
+ IFunctionNode node = getMethod("function foo(){}");
+ asBlockWalker.visitFunction(node);
+ assertOut("RoyaleTest_A.prototype.foo = function() {\n}");
+ }
@Override
@Test
@@ -107,7 +115,6 @@ public class TestRoyaleMethodMembers extends TestGoogMethodMembers
// Doc Specific Tests
//--------------------------------------------------------------------------
- @Override
@Test
public void testConstructor_withThisInBody()
{
@@ -124,7 +131,6 @@ public class TestRoyaleMethodMembers extends TestGoogMethodMembers
assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function() {\n this.foo();\n};\n\n\n/**\n * @private\n * @return {string}\n */\nRoyaleTest_A.prototype.foo = function() {\n return '';\n};");
}
- @Override
@Test
public void testMethod_withThisInBody()
{
@@ -141,7 +147,6 @@ public class TestRoyaleMethodMembers extends TestGoogMethodMembers
assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function() {\n};\n\n\n/**\n * @private\n * @type {string}\n */\nRoyaleTest_A.prototype.baz;\n\n\n/**\n * @private\n * @return {string}\n */\nRoyaleTest_A.prototype.foo = function() {\n return this.baz;\n};");
}
- @Override
@Test
public void testMethod_withThisInBodyComplex()
{
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyalePackage.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyalePackage.java
index 8b9af2f49..c464fd207 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyalePackage.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyalePackage.java
@@ -22,7 +22,7 @@ package org.apache.royale.compiler.internal.codegen.js.royale;
import java.util.ArrayList;
import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogPackage;
+import org.apache.royale.compiler.internal.codegen.as.TestPackage;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.internal.driver.js.goog.JSGoogConfiguration;
import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
@@ -32,7 +32,7 @@ import org.junit.Test;
/**
* @author Erik de Bruin
*/
-public class TestRoyalePackage extends TestGoogPackage
+public class TestRoyalePackage extends TestPackage
{
@Override
public void setUp()
@@ -50,6 +50,32 @@ public class TestRoyalePackage extends TestGoogPackage
((RoyaleJSProject)project).config = config;
super.setUp();
}
+
+ @Override
+ @Test
+ public void testPackage_Simple()
+ {
+ IFileNode node = compileAS("package{}");
+ asBlockWalker.visitFile(node);
+ assertOut("");
+ }
+
+ @Test
+ public void testPackage_SimpleName()
+ {
+ IFileNode node = compileAS("package foo {}");
+ asBlockWalker.visitFile(node);
+ assertOut("");
+ }
+
+ @Override
+ @Test
+ public void testPackage_Name()
+ {
+ IFileNode node = compileAS("package foo.bar.baz {}");
+ asBlockWalker.visitFile(node);
+ assertOut("");
+ }
@Override
@Test
@@ -215,7 +241,6 @@ public class TestRoyalePackage extends TestGoogPackage
);
}
- @Override
@Test
public void testPackageQualified_ClassBodyMethodContents()
{
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleProject.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleProject.java
index e70f2124f..1159b5aab 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleProject.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleProject.java
@@ -21,6 +21,7 @@ package org.apache.royale.compiler.internal.codegen.js.royale;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
import java.io.File;
import java.util.ArrayList;
@@ -28,13 +29,18 @@ import java.util.Collection;
import java.util.List;
import junit.framework.Assert;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.FileFileFilter;
+import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.royale.compiler.driver.IBackend;
import org.apache.royale.compiler.exceptions.ConfigurationException;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogProject;
import org.apache.royale.compiler.internal.config.TargetSettings;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.internal.driver.js.goog.JSGoogConfiguration;
import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
+import org.apache.royale.compiler.internal.test.ASTestBase;
import org.apache.royale.utils.FilenameNormalization;
import org.apache.royale.utils.ITestAdapter;
import org.apache.royale.utils.TestAdapterFactory;
@@ -47,7 +53,7 @@ import org.junit.Test;
*
* @author Erik de Bruin
*/
-public class TestRoyaleProject extends TestGoogProject
+public class TestRoyaleProject extends ASTestBase
{
private static ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter();
@@ -63,12 +69,20 @@ public class TestRoyaleProject extends TestGoogProject
project.config = new JSGoogConfiguration();
super.setUp();
}
-
- @Ignore
+
@Test
public void test_imports()
{
- // crude bypass to allow for successful inheritance
+ String testDirPath = projectDirPath + "/imports";
+
+ String fileName = "Case";
+
+ sourcePath = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
+ projectDirPath + "/imports").getPath();
+
+ List<String> compiledFileNames = compileProject(fileName, testDirPath);
+
+ assertProjectOut(compiledFileNames, testDirPath);
}
@Test
@@ -353,6 +367,65 @@ public class TestRoyaleProject extends TestGoogProject
((RoyaleJSProject)project).unitTestExterns = externs;
}
+ protected void assertProjectOut(List<String> compiledFileNames,
+ String testDirPath)
+ {
+ if (compiledFileNames.size() == 0)
+ {
+ fail("Expected compiled files");
+ }
+ for (String compiledFileName : compiledFileNames)
+ {
+ String compiledFilePath = tempDir.getAbsolutePath()
+ + File.separator + testDirPath + File.separator
+ + compiledFileName + "_output" + "."
+ + backend.getOutputExtension();
+ String compiledResult = readCodeFile(new File(compiledFilePath));
+
+ //System.out.println(compiledResult);
+
+ String expectedFilePath = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
+ testDirPath + "/" + compiledFileName + "_result" + "." + backend.getOutputExtension()).getPath();
+ String expectedResult = readCodeFile(new File(expectedFilePath));
+ /*if (!compiledResult.equals(expectedResult)) {
+ System.out.println("expected\n"+expectedResult);
+ System.out.println("got\n"+compiledResult);
+ }*/
+ assertThat(compiledResult, is(expectedResult));
+ }
+ }
+
+ protected void assertPublishedProjectOut(String projectFolderPath,
+ String projectName)
+ {
+ String outputFolderName = tempDir + "/" + projectName + "/bin/js-debug";
+ IOFileFilter jsFilter = FileFilterUtils.and(FileFileFilter.FILE,
+ FileFilterUtils.suffixFileFilter("js"));
+ IOFileFilter htmlFilter = FileFilterUtils.and(FileFileFilter.FILE,
+ FileFilterUtils.suffixFileFilter("html"));
+ IOFileFilter resultsFilter = FileFilterUtils.or(jsFilter, htmlFilter);
+ File outputFolder = new File(outputFolderName);
+ File projectFolder = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(), projectFolderPath);
+ projectFolderPath = projectFolder.getAbsolutePath();
+ Collection<File> files = FileUtils.listFiles(projectFolder, resultsFilter, null);
+ for (File resultFile : files)
+ {
+ String compiledFilePath = resultFile.getAbsolutePath();
+ if (compiledFilePath.startsWith(projectFolderPath))
+ compiledFilePath = compiledFilePath.substring(projectFolderPath.length());
+ compiledFilePath = compiledFilePath.replace("_result", "");
+ File compiledFile = new File(outputFolder, compiledFilePath);
+ String compiledResult = readCodeFile(compiledFile);
+
+ String expectedResult = readCodeFile(resultFile);
+ /*if (!compiledResult.equals(expectedResult)) {
+ System.out.println("expected\n"+expectedResult);
+ System.out.println("got\n"+compiledResult);
+ }*/
+ assertThat(compiledResult, is(expectedResult));
+ }
+ }
+
@Override
protected IBackend createBackend()
{
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java
index 46d66dea6..ba1cb8ddd 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java
@@ -20,7 +20,7 @@
package org.apache.royale.compiler.internal.codegen.js.royale;
import org.apache.royale.compiler.driver.IBackend;
-import org.apache.royale.compiler.internal.codegen.js.goog.TestGoogStatements;
+import org.apache.royale.compiler.internal.codegen.as.TestStatements;
import org.apache.royale.compiler.internal.driver.js.goog.JSGoogConfiguration;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
@@ -37,13 +37,12 @@ import org.apache.royale.compiler.tree.as.ITryNode;
import org.apache.royale.compiler.tree.as.IVariableNode;
import org.apache.royale.compiler.tree.as.IWhileLoopNode;
import org.apache.royale.compiler.tree.as.IWithNode;
-import org.junit.Ignore;
import org.junit.Test;
/**
* @author Erik de Bruin
*/
-public class TestRoyaleStatements extends TestGoogStatements
+public class TestRoyaleStatements extends TestStatements
{
@Override
public void setUp()
@@ -80,6 +79,49 @@ public class TestRoyaleStatements extends TestGoogStatements
asBlockWalker.visitLiteral(node);
assertOut("{myConst:RoyaleTest_A.myConst}");
}
+ //----------------------------------
+ // var declaration
+ //----------------------------------
+
+ @Override
+ @Test
+ public void testVarDeclaration()
+ {
+ IVariableNode node = (IVariableNode) getNode("var a;",
+ IVariableNode.class);
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {*} */ a");
+ }
+
+ @Override
+ @Test
+ public void testVarDeclaration_withTypeAssignedValue()
+ {
+ IVariableNode node = (IVariableNode) getNode("var a:int = 42;",
+ IVariableNode.class);
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {number} */ a = 42");
+ }
+
+ @Override
+ @Test
+ public void testVarDeclaration_withTypeAssignedValueComplex()
+ {
+ IVariableNode node = (IVariableNode) getNode(
+ "class A { public function b():void { var a:Foo = new Foo(42, 'goo');}} class Foo {}", IVariableNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Foo} */ a = new Foo(42, 'goo')");
+ }
+
+ @Override
+ @Test
+ public void testVarDeclaration_withList()
+ {
+ IVariableNode node = (IVariableNode) getNode(
+ "var a:int = 4, b:int = 11, c:int = 42;", IVariableNode.class);
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {number} */ a = 4, /** @type {number} */ b = 11, /** @type {number} */ c = 42");
+ }
@Test
public void testVarDeclaration_withTypeAssignedStringWithNewLine()
@@ -339,7 +381,6 @@ public class TestRoyaleStatements extends TestGoogStatements
assertOut("for (var /** @type {number} */ i = 0; i < len; i++)\n break;");
}
- @Override
@Test
public void testVisitFor_1c()
{
@@ -696,7 +737,15 @@ public class TestRoyaleStatements extends TestGoogStatements
assertOut("");
}
- @Override
+ @Test
+ public void testVisitIf_NoBody()
+ {
+ IIfNode node = (IIfNode) getNode(
+ "if (a) ;", IIfNode.class);
+ asBlockWalker.visitIf(node);
+ assertOut("if (a) {}\n");
+ }
+
@Test
public void testVisitElseIf_NoBody()
{
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/HelloWorld.as b/compiler-jx/src/test/resources/amd/simple-project/src/HelloWorld.as
deleted file mode 100644
index 19d82f879..000000000
--- a/compiler-jx/src/test/resources/amd/simple-project/src/HelloWorld.as
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package {
-
-import com.acme.A;
-import com.acme.B;
-import com.acme.I;
-import com.acme.sub.IOther;
-import com.acme.sub.ISub;
-
-//noinspection JSUnusedGlobalSymbols
-public class HelloWorld {
-
- //noinspection JSUnusedGlobalSymbols
- public function HelloWorld() {
- trace(B.now);
- trace(B.nowPlusOne());
-
- var b:B = new B('hello ');
- trace("b = new B('hello '):", b);
- trace("b.foo(3):", b.foo(3));
- trace("b.baz():", b.baz());
- trace("b is A:", b is A);
- trace("b is B:", b is B);
- trace("b is I:", b is I);
- trace("b is ISub:", b is ISub);
- trace("b is IOther:", b is IOther);
-
- var a:A = new A('123');
- trace("a = new A('123'):", a);
- trace("a is A:", a is A);
- trace("a is B:", a is B);
- trace("a is I:", a is I);
- trace("a is ISub:", a is ISub);
- trace("a is IOther:", a is IOther);
- }
-}
-}
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/A.as b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/A.as
deleted file mode 100644
index a6ca41e2c..000000000
--- a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/A.as
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.acme {
-public class A implements I {
-
- public function A(msg:String) {
- this.msg = msg;
- }
-
- private var _msg:int;
-
- public function get msg():String {
- return String(this._msg);
- }
-
- trace("Class A is initialized!");
-
- public function set msg(value:String):void {
- this._msg = parseInt(value, 10);
- }
-
- private function secret(n) {
- return msg + n;
- }
-
- public function foo(x) {
- return this.secret(A.bar(x));
- }
-
- public function baz() {
- var tmp = this.secret;
- return tmp("-bound");
- }
-
- public static function bar(x) {
- return x + 1;
- }
-
-}
-}
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/B.as b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/B.as
deleted file mode 100644
index eac2c6062..000000000
--- a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/B.as
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.acme {
-import com.acme.sub.IOther;
-import com.acme.sub.ISub;
-
-public class B extends A implements IOther, ISub {
-
- public static function nowPlusOne() {
- return new Date(B.now.getTime() + 60*60*1000);
- }
-
- public function B(msg, count) {
- super(msg);
- this.count = count;
- trace("now: " + B.now);
- }
-
- public var count = 0;
-
- public var barfoo = A.bar(3);
-
- public override function foo(x) {
- return super.foo(x + 2) + "-sub";
- }
-
- public static var now = new Date();
-
-}
-}
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/I.as b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/I.as
deleted file mode 100644
index 189304bd4..000000000
--- a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/I.as
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.acme {
-public interface I {
-
- function get msg():String;
-
-}
-}
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/IOther.as b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/IOther.as
deleted file mode 100644
index ebe3de1d4..000000000
--- a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/IOther.as
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.acme.sub {
-
-public interface IOther {
-
-}
-}
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/ISub.as b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/ISub.as
deleted file mode 100644
index 23d80a77d..000000000
--- a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/ISub.as
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.acme.sub {
-import com.acme.I;
-
-public interface ISub extends I {
-
- function foo(x);
-
-}
-}
diff --git a/compiler-jx/src/test/resources/goog/projects/imports/comps/A_result.js b/compiler-jx/src/test/resources/goog/projects/imports/comps/A_result.js
deleted file mode 100644
index 5d128a5bb..000000000
--- a/compiler-jx/src/test/resources/goog/projects/imports/comps/A_result.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-goog.provide('comps.A');
-
-/**
- * @constructor
- */
-comps.A = function() {
- var self = this;
- var /** @type {comps.B} */ foo = new B();
-};
diff --git a/compiler-jx/src/test/resources/goog/files/call-super.as b/compiler-jx/src/test/resources/royale/files/call-super.as
similarity index 100%
rename from compiler-jx/src/test/resources/goog/files/call-super.as
rename to compiler-jx/src/test/resources/royale/files/call-super.as
diff --git a/compiler-jx/src/test/resources/goog/files/call-super_result.js b/compiler-jx/src/test/resources/royale/files/call-super_result.js
similarity index 100%
rename from compiler-jx/src/test/resources/goog/files/call-super_result.js
rename to compiler-jx/src/test/resources/royale/files/call-super_result.js
diff --git a/compiler-jx/src/test/resources/goog/files/get-set.as b/compiler-jx/src/test/resources/royale/files/get-set.as
similarity index 100%
rename from compiler-jx/src/test/resources/goog/files/get-set.as
rename to compiler-jx/src/test/resources/royale/files/get-set.as
diff --git a/compiler-jx/src/test/resources/goog/files/get-set_result.js b/compiler-jx/src/test/resources/royale/files/get-set_result.js
similarity index 100%
rename from compiler-jx/src/test/resources/goog/files/get-set_result.js
rename to compiler-jx/src/test/resources/royale/files/get-set_result.js
diff --git a/compiler-jx/src/test/resources/goog/files/input.as b/compiler-jx/src/test/resources/royale/files/input.as
similarity index 100%
rename from compiler-jx/src/test/resources/goog/files/input.as
rename to compiler-jx/src/test/resources/royale/files/input.as
diff --git a/compiler-jx/src/test/resources/goog/files/output.js b/compiler-jx/src/test/resources/royale/files/output.js
similarity index 100%
rename from compiler-jx/src/test/resources/goog/files/output.js
rename to compiler-jx/src/test/resources/royale/files/output.js
diff --git a/compiler-jx/src/test/resources/goog/files/poc.as b/compiler-jx/src/test/resources/royale/files/poc.as
similarity index 100%
rename from compiler-jx/src/test/resources/goog/files/poc.as
rename to compiler-jx/src/test/resources/royale/files/poc.as
diff --git a/compiler-jx/src/test/resources/goog/files/poc_result.js b/compiler-jx/src/test/resources/royale/files/poc_result.js
similarity index 100%
rename from compiler-jx/src/test/resources/goog/files/poc_result.js
rename to compiler-jx/src/test/resources/royale/files/poc_result.js
diff --git a/compiler-jx/src/test/resources/goog/files/qualify-new-object.as b/compiler-jx/src/test/resources/royale/files/qualify-new-object.as
similarity index 100%
rename from compiler-jx/src/test/resources/goog/files/qualify-new-object.as
rename to compiler-jx/src/test/resources/royale/files/qualify-new-object.as
diff --git a/compiler-jx/src/test/resources/goog/files/qualify-new-object_result.js b/compiler-jx/src/test/resources/royale/files/qualify-new-object_result.js
similarity index 100%
rename from compiler-jx/src/test/resources/goog/files/qualify-new-object_result.js
rename to compiler-jx/src/test/resources/royale/files/qualify-new-object_result.js
diff --git a/compiler-jx/src/test/resources/goog/projects/imports/Case.as b/compiler-jx/src/test/resources/royale/projects/imports/Case.as
similarity index 100%
rename from compiler-jx/src/test/resources/goog/projects/imports/Case.as
rename to compiler-jx/src/test/resources/royale/projects/imports/Case.as
diff --git a/compiler-jx/src/test/resources/goog/projects/imports/Case_result.js b/compiler-jx/src/test/resources/royale/projects/imports/Case_result.js
similarity index 51%
rename from compiler-jx/src/test/resources/goog/projects/imports/Case_result.js
rename to compiler-jx/src/test/resources/royale/projects/imports/Case_result.js
index 2d090e949..ba76b389d 100644
--- a/compiler-jx/src/test/resources/goog/projects/imports/Case_result.js
+++ b/compiler-jx/src/test/resources/royale/projects/imports/Case_result.js
@@ -11,14 +11,53 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+ * Case
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes|accessControls}
+ */
+
goog.provide('Case');
goog.require('comps.A');
+
+
/**
* @constructor
*/
Case = function() {
- var self = this;
- var /** @type {comps.A} */ bar = new comps.A();
+ var /** @type {comps.A} */ bar = new comps.A();
};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+Case.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'Case', qName: 'Case', kind: 'class' }] };
+
+
+
+/**
+ * Reflection
+ *
+ * @return {Object.<string, Function>}
+ */
+Case.prototype.ROYALE_REFLECTION_INFO = function () {
+ return {
+ methods: function () {
+ return {
+ 'Case': { type: '', declaredBy: 'Case'}
+ };
+ }
+ };
+};
+/**
+ * @const
+ * @type {number}
+ */
+Case.prototype.ROYALE_COMPILE_FLAGS = 9;
\ No newline at end of file
diff --git a/compiler-jx/src/test/resources/goog/projects/imports/comps/A.as b/compiler-jx/src/test/resources/royale/projects/imports/comps/A.as
similarity index 100%
rename from compiler-jx/src/test/resources/goog/projects/imports/comps/A.as
rename to compiler-jx/src/test/resources/royale/projects/imports/comps/A.as
diff --git a/compiler-jx/src/test/resources/royale/projects/imports/comps/A_result.js b/compiler-jx/src/test/resources/royale/projects/imports/comps/A_result.js
new file mode 100644
index 000000000..a5baa34ba
--- /dev/null
+++ b/compiler-jx/src/test/resources/royale/projects/imports/comps/A_result.js
@@ -0,0 +1,63 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * comps.A
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes|accessControls}
+ */
+
+goog.provide('comps.A');
+
+goog.require('comps.B');
+
+
+
+/**
+ * @constructor
+ */
+comps.A = function() {
+ var /** @type {comps.B} */ foo = new comps.B();
+};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+comps.A.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'A', qName: 'comps.A', kind: 'class' }] };
+
+
+
+/**
+ * Reflection
+ *
+ * @return {Object.<string, Function>}
+ */
+comps.A.prototype.ROYALE_REFLECTION_INFO = function () {
+ return {
+ methods: function () {
+ return {
+ 'A': { type: '', declaredBy: 'comps.A'}
+ };
+ }
+ };
+};
+/**
+ * @const
+ * @type {number}
+ */
+comps.A.prototype.ROYALE_COMPILE_FLAGS = 9;
\ No newline at end of file
diff --git a/compiler-jx/src/test/resources/goog/projects/imports/comps/B.as b/compiler-jx/src/test/resources/royale/projects/imports/comps/B.as
similarity index 100%
rename from compiler-jx/src/test/resources/goog/projects/imports/comps/B.as
rename to compiler-jx/src/test/resources/royale/projects/imports/comps/B.as
diff --git a/compiler-jx/src/test/resources/goog/projects/imports/comps/B_result.js b/compiler-jx/src/test/resources/royale/projects/imports/comps/B_result.js
similarity index 52%
rename from compiler-jx/src/test/resources/goog/projects/imports/comps/B_result.js
rename to compiler-jx/src/test/resources/royale/projects/imports/comps/B_result.js
index 643887e65..82c9bfb33 100644
--- a/compiler-jx/src/test/resources/goog/projects/imports/comps/B_result.js
+++ b/compiler-jx/src/test/resources/royale/projects/imports/comps/B_result.js
@@ -11,10 +11,50 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+ * comps.B
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes|accessControls}
+ */
+
goog.provide('comps.B');
+
+
/**
* @constructor
*/
comps.B = function() {
};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+comps.B.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'B', qName: 'comps.B', kind: 'class' }] };
+
+
+
+/**
+ * Reflection
+ *
+ * @return {Object.<string, Function>}
+ */
+comps.B.prototype.ROYALE_REFLECTION_INFO = function () {
+ return {
+ methods: function () {
+ return {
+ 'B': { type: '', declaredBy: 'comps.B'}
+ };
+ }
+ };
+};
+/**
+ * @const
+ * @type {number}
+ */
+comps.B.prototype.ROYALE_COMPILE_FLAGS = 9;
\ No newline at end of file