You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jo...@apache.org on 2016/04/30 01:18:52 UTC
[5/8] git commit: [flex-falcon] [refs/heads/develop] - fixed typo in
test class names
fixed typo in test class names
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/6993a66e
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/6993a66e
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/6993a66e
Branch: refs/heads/develop
Commit: 6993a66e29c9de4658dfed68ae4dca4ba0b7c70c
Parents: b20a5d5
Author: Josh Tynjala <jo...@gmail.com>
Authored: Fri Apr 29 14:44:32 2016 -0700
Committer: Josh Tynjala <jo...@gmail.com>
Committed: Fri Apr 29 14:44:32 2016 -0700
----------------------------------------------------------------------
.../internal/codegen/js/amd/TestAMDEmiter.java | 144 --------
.../internal/codegen/js/amd/TestAMDEmitter.java | 144 ++++++++
.../codegen/js/flexjs/TestFlexJSEmiter.java | 364 -------------------
.../codegen/js/flexjs/TestFlexJSEmitter.java | 364 +++++++++++++++++++
.../codegen/js/goog/TestGoogEmiter.java | 153 --------
.../codegen/js/goog/TestGoogEmitter.java | 153 ++++++++
6 files changed, 661 insertions(+), 661 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6993a66e/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/amd/TestAMDEmiter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/amd/TestAMDEmiter.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/amd/TestAMDEmiter.java
deleted file mode 100644
index 71e35dc..0000000
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/amd/TestAMDEmiter.java
+++ /dev/null
@@ -1,144 +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.flex.compiler.internal.codegen.js.amd;
-
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.driver.js.amd.AMDBackend;
-import org.apache.flex.compiler.internal.test.ASTestBase;
-import org.junit.Test;
-
-/**
- * This class tests the production of 'AMD' 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 TestAMDEmiter extends ASTestBase
-{
- // TODO (mschmalle) these tests were all ignored... ?
-
- @Test
- public void testSimple()
- {
-// String code = "package com.example.components {"
-// + "import org.apache.flex.html.staticControls.TextButton;"
-// + "public class MyTextButton extends TextButton {"
-// + "public function MyTextButton() {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("package com.example.components {\n\tpublic class MyTextButton extends TextButton {\n\t\tcom.example.components.MyTextButton = function() {\n\t\t\tif (foo() != 42) {\n\t\t\t\tbar();\n\t\t\t}\n\t\t}\n\t\tprivate var _privateVar:String = \"do \";\n\t\tpublic var publicProperty:Number = 100;\n\t\tcom.example.components.MyTextButton.prototype.myFunction = function(value) {\n\t\t\treturn \"Don't \" + _privateVar + value;\n\t\t}\n\t}\n}");
- }
-
- @Test
- public void testSimpleMethod()
- {
-// IFunctionNode node = getMethod("function method1():void{\n}");
-// asBlockWalker.visitFunction(node);
-// assertOut("A.prototype.method1 = function() {\n}");
- }
-
- @Test
- public void testSimpleParameterReturnType()
- {
-// IFunctionNode node = getMethod("function method1(bar:int):int{\n}");
-// asBlockWalker.visitFunction(node);
-// assertOut("A.prototype.method1 = function(bar) {\n}");
- }
-
- @Test
- public void testSimpleMultipleParameter()
- {
-// IFunctionNode node = getMethod("function method1(bar:int, baz:String, goo:A):void{\n}");
-// asBlockWalker.visitFunction(node);
-// assertOut("A.prototype.method1 = function(bar, baz, goo) {\n}");
- }
-
- @Test
- public void testDefaultParameter()
- {
-// /*
-// foo.bar.A.method1 = function(p1, p2, p3, p4) {
-// if (arguments.length < 4) {
-// if (arguments.length < 3) {
-// p3 = 3;
-// }
-// p4 = 4;
-// }
-// return p1 + p2 + p3 + p4;
-// }
-// */
-// IFunctionNode node = getMethod("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{return p1 + p2 + p3 + p4;}");
-// asBlockWalker.visitFunction(node);
-// assertOut("A.prototype.method1 = function(p1, p2, p3, p4) {\n\tif (arguments.length < 4) "
-// + "{\n\t\tif (arguments.length < 3) {\n\t\t\tp3 = 3;\n\t\t}\n\t\tp4 = 4;\n\t}"
-// + "\n\treturn p1 + p2 + p3 + p4;\n}");
- }
-
- @Test
- public void testDefaultParameter_Body()
- {
-// /*
-// foo.bar.A.method1 = function(bar, bax) {
-// if (arguments.length < 2) {
-// if (arguments.length < 1) {
-// bar = 42;
-// }
-// bax = 4;
-// }
-// }
-// */
-// IFunctionNode node = getMethod("function method1(bar:int = 42, bax:int = 4):void{if (a) foo();}");
-// asBlockWalker.visitFunction(node);
-// assertOut("A.prototype.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
-// + "if (arguments.length < 1) {\n\t\t\tbar = 42;\n\t\t}\n\t\tbax = 4;\n\t}\n\t"
-// + "if (a)\n\t\tfoo();\n}");
- }
-
- @Test
- public void testDefaultParameter_NoBody_Alternate()
- {
-// /*
-// foo.bar.A.method1 = function(bar, bax) {
-// if (arguments.length < 2) {
-// if (arguments.length < 1) {
-// bar = 42;
-// }
-// bax = 4;
-// }
-// }
-// */
-// IFunctionNode node = getMethod("function method1(bar:int = 42, bax:int = 4):void{\n}");
-// asBlockWalker.visitFunction(node);
-// assertOut("A.prototype.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
-// + "if (arguments.length < 1) {\n\t\t\tbar = 42;\n\t\t}\n\t\tbax = 4;\n\t}\n}");
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new AMDBackend();
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6993a66e/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/amd/TestAMDEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/amd/TestAMDEmitter.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/amd/TestAMDEmitter.java
new file mode 100644
index 0000000..dd7e5eb
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/amd/TestAMDEmitter.java
@@ -0,0 +1,144 @@
+/*
+ *
+ * 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.flex.compiler.internal.codegen.js.amd;
+
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.driver.js.amd.AMDBackend;
+import org.apache.flex.compiler.internal.test.ASTestBase;
+import org.junit.Test;
+
+/**
+ * This class tests the production of 'AMD' 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 TestAMDEmitter extends ASTestBase
+{
+ // TODO (mschmalle) these tests were all ignored... ?
+
+ @Test
+ public void testSimple()
+ {
+// String code = "package com.example.components {"
+// + "import org.apache.flex.html.staticControls.TextButton;"
+// + "public class MyTextButton extends TextButton {"
+// + "public function MyTextButton() {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("package com.example.components {\n\tpublic class MyTextButton extends TextButton {\n\t\tcom.example.components.MyTextButton = function() {\n\t\t\tif (foo() != 42) {\n\t\t\t\tbar();\n\t\t\t}\n\t\t}\n\t\tprivate var _privateVar:String = \"do \";\n\t\tpublic var publicProperty:Number = 100;\n\t\tcom.example.components.MyTextButton.prototype.myFunction = function(value) {\n\t\t\treturn \"Don't \" + _privateVar + value;\n\t\t}\n\t}\n}");
+ }
+
+ @Test
+ public void testSimpleMethod()
+ {
+// IFunctionNode node = getMethod("function method1():void{\n}");
+// asBlockWalker.visitFunction(node);
+// assertOut("A.prototype.method1 = function() {\n}");
+ }
+
+ @Test
+ public void testSimpleParameterReturnType()
+ {
+// IFunctionNode node = getMethod("function method1(bar:int):int{\n}");
+// asBlockWalker.visitFunction(node);
+// assertOut("A.prototype.method1 = function(bar) {\n}");
+ }
+
+ @Test
+ public void testSimpleMultipleParameter()
+ {
+// IFunctionNode node = getMethod("function method1(bar:int, baz:String, goo:A):void{\n}");
+// asBlockWalker.visitFunction(node);
+// assertOut("A.prototype.method1 = function(bar, baz, goo) {\n}");
+ }
+
+ @Test
+ public void testDefaultParameter()
+ {
+// /*
+// foo.bar.A.method1 = function(p1, p2, p3, p4) {
+// if (arguments.length < 4) {
+// if (arguments.length < 3) {
+// p3 = 3;
+// }
+// p4 = 4;
+// }
+// return p1 + p2 + p3 + p4;
+// }
+// */
+// IFunctionNode node = getMethod("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{return p1 + p2 + p3 + p4;}");
+// asBlockWalker.visitFunction(node);
+// assertOut("A.prototype.method1 = function(p1, p2, p3, p4) {\n\tif (arguments.length < 4) "
+// + "{\n\t\tif (arguments.length < 3) {\n\t\t\tp3 = 3;\n\t\t}\n\t\tp4 = 4;\n\t}"
+// + "\n\treturn p1 + p2 + p3 + p4;\n}");
+ }
+
+ @Test
+ public void testDefaultParameter_Body()
+ {
+// /*
+// foo.bar.A.method1 = function(bar, bax) {
+// if (arguments.length < 2) {
+// if (arguments.length < 1) {
+// bar = 42;
+// }
+// bax = 4;
+// }
+// }
+// */
+// IFunctionNode node = getMethod("function method1(bar:int = 42, bax:int = 4):void{if (a) foo();}");
+// asBlockWalker.visitFunction(node);
+// assertOut("A.prototype.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
+// + "if (arguments.length < 1) {\n\t\t\tbar = 42;\n\t\t}\n\t\tbax = 4;\n\t}\n\t"
+// + "if (a)\n\t\tfoo();\n}");
+ }
+
+ @Test
+ public void testDefaultParameter_NoBody_Alternate()
+ {
+// /*
+// foo.bar.A.method1 = function(bar, bax) {
+// if (arguments.length < 2) {
+// if (arguments.length < 1) {
+// bar = 42;
+// }
+// bax = 4;
+// }
+// }
+// */
+// IFunctionNode node = getMethod("function method1(bar:int = 42, bax:int = 4):void{\n}");
+// asBlockWalker.visitFunction(node);
+// assertOut("A.prototype.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
+// + "if (arguments.length < 1) {\n\t\t\tbar = 42;\n\t\t}\n\t\tbax = 4;\n\t}\n}");
+ }
+
+ @Override
+ protected IBackend createBackend()
+ {
+ return new AMDBackend();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6993a66e/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmiter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmiter.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmiter.java
deleted file mode 100644
index c02200e..0000000
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmiter.java
+++ /dev/null
@@ -1,364 +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.flex.compiler.internal.codegen.js.flexjs;
-
-import org.apache.flex.compiler.clients.MXMLJSC;
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogEmiter;
-import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
-import org.apache.flex.compiler.internal.parsing.as.FlexJSASDocDelegate;
-import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.compiler.tree.as.IFileNode;
-import org.apache.flex.compiler.tree.as.IFunctionNode;
-import org.junit.Test;
-
-/**
- * @author Erik de Bruin
- */
-public class TestFlexJSEmiter extends TestGoogEmiter
-{
- @Override
- public void setUp()
- {
- project = new FlexJSProject(workspace);
-
- super.setUp();
- }
-
- @Override
- @Test
- public void testSimple()
- {
- String code = "package com.example.components {"
- + "import goog.events.EventTarget;"
- + "public class MyEventTarget extends EventTarget {"
- + "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);
- assertOutWithMetadata("/**\n" +
- " * com.example.components.MyEventTarget\n" +
- " *\n" +
- " * @fileoverview\n" +
- " *\n" +
- " * @suppress {checkTypes|accessControls}\n" +
- " */\n" +
- "\n" +
- "goog.provide('com.example.components.MyEventTarget');\n" +
- "\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * @constructor\n" +
- " * @extends {goog.events.EventTarget}\n" +
- " */\n" +
- "com.example.components.MyEventTarget = function() {\n" +
- " com.example.components.MyEventTarget.base(this, 'constructor');\n" +
- " if (foo() != 42) {\n" +
- " bar();\n" +
- " }\n" +
- "};\n" +
- "goog.inherits(com.example.components.MyEventTarget, goog.events.EventTarget);\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * @private\n" +
- " * @type {string}\n" +
- " */\n" +
- "com.example.components.MyEventTarget.prototype._privateVar = \"do \";\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * @export\n" +
- " * @type {number}\n" +
- " */\n" +
- "com.example.components.MyEventTarget.prototype.publicProperty = 100;\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * @export\n" +
- " * @param {string} value\n" +
- " * @return {string}\n" +
- " */\n" +
- "com.example.components.MyEventTarget.prototype.myFunction = function(value) {\n" +
- " return \"Don't \" + this._privateVar + value;\n" +
- "};\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * Metadata\n" +
- " *\n" +
- " * @type {Object.<string, Array.<Object>>}\n" +
- " */\n" +
- "com.example.components.MyEventTarget.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'MyEventTarget', qName: 'com.example.components.MyEventTarget'}] };\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * Prevent renaming of class. Needed for reflection.\n" +
- " */\n" +
- "goog.exportSymbol('com.example.components.MyEventTarget', com.example.components.MyEventTarget);\n" +
- "\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * Reflection\n" +
- " *\n" +
- " * @return {Object.<string, Function>}\n" +
- " */\n" +
- "com.example.components.MyEventTarget.prototype.FLEXJS_REFLECTION_INFO = function () {\n" +
- " return {\n" +
- " variables: function () {\n" +
- " return {\n" +
- " 'publicProperty': { type: 'Number'}\n" +
- " };\n" +
- " },\n" +
- " accessors: function () {\n" +
- " return {\n" +
- " };\n" +
- " },\n" +
- " methods: function () {\n" +
- " return {\n" +
- " 'MyEventTarget': { type: '', declaredBy: 'com.example.components.MyEventTarget'},\n" +
- " 'myFunction': { type: 'String', declaredBy: 'com.example.components.MyEventTarget'}\n" +
- " };\n" +
- " }\n" +
- " };\n" +
- "};\n");
- }
-
- @Override
- @Test
- public void testSimpleInterface()
- {
- String code = "package com.example.components {"
- + "public interface TestInterface { } }";
- IFileNode node = compileAS(code);
- asBlockWalker.visitFile(node);
- assertOutWithMetadata("/**\n" +
- " * com.example.components.TestInterface\n" +
- " *\n" +
- " * @fileoverview\n" +
- " *\n" +
- " * @suppress {checkTypes|accessControls}\n" +
- " */\n" +
- "\n" +
- "goog.provide('com.example.components.TestInterface');\n" +
- "\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * @interface\n" +
- " */\ncom.example.components.TestInterface = function() {\n" +
- "};\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * Metadata\n" +
- " *\n" +
- " * @type {Object.<string, Array.<Object>>}\n" +
- " */\n" +
- "com.example.components.TestInterface.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'TestInterface', qName: 'com.example.components.TestInterface'}] };\n" +
- "\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * Reflection\n" +
- " *\n" +
- " * @return {Object.<string, Function>}\n" +
- " */\n" +
- "com.example.components.TestInterface.prototype.FLEXJS_REFLECTION_INFO = function () {\n" +
- " return {\n" +
- " variables: function () {\n" +
- " return {\n" +
- " };\n" +
- " },\n" +
- " accessors: function () {\n" +
- " return {\n" +
- " };\n" +
- " },\n" +
- " methods: function () {\n" +
- " return {\n" +
- " };\n" +
- " }\n" +
- " };\n" +
- "};\n");
- }
-
- @Override
- @Test
- public void testSimpleClass()
- {
- String code = "package com.example.components {"
- + "public class TestClass { } }";
- IFileNode node = compileAS(code);
- asBlockWalker.visitFile(node);
- assertOutWithMetadata("/**\n" +
- " * com.example.components.TestClass\n" +
- " *\n" +
- " * @fileoverview\n" +
- " *\n" +
- " * @suppress {checkTypes|accessControls}\n" +
- " */\n" +
- "\n" +
- "goog.provide('com.example.components.TestClass');\n" +
- "\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * @constructor\n" +
- " */\n" +
- "com.example.components.TestClass = function() {\n" +
- "};\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * Metadata\n" +
- " *\n" +
- " * @type {Object.<string, Array.<Object>>}\n" +
- " */\n" +
- "com.example.components.TestClass.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'TestClass', qName: 'com.example.components.TestClass'}] };\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * Prevent renaming of class. Needed for reflection.\n" +
- " */\n" +
- "goog.exportSymbol('com.example.components.TestClass', com.example.components.TestClass);\n" +
- "\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * Reflection\n" +
- " *\n" +
- " * @return {Object.<string, Function>}\n" +
- " */\n" +
- "com.example.components.TestClass.prototype.FLEXJS_REFLECTION_INFO = function () {\n" +
- " return {\n" +
- " variables: function () {\n" +
- " return {\n" +
- " };\n" +
- " },\n" +
- " accessors: function () {\n" +
- " return {\n" +
- " };\n" +
- " },\n" +
- " methods: function () {\n" +
- " return {\n" +
- " };\n" +
- " }\n" +
- " };\n" +
- "};\n");
- }
-
-
- @Override
- @Test
- public void testDefaultParameter()
- {
- IFunctionNode node = getMethodWithPackage("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{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.FalconTest_A.prototype.method1 = function(p1, p2, p3, p4) {\n"
- + " p3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
- + " p4 = typeof p4 !== 'undefined' ? p4 : 4;\n"
- + " return p1 + p2 + p3 + p4;\n}");
- }
-
- @Override
- @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.FalconTest_A.prototype.method1 = function(bar, bax) {\n"
- + " bar = typeof bar !== 'undefined' ? bar : 42;\n"
- + " bax = typeof bax !== 'undefined' ? bax : 4;\n"
- + " if (a)\n foo();\n}");
- }
-
- @Override
- @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.FalconTest_A.prototype.method1 = function(p1, p2, p3, p4) {\n"
- + " p3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
- + " p4 = typeof p4 !== 'undefined' ? p4 : 4;\n}");
- }
-
- @Override
- @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.FalconTest_A.prototype.method1 = function(bar) {\n}");
- }
-
- @Override
- @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.FalconTest_A.prototype.method1 = function(bar, baz, goo) {\n}");
- }
-
- @Override
- @Test
- public void testSimpleMultipleParameter_JSDoc()
- {
- IFunctionNode node = getMethodWithPackage("/**\n * This is copied from ASDoc.\n */\nfunction method1(bar:int, baz:String, goo:Array):void{\n}");
- asBlockWalker.visitFunction(node);
- assertOut("/**\n * This is copied from ASDoc.\n * @param {number} bar\n * @param {string} baz\n * @param {Array} goo\n */\n"
- + "foo.bar.FalconTest_A.prototype.method1 = function(bar, baz, goo) {\n}");
- }
-
- @Test
- public void testSimpleMultipleParameter_JSDocSingleLine()
- {
- IFunctionNode node = getMethodWithPackage("/** This is copied from ASDoc. */\nfunction method1(bar:int, baz:String, goo:Array):void{\n}");
- asBlockWalker.visitFunction(node);
- assertOut("/** This is copied from ASDoc. \n * @param {number} bar\n * @param {string} baz\n * @param {Array} goo\n */\n"
- + "foo.bar.FalconTest_A.prototype.method1 = function(bar, baz, goo) {\n}");
- }
-
- @Override
- protected IBackend createBackend()
- {
- return new FlexJSBackend();
- }
-
- @Override
- protected void addDependencies()
- {
- super.addDependencies();
- workspace.setASDocDelegate(new FlexJSASDocDelegate());
- MXMLJSC.keepASDoc = true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6993a66e/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmitter.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmitter.java
new file mode 100644
index 0000000..013d930
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmitter.java
@@ -0,0 +1,364 @@
+/*
+ *
+ * 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.flex.compiler.internal.codegen.js.flexjs;
+
+import org.apache.flex.compiler.clients.MXMLJSC;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogEmitter;
+import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
+import org.apache.flex.compiler.internal.parsing.as.FlexJSASDocDelegate;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.junit.Test;
+
+/**
+ * @author Erik de Bruin
+ */
+public class TestFlexJSEmitter extends TestGoogEmitter
+{
+ @Override
+ public void setUp()
+ {
+ project = new FlexJSProject(workspace);
+
+ super.setUp();
+ }
+
+ @Override
+ @Test
+ public void testSimple()
+ {
+ String code = "package com.example.components {"
+ + "import goog.events.EventTarget;"
+ + "public class MyEventTarget extends EventTarget {"
+ + "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);
+ assertOutWithMetadata("/**\n" +
+ " * com.example.components.MyEventTarget\n" +
+ " *\n" +
+ " * @fileoverview\n" +
+ " *\n" +
+ " * @suppress {checkTypes|accessControls}\n" +
+ " */\n" +
+ "\n" +
+ "goog.provide('com.example.components.MyEventTarget');\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * @constructor\n" +
+ " * @extends {goog.events.EventTarget}\n" +
+ " */\n" +
+ "com.example.components.MyEventTarget = function() {\n" +
+ " com.example.components.MyEventTarget.base(this, 'constructor');\n" +
+ " if (foo() != 42) {\n" +
+ " bar();\n" +
+ " }\n" +
+ "};\n" +
+ "goog.inherits(com.example.components.MyEventTarget, goog.events.EventTarget);\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * @private\n" +
+ " * @type {string}\n" +
+ " */\n" +
+ "com.example.components.MyEventTarget.prototype._privateVar = \"do \";\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * @export\n" +
+ " * @type {number}\n" +
+ " */\n" +
+ "com.example.components.MyEventTarget.prototype.publicProperty = 100;\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * @export\n" +
+ " * @param {string} value\n" +
+ " * @return {string}\n" +
+ " */\n" +
+ "com.example.components.MyEventTarget.prototype.myFunction = function(value) {\n" +
+ " return \"Don't \" + this._privateVar + value;\n" +
+ "};\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * Metadata\n" +
+ " *\n" +
+ " * @type {Object.<string, Array.<Object>>}\n" +
+ " */\n" +
+ "com.example.components.MyEventTarget.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'MyEventTarget', qName: 'com.example.components.MyEventTarget'}] };\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * Prevent renaming of class. Needed for reflection.\n" +
+ " */\n" +
+ "goog.exportSymbol('com.example.components.MyEventTarget', com.example.components.MyEventTarget);\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * Reflection\n" +
+ " *\n" +
+ " * @return {Object.<string, Function>}\n" +
+ " */\n" +
+ "com.example.components.MyEventTarget.prototype.FLEXJS_REFLECTION_INFO = function () {\n" +
+ " return {\n" +
+ " variables: function () {\n" +
+ " return {\n" +
+ " 'publicProperty': { type: 'Number'}\n" +
+ " };\n" +
+ " },\n" +
+ " accessors: function () {\n" +
+ " return {\n" +
+ " };\n" +
+ " },\n" +
+ " methods: function () {\n" +
+ " return {\n" +
+ " 'MyEventTarget': { type: '', declaredBy: 'com.example.components.MyEventTarget'},\n" +
+ " 'myFunction': { type: 'String', declaredBy: 'com.example.components.MyEventTarget'}\n" +
+ " };\n" +
+ " }\n" +
+ " };\n" +
+ "};\n");
+ }
+
+ @Override
+ @Test
+ public void testSimpleInterface()
+ {
+ String code = "package com.example.components {"
+ + "public interface TestInterface { } }";
+ IFileNode node = compileAS(code);
+ asBlockWalker.visitFile(node);
+ assertOutWithMetadata("/**\n" +
+ " * com.example.components.TestInterface\n" +
+ " *\n" +
+ " * @fileoverview\n" +
+ " *\n" +
+ " * @suppress {checkTypes|accessControls}\n" +
+ " */\n" +
+ "\n" +
+ "goog.provide('com.example.components.TestInterface');\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * @interface\n" +
+ " */\ncom.example.components.TestInterface = function() {\n" +
+ "};\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * Metadata\n" +
+ " *\n" +
+ " * @type {Object.<string, Array.<Object>>}\n" +
+ " */\n" +
+ "com.example.components.TestInterface.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'TestInterface', qName: 'com.example.components.TestInterface'}] };\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * Reflection\n" +
+ " *\n" +
+ " * @return {Object.<string, Function>}\n" +
+ " */\n" +
+ "com.example.components.TestInterface.prototype.FLEXJS_REFLECTION_INFO = function () {\n" +
+ " return {\n" +
+ " variables: function () {\n" +
+ " return {\n" +
+ " };\n" +
+ " },\n" +
+ " accessors: function () {\n" +
+ " return {\n" +
+ " };\n" +
+ " },\n" +
+ " methods: function () {\n" +
+ " return {\n" +
+ " };\n" +
+ " }\n" +
+ " };\n" +
+ "};\n");
+ }
+
+ @Override
+ @Test
+ public void testSimpleClass()
+ {
+ String code = "package com.example.components {"
+ + "public class TestClass { } }";
+ IFileNode node = compileAS(code);
+ asBlockWalker.visitFile(node);
+ assertOutWithMetadata("/**\n" +
+ " * com.example.components.TestClass\n" +
+ " *\n" +
+ " * @fileoverview\n" +
+ " *\n" +
+ " * @suppress {checkTypes|accessControls}\n" +
+ " */\n" +
+ "\n" +
+ "goog.provide('com.example.components.TestClass');\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * @constructor\n" +
+ " */\n" +
+ "com.example.components.TestClass = function() {\n" +
+ "};\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * Metadata\n" +
+ " *\n" +
+ " * @type {Object.<string, Array.<Object>>}\n" +
+ " */\n" +
+ "com.example.components.TestClass.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'TestClass', qName: 'com.example.components.TestClass'}] };\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * Prevent renaming of class. Needed for reflection.\n" +
+ " */\n" +
+ "goog.exportSymbol('com.example.components.TestClass', com.example.components.TestClass);\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * Reflection\n" +
+ " *\n" +
+ " * @return {Object.<string, Function>}\n" +
+ " */\n" +
+ "com.example.components.TestClass.prototype.FLEXJS_REFLECTION_INFO = function () {\n" +
+ " return {\n" +
+ " variables: function () {\n" +
+ " return {\n" +
+ " };\n" +
+ " },\n" +
+ " accessors: function () {\n" +
+ " return {\n" +
+ " };\n" +
+ " },\n" +
+ " methods: function () {\n" +
+ " return {\n" +
+ " };\n" +
+ " }\n" +
+ " };\n" +
+ "};\n");
+ }
+
+
+ @Override
+ @Test
+ public void testDefaultParameter()
+ {
+ IFunctionNode node = getMethodWithPackage("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{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.FalconTest_A.prototype.method1 = function(p1, p2, p3, p4) {\n"
+ + " p3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
+ + " p4 = typeof p4 !== 'undefined' ? p4 : 4;\n"
+ + " return p1 + p2 + p3 + p4;\n}");
+ }
+
+ @Override
+ @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.FalconTest_A.prototype.method1 = function(bar, bax) {\n"
+ + " bar = typeof bar !== 'undefined' ? bar : 42;\n"
+ + " bax = typeof bax !== 'undefined' ? bax : 4;\n"
+ + " if (a)\n foo();\n}");
+ }
+
+ @Override
+ @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.FalconTest_A.prototype.method1 = function(p1, p2, p3, p4) {\n"
+ + " p3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
+ + " p4 = typeof p4 !== 'undefined' ? p4 : 4;\n}");
+ }
+
+ @Override
+ @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.FalconTest_A.prototype.method1 = function(bar) {\n}");
+ }
+
+ @Override
+ @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.FalconTest_A.prototype.method1 = function(bar, baz, goo) {\n}");
+ }
+
+ @Override
+ @Test
+ public void testSimpleMultipleParameter_JSDoc()
+ {
+ IFunctionNode node = getMethodWithPackage("/**\n * This is copied from ASDoc.\n */\nfunction method1(bar:int, baz:String, goo:Array):void{\n}");
+ asBlockWalker.visitFunction(node);
+ assertOut("/**\n * This is copied from ASDoc.\n * @param {number} bar\n * @param {string} baz\n * @param {Array} goo\n */\n"
+ + "foo.bar.FalconTest_A.prototype.method1 = function(bar, baz, goo) {\n}");
+ }
+
+ @Test
+ public void testSimpleMultipleParameter_JSDocSingleLine()
+ {
+ IFunctionNode node = getMethodWithPackage("/** This is copied from ASDoc. */\nfunction method1(bar:int, baz:String, goo:Array):void{\n}");
+ asBlockWalker.visitFunction(node);
+ assertOut("/** This is copied from ASDoc. \n * @param {number} bar\n * @param {string} baz\n * @param {Array} goo\n */\n"
+ + "foo.bar.FalconTest_A.prototype.method1 = function(bar, baz, goo) {\n}");
+ }
+
+ @Override
+ protected IBackend createBackend()
+ {
+ return new FlexJSBackend();
+ }
+
+ @Override
+ protected void addDependencies()
+ {
+ super.addDependencies();
+ workspace.setASDocDelegate(new FlexJSASDocDelegate());
+ MXMLJSC.keepASDoc = true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6993a66e/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java
deleted file mode 100644
index 21a9c90..0000000
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java
+++ /dev/null
@@ -1,153 +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.flex.compiler.internal.codegen.js.goog;
-
-import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
-import org.apache.flex.compiler.internal.test.ASTestBase;
-import org.apache.flex.compiler.tree.as.IFileNode;
-import org.apache.flex.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 TestGoogEmiter extends ASTestBase
-{
-
- @Test
- public void testSimple()
- {
- String code = "package com.example.components {"
- + "import goog.events.EventTarget;"
- + "public class MyEventTarget extends EventTarget {"
- + "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('goog.events.EventTarget');\n\n/**\n * @constructor\n * @extends {goog.events.EventTarget}\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, goog.events.EventTarget);\n\n/**\n * @private\n * @type {string}\n */\ncom.example.components.MyEventTarget.prototype._privateVar = \"do \";\n\n/**\n * @type {number}\n */\ncom.example.components.MyEventTarget.prototype.publicProperty = 100;\n\n/**\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyEventTarget.prototype.myFunction = function(value) {\n\tvar self = this;\n\treturn \"Don't \" + self._privateVar + value;\n};");
- }
-
- @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("FalconTest_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.FalconTest_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.FalconTest_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.FalconTest_A.prototype.method1 = function(bar, baz, goo) {\n}");
- }
-
- @Test
- public void testDefaultParameter()
- {
- IFunctionNode node = getMethodWithPackage("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{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.FalconTest_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.FalconTest_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.FalconTest_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();
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6993a66e/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmitter.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmitter.java
new file mode 100644
index 0000000..92f0ecb
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmitter.java
@@ -0,0 +1,153 @@
+/*
+ *
+ * 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.flex.compiler.internal.codegen.js.goog;
+
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.internal.test.ASTestBase;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.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 goog.events.EventTarget;"
+ + "public class MyEventTarget extends EventTarget {"
+ + "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('goog.events.EventTarget');\n\n/**\n * @constructor\n * @extends {goog.events.EventTarget}\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, goog.events.EventTarget);\n\n/**\n * @private\n * @type {string}\n */\ncom.example.components.MyEventTarget.prototype._privateVar = \"do \";\n\n/**\n * @type {number}\n */\ncom.example.components.MyEventTarget.prototype.publicProperty = 100;\n\n/**\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyEventTarget.prototype.myFunction = function(value) {\n\tvar self = this;\n\treturn \"Don't \" + self._privateVar + value;\n};");
+ }
+
+ @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("FalconTest_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.FalconTest_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.FalconTest_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.FalconTest_A.prototype.method1 = function(bar, baz, goo) {\n}");
+ }
+
+ @Test
+ public void testDefaultParameter()
+ {
+ IFunctionNode node = getMethodWithPackage("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{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.FalconTest_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.FalconTest_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.FalconTest_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();
+ }
+}