You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2014/10/31 09:28:33 UTC
[11/23] git commit: [flex-falcon]
[refs/heads/feature/flexmojos-tests] - VF2JS tests
VF2JS tests
Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/26117b18
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/26117b18
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/26117b18
Branch: refs/heads/feature/flexmojos-tests
Commit: 26117b18b96b6f5c4c8c3ce84885b0ecfefa9fdd
Parents: db8e7f0
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Thu Oct 23 16:57:27 2014 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Thu Oct 23 19:42:52 2014 +0200
----------------------------------------------------------------------
.../codegen/js/vf2js/TestVF2JSClass.java | 302 ++++++++++++
.../codegen/js/vf2js/TestVF2JSFile.java | 4 +-
.../codegen/js/vf2js/TestVF2JSProject.java | 73 +--
.../codegen/js/vf2js/TestVF2JSStatements.java | 494 +++++++++++++++++++
.../mxml/vf2js/TestVF2JSMXMLApplication.java | 57 ++-
5 files changed, 895 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/26117b18/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java
new file mode 100644
index 0000000..8998868
--- /dev/null
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSClass.java
@@ -0,0 +1,302 @@
+/*
+ *
+ * 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.vf2js;
+
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogClass;
+import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
+import org.apache.flex.compiler.tree.as.IClassNode;
+import org.junit.Test;
+
+/**
+ * @author Erik de Bruin
+ */
+public class TestVF2JSClass extends TestGoogClass
+{
+
+ @Override
+ @Test
+ public void testConstructor_super()
+ {
+ IClassNode node = getClassNode("public class A {public function A() { super(); }}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n ;\n};");
+ }
+
+ @Override
+ @Test
+ public void testSimpleExtends()
+ {
+ IClassNode node = getClassNode("public class A extends Button {public function A() {}}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+ }
+
+ @Override
+ @Test
+ public void testSimpleExtendsImplements()
+ {
+ IClassNode node = getClassNode("public class A extends Button implements IEventDispatcher {public function A() {}}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+ }
+
+ @Override
+ @Test
+ public void testSimpleExtendsImplementsMultiple()
+ {
+ IClassNode node = getClassNode("public class A extends Button implements IEventDispatcher, ILogger {public function A() {}}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+ }
+
+ @Override
+ @Test
+ public void testSimpleFinalExtendsImplementsMultiple()
+ {
+ IClassNode node = getClassNode("public final class A extends Button implements IEventDispatcher, ILogger {public function A() {}}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+ }
+
+ @Override
+ @Test
+ public void testQualifiedExtendsImplementsMultiple()
+ {
+ IClassNode node = getClassNode("public class A extends spark.components.Button implements flash.events.IEventDispatcher, mx.logging.ILogger {public function A() {}}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @implements {flash.events.IEventDispatcher}\n * @implements {mx.logging.ILogger}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor');\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+ }
+
+ @Override
+ @Test
+ public void testExtendsConstructor_super()
+ {
+ IClassNode node = getClassNode("public class A extends spark.components.Button { public function A() { super('foo', 42);}}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n */\norg.apache.flex.A = function() {\n org.apache.flex.A.base(this, 'constructor', 'foo', 42);\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+ }
+
+ @Test
+ public void testConstructor_withArgumentNameMatchingMemberName()
+ {
+ IClassNode node = getClassNode("public class B {public function B(arg1:String) {this.arg1 = arg1}; public var arg1:String;}");
+ asBlockWalker.visitClass(node);
+ String expected = "/**\n * @constructor\n * @param {string} arg1\n */\norg.apache.flex.B = function(arg1) {\n this.arg1 = arg1;\n};\n\n\n/**\n * @type {string}\n */\norg.apache.flex.B.prototype.arg1;";
+ assertOut(expected);
+ }
+
+ @Test
+ public void testMethod_withImplicitSelfInReturnValue()
+ {
+ IClassNode node = getClassNode("public class B {public function B() {}; public var button:Button = new Button(); public function foo():String {return button.label;};}");
+ asBlockWalker.visitClass(node);
+ String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @type {spark.components.Button}\n */\norg.apache.flex.B.prototype.button = new spark.components.Button();\n\n\n/**\n * @expose\n * @return {string}\n */\norg.apache.flex.B.prototype.foo = function() {\n return this.button.get_label();\n};";
+ assertOut(expected);
+ }
+
+ @Test
+ public void testMethod_noArgsNoReturn()
+ {
+ IClassNode node = getClassNode("public class B {public function B() {}; public function foo():void {};}");
+ asBlockWalker.visitClass(node);
+ String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n */\norg.apache.flex.B.prototype.foo = function() {\n};";
+ assertOut(expected);
+ }
+
+ @Test
+ public void testMethod_override()
+ {
+ IClassNode node = getClassNode("public class B {public function B() {}; override public function foo():void {};}");
+ asBlockWalker.visitClass(node);
+ String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @override\n */\norg.apache.flex.B.prototype.foo = function() {\n};";
+ assertOut(expected);
+ }
+
+ @Test
+ public void testMethod_overrideWithFunctionBody()
+ {
+ IClassNode node = getClassNode("public class B {public function B() {}; override public function foo(value:Object):void {baz = ''};}");
+ asBlockWalker.visitClass(node);
+ String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n * @override\n */\norg.apache.flex.B.prototype.foo = function(value) {\n baz = '';\n};";
+ assertOut(expected);
+ }
+
+ @Test
+ public void testMethod_overrideSuperCall()
+ {
+ IClassNode node = getClassNode("public class B {public function B() {}; override public function foo():void {super.foo();};}");
+ asBlockWalker.visitClass(node);
+ String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @override\n */\norg.apache.flex.B.prototype.foo = function() {\n org.apache.flex.B.base(this, 'foo');\n};";
+ assertOut(expected);
+ }
+
+ @Test
+ public void testMethod_setterCall()
+ {
+ IClassNode node = getClassNode("public class B {public function B() {}; public function set baz(value:Object):void {}; public function set foo(value:Object):void {baz = value;};}");
+ asBlockWalker.visitClass(node);
+ String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n */\norg.apache.flex.B.prototype.set_baz = function(value) {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n */\norg.apache.flex.B.prototype.set_foo = function(value) {\n this.set_baz(value);\n};";
+ assertOut(expected);
+ }
+
+ @Test
+ public void testMethod_overrideSetterSuperCall()
+ {
+ IClassNode node = getClassNode("public class B {public function B() {}; override public function set foo(value:Object):void {super.foo = value;};}");
+ asBlockWalker.visitClass(node);
+ String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n * @override\n */\norg.apache.flex.B.prototype.set_foo = function(value) {\n org.apache.flex.B.base(this, 'set_foo', value);\n};";
+ assertOut(expected);
+ }
+
+ @Override
+ @Test
+ public void testExtendsConstructor_withArguments()
+ {
+ IClassNode node = getClassNode("public class A extends spark.components.Button {public function A(arg1:String, arg2:int) {}}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n * @extends {spark.components.Button}\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.flex.A = function(arg1, arg2) {\n org.apache.flex.A.base(this, 'constructor', arg1, arg2);\n};\ngoog.inherits(org.apache.flex.A, spark.components.Button);");
+ }
+
+ @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.flex.A = function() {\n};\n\n\n/**\n * @type {Object}\n */\norg.apache.flex.A.prototype.a;\n\n\n/**\n * @protected\n * @type {string}\n */\norg.apache.flex.A.prototype.b;\n\n\n/**\n * @private\n * @type {number}\n */\norg.apache.flex.A.prototype.c;\n\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.d;\n\n\n/**\n * @type {number}\n */\norg.apache.flex.A.prototype.e;");
+ }
+
+ @Test
+ public void testFieldWithEmbed()
+ {
+ IClassNode node = getClassNode("public class A {[Embed(source=\"LuminosityMaskFilter.pbj\", mimeType=\"application/octet-stream\")]\nprivate static var ShaderClass:Class;}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n * @private\n * @type {Object}\n */\norg.apache.flex.A.ShaderClass;");
+ }
+
+ @Test
+ public void testFieldWithObjectAssignment()
+ {
+ IClassNode node = getClassNode("public class A {private var controlBarGroupProperties:Object = { visible: true }; private var _visible:Boolean; public function get visible():Boolean { return _visible; }; public function set visible(value:Boolean):void { _visible = value; };}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n * @private\n * @type {Object}\n */\norg.apache.flex.A.prototype.controlBarGroupProperties = {visible:true};\n\n\n/**\n * @private\n * @type {boolean}\n */\norg.apache.flex.A.prototype._visible;\n\n\n/**\n * @expose\n * @return {boolean}\n */\norg.apache.flex.A.prototype.get_visible = function() {\n return this._visible;\n};\n\n\n/**\n * @expose\n * @param {boolean} value\n */\norg.apache.flex.A.prototype.set_visible = function(value) {\n this._visible = value;\n};");
+ }
+
+ @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.flex.A = function() {\n};\n\n\n/**\n * @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n\n/**\n * @protected\n * @const\n * @type {number}\n */\norg.apache.flex.A.B = 42;\n\n\n/**\n * @private\n * @const\n * @type {number}\n */\norg.apache.flex.A.C = 42;\n\n\n/**\n * @const\n * @type {string}\n */\norg.apache.flex.A.C = 'me' + 'you';");
+ }
+
+ @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.flex.A = function() {\n};\n\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo1 = function() {\n return null;\n};\n\n\n/**\n * @expose\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo1 = function(value) {\n};\n\n\n/**\n * @protected\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo2 = function() {\n return null;\n};\n\n\n/**\n * @protected\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo2 = function(value) {\n};\n\n\n/**\n * @private\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo3 = function() {\n return null;\n};\n\n\n/**\n * @private\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo3 = function(value) {\n};\n\n\n/**\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo5 = function() {\n return null;\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo5 = function(value)
{\n};\n\n\n/**\n * @return {Object}\n */\norg.apache.flex.A.prototype.get_foo6 = function() {\n return null;\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.set_foo6 = function(value) {\n};");
+ }
+
+ @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.flex.A = function() {\n};\n\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1 = function() {\n return null;\n};\n\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1a = function() {\n return null;\n};\n\n\n/**\n * @expose\n * @return {Object}\n * @override\n */\norg.apache.flex.A.prototype.foo1b = function() {\n return org.apache.flex.A.base(this, 'foo1b');\n};\n\n\n/**\n * @protected\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo2 = function(value) {\n};\n\n\n/**\n * @private\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo3 = function(value) {\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo5 = function(value) {\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo6 = function(value) {\n};\n\n\n/**\n * @expose\n * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n
};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n};");
+ }
+
+ @Test
+ public void testMethodsWithLocalFunctions()
+ {
+ IClassNode node = getClassNode("public class B {"
+ + "public function foo1():Object{function bar1():Object {return null;}; return bar1()}"
+ + "public function foo2():Object{function bar2(param1:Object):Object {return null;}; return bar2('foo');}"
+ + "}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n function bar1() {\n return null;\n };\n return goog.bind(bar1, this)();\n};\n\n\n/**\n * @expose\n * @return {Object}\n */\norg.apache.flex.B.prototype.foo2 = function() {\n function bar2(param1) {\n return null;\n };\n return goog.bind(bar2, this)('foo');\n};");
+ }
+
+ @Test
+ public void testMethodsWithLocalFunctions2()
+ {
+ IClassNode node = getClassNode("public class B {"
+ + "public var baz1:String;"
+ + "public function foo1():String{function bar1():String {return baz1;}; return bar1()}"
+ + "public function foo2():String{function bar2(param1:String):String {return param1 + baz1;}; return bar2('foo');}"
+ + "}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @type {string}\n */\norg.apache.flex.B.prototype.baz1;\n\n\n/**\n * @expose\n * @return {string}\n */\norg.apache.flex.B.prototype.foo1 = function() {\n function bar1() {\n return this.baz1;\n };\n return goog.bind(bar1, this)();\n};\n\n\n/**\n * @expose\n * @return {string}\n */\norg.apache.flex.B.prototype.foo2 = function() {\n function bar2(param1) {\n return param1 + this.baz1;\n };\n return goog.bind(bar2, this)('foo');\n};");
+ }
+
+ @Test
+ public void testClassWithoutConstructor()
+ {
+ /* AJH couldn't find a way to reproduce the code paths
+ * in a simple test case. May require multiple compilation
+ * units in the same package.
+ */
+
+ // (erikdebruin) what's wrong with this test case and/or the resulting code?
+
+ // (erikdebruin) if you're looking for a way to test multiple cu's
+ // (a project), look in 'TestGoogProject' for an example
+
+ IClassNode node = getClassNode("public class B {"
+ + "public function clone():B { return new B() }"
+ + "}");
+ asBlockWalker.visitClass(node);
+ assertOut("/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @expose\n * @return {org.apache.flex.B}\n */\norg.apache.flex.B.prototype.clone = function() {\n return new org.apache.flex.B();\n};");
+ }
+
+ protected IBackend createBackend()
+ {
+ return new VF2JSBackend();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/26117b18/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java
index 4ee33db..66a591d 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java
@@ -23,7 +23,7 @@ import java.io.File;
import java.util.List;
import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
+import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
import org.apache.flex.compiler.internal.test.VF2JSTestBase;
import org.apache.flex.compiler.tree.as.IFileNode;
import org.apache.flex.utils.FilenameNormalization;
@@ -68,6 +68,6 @@ public class TestVF2JSFile extends VF2JSTestBase
@Override
protected IBackend createBackend()
{
- return new FlexJSBackend();
+ return new VF2JSBackend();
}
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/26117b18/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java
index 38c21c8..06984bd 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSProject.java
@@ -19,14 +19,14 @@
package org.apache.flex.compiler.internal.codegen.js.vf2js;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
import java.io.File;
import java.util.List;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogProject;
+import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.compiler.internal.test.VF2JSTestBase;
+import org.apache.flex.utils.FilenameNormalization;
import org.junit.Ignore;
import org.junit.Test;
@@ -36,9 +36,11 @@ import org.junit.Test;
*
* @author Erik de Bruin
*/
-public class TestVF2JSProject extends VF2JSTestBase
+public class TestVF2JSProject extends TestGoogProject
{
+ private static String projectDirPath = "vf2js/projects";
+
@Override
public void setUp()
{
@@ -46,41 +48,54 @@ public class TestVF2JSProject extends VF2JSTestBase
super.setUp();
}
-
+
@Ignore
@Test
- public void testSimpleMXMLProject()
+ public void test_imports()
+ {
+ // crude bypass to allow for successful inheritance
+ }
+
+ @Test
+ public void test_Test()
{
- String testDirPath = new File("test-files").getAbsolutePath()
- + "/vf2js/projects/simpleMXML/src";
+ String testDirPath = projectDirPath + "/interfaces";
- String fileName = "SimpleMXML";
+ String fileName = "Test";
List<String> compiledFileNames = compileProject(fileName, testDirPath);
assertProjectOut(compiledFileNames, testDirPath);
}
- protected void assertProjectOut(List<String> compiledFileNames,
- String testDirPath)
+ @Test
+ public void test_Super()
+ {
+ String testDirPath = projectDirPath + "/super";
+
+ String fileName = "Base";
+
+ List<String> compiledFileNames = compileProject(fileName, testDirPath);
+
+ assertProjectOut(compiledFileNames, testDirPath);
+ }
+
+ @Override
+ protected void addSourcePaths(List<File> sourcePaths)
+ {
+ sourcePaths.add(new File(FilenameNormalization.normalize("test-files"
+ + File.separator + projectDirPath + "/interfaces")));
+
+ sourcePaths.add(new File(FilenameNormalization.normalize("test-files"
+ + File.separator + projectDirPath + "/super")));
+
+ super.addSourcePaths(sourcePaths);
+ }
+
+ @Override
+ protected IBackend createBackend()
{
- 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 = testDirPath + File.separator
- + compiledFileName + "_result" + "."
- + backend.getOutputExtension();
- String expectedResult = readCodeFile(new File(expectedFilePath));
-
- assertThat(compiledResult, is(expectedResult));
- }
+ return new VF2JSBackend();
}
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/26117b18/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
new file mode 100644
index 0000000..e32a5d2
--- /dev/null
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSStatements.java
@@ -0,0 +1,494 @@
+/*
+ *
+ * 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.vf2js;
+
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogStatements;
+import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.as.IForLoopNode;
+import org.apache.flex.compiler.tree.as.IIfNode;
+import org.apache.flex.compiler.tree.as.ISwitchNode;
+import org.apache.flex.compiler.tree.as.ITryNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.tree.as.IWhileLoopNode;
+import org.apache.flex.compiler.tree.as.IWithNode;
+import org.junit.Test;
+
+/**
+ * @author Erik de Bruin
+ */
+public class TestVF2JSStatements extends TestGoogStatements
+{
+ @Override
+ public void setUp()
+ {
+ project = new FlexJSProject(workspace);
+ super.setUp();
+ }
+
+ @Test
+ public void testVarDeclaration_withTypeAssignedStringWithNewLine()
+ {
+ IVariableNode node = (IVariableNode) getNode("var a:String = \"\\n\"",
+ IVariableNode.class);
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {string} */ a = \"\\n\"");
+ }
+
+ @Test
+ public void testVarDeclaration_withXMLList()
+ {
+ IVariableNode node = (IVariableNode) getNode(
+ "var childDesc:XMLList = typeDescription.accessor."
+ + "(@name == childName) + typeDescription.method."
+ + "(@name == childName);",
+ IVariableNode.class);
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {XMLList} */ childDesc = 'E4XFilter' + 'E4XFilter'");
+ }
+
+ @Test
+ public void testVarDeclaration_withEmbed()
+ {
+ IVariableNode node = (IVariableNode) getNode(
+ "[Embed(source=\"LuminosityMaskFilter.pbj\", mimeType=\"application/octet-stream\")]\nprivate static var ShaderClass:Class;",
+ IVariableNode.class);
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {Object} */ falconTest_a.ShaderClass");
+ }
+
+ //----------------------------------
+ // 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 break;\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 break;");
+ }
+
+ @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 break;\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 break;");
+ }
+
+ @Override
+ @Test
+ public void testVisitForEach_1()
+ {
+ IForLoopNode node = (IForLoopNode) getNode(
+ "for each(var i:int in obj) { break; }", IForLoopNode.class);
+ asBlockWalker.visitForLoop(node);
+ assertOut("for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n{\n break;\n}}\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("for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n\n break;}\n");
+ }
+
+ @Test
+ public void testVisitForEach_HoistedVar()
+ {
+ IForLoopNode node = (IForLoopNode) getNode(
+ "var i:int; for each(i in obj) break; ", IForLoopNode.class);
+ asBlockWalker.visitForLoop(node);
+ assertOut("for (var foreachiter0 in obj) \n{\ni = obj[foreachiter0];\n\n break;}\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 a;\n} catch (e) {\n b;\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 a;\n} catch (e) {\n b;\n} finally {\n c;\n}");
+ }
+
+ @Override
+ @Test
+ public void testVisitTry_Catch_Catch_Finally()
+ {
+ // TODO (erikdebruin) handle multiple 'catch' statements (FW in Wiki)
+ ITryNode node = (ITryNode) getNode(
+ "try { a; } catch (e:Error) { b; } catch (f:Error) { c; } finally { d; }",
+ ITryNode.class);
+ asBlockWalker.visitTry(node);
+ assertOut("try {\n a;\n} catch (e) {\n b;\n} catch (f) {\n c;\n} finally {\n d;\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 a;\n} catch (e) {\n} finally {\n}");
+ }
+
+ //----------------------------------
+ // switch {}
+ //----------------------------------
+
+ @Override
+ @Test
+ public void testVisitSwitch_1()
+ {
+ ISwitchNode node = (ISwitchNode) getNode("switch(i){case 1: break;}",
+ ISwitchNode.class);
+ asBlockWalker.visitSwitch(node);
+ assertOut("switch (i) {\n case 1:\n break;\n}");
+ }
+
+ @Override
+ @Test
+ public void testVisitSwitch_1a()
+ {
+ ISwitchNode node = (ISwitchNode) getNode(
+ "switch(i){case 1: { break; }}", ISwitchNode.class);
+ asBlockWalker.visitSwitch(node);
+ // (erikdebruin) the code is valid without the extra braces,
+ // i.e. we're good, we "don't care"
+ assertOut("switch (i) {\n case 1:\n break;\n}");
+ }
+
+ @Override
+ @Test
+ public void testVisitSwitch_2()
+ {
+ ISwitchNode node = (ISwitchNode) getNode(
+ "switch(i){case 1: break; default: return;}", ISwitchNode.class);
+ asBlockWalker.visitSwitch(node);
+ assertOut("switch (i) {\n case 1:\n break;\n default:\n return;\n}");
+ }
+
+ @Override
+ @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 case 1:\n var /** @type {number} */ x = 42;\n break;\n case 2:\n var /** @type {number} */ y = 66;\n break;\n}");
+ }
+
+ @Test
+ public void testVisitSwitch_EscapedQuotes()
+ {
+ ISwitchNode node = (ISwitchNode) getNode(
+ "switch (type) { case \"string\": { return \"\\\"\" + value.toString() + \"\\\"\"; } }", ISwitchNode.class);
+ asBlockWalker.visitSwitch(node);
+ assertOut("switch (type) {\n case \"string\":\n return \"\\\"\" + value.toString() + \"\\\"\";\n}");
+ }
+
+ //----------------------------------
+ // if ()
+ //----------------------------------
+
+ @Override
+ @Test
+ public void testVisitIf_1()
+ {
+ IIfNode node = (IIfNode) getNode("if (a) b++;", IIfNode.class);
+ asBlockWalker.visitIf(node);
+ assertOut("if (a)\n b++;");
+ }
+
+ @Override
+ @Test
+ public void testVisitIf_2()
+ {
+ IIfNode node = (IIfNode) getNode("if (a) b++; else c++;", IIfNode.class);
+ asBlockWalker.visitIf(node);
+ assertOut("if (a)\n b++;\nelse\n c++;");
+ }
+
+ @Override
+ @Test
+ public void testVisitIf_4()
+ {
+ IIfNode node = (IIfNode) getNode(
+ "if (a) b++; else if (c) d++; else if(e) --f;", IIfNode.class);
+ asBlockWalker.visitIf(node);
+ assertOut("if (a)\n b++;\nelse if (c)\n d++;\nelse if (e)\n --f;");
+ }
+
+ @Test
+ public void testVisitIf_E4X()
+ {
+ IIfNode node = (IIfNode) getNode(
+ "if (numChildren == 0) { if (!typeDescription.@dynamic) { trace(\"warning: no describeType entry for '\" + childName + \"' on non-dynamic type '\" + typeDescription.@name + \"'\"); } }", IIfNode.class);
+ asBlockWalker.visitIf(node);
+ assertOut("if (numChildren == 0) {\n if (!this.typeDescription['E4XOperator']) {\n org.apache.flex.utils.Language.trace(\"warning: no describeType entry for '\" + childName + \"' on non-dynamic type '\" + this.typeDescription['E4XOperator'] + \"'\");\n }\n}");
+ }
+
+ @Test
+ public void testVisitIf_E4X_Again()
+ {
+ IIfNode node = (IIfNode) getNode(
+ "if (options.includeReadOnly) { properties = classInfo..accessor.(@access != \"writeonly\") + classInfo..variable; }", IIfNode.class);
+ asBlockWalker.visitIf(node);
+ assertOut("if (options.includeReadOnly) {\n properties = 'E4XFilter' + this.classInfo['E4XSelector'];\n}");
+ }
+
+ @Test
+ public void testVisitIf_UnescapedBackSlash()
+ {
+ IIfNode node = (IIfNode) getNode(
+ "if (rootURL && !(url.indexOf(\":\") > -1 || url.indexOf(\"/\") == 0 || url.indexOf(\"\\\\\") == 0)) { var index:int; }", IIfNode.class);
+ asBlockWalker.visitIf(node);
+ assertOut("if (rootURL && !(url.indexOf(\":\") > -1 || url.indexOf(\"/\") == 0 || url.indexOf(\"\\\\\") == 0)) {\n var /** @type {number} */ index;\n}");
+ }
+
+ //----------------------------------
+ // if () { }
+ //----------------------------------
+
+ @Override
+ @Test
+ public void testVisitIf_1a()
+ {
+ IIfNode node = (IIfNode) getNode("if (a) { b++; }", IIfNode.class);
+ asBlockWalker.visitIf(node);
+ assertOut("if (a) {\n b++;\n}");
+ }
+
+ @Override
+ @Test
+ public void testVisitIf_1b()
+ {
+ IIfNode node = (IIfNode) getNode("if (a) { b++; } else { c++; }",
+ IIfNode.class);
+ asBlockWalker.visitIf(node);
+ assertOut("if (a) {\n b++;\n} else {\n c++;\n}");
+ }
+
+ @Override
+ @Test
+ public void testVisitIf_1c()
+ {
+ IIfNode node = (IIfNode) getNode(
+ "if (a) { b++; } else if (b) { c++; } else { d++; }",
+ IIfNode.class);
+ asBlockWalker.visitIf(node);
+ assertOut("if (a) {\n b++;\n} else if (b) {\n c++;\n} else {\n d++;\n}");
+ }
+
+ @Override
+ @Test
+ public void testVisitIf_3()
+ {
+ IIfNode node = (IIfNode) getNode(
+ "if (a) b++; else if (c) d++; else --e;", IIfNode.class);
+ asBlockWalker.visitIf(node);
+ assertOut("if (a)\n b++;\nelse if (c)\n d++;\nelse\n --e;");
+ }
+
+ //----------------------------------
+ // label : for () {}
+ //----------------------------------
+
+ @Override
+ @Test
+ public void testVisitFor_2()
+ {
+ IForLoopNode node = (IForLoopNode) getNode("for (;;) { break; }",
+ IForLoopNode.class);
+ asBlockWalker.visitForLoop(node);
+ assertOut("for (;;) {\n break;\n}");
+ }
+
+ //----------------------------------
+ // while () { }
+ //----------------------------------
+
+ @Override
+ @Test
+ public void testVisitWhileLoop_1()
+ {
+ IWhileLoopNode node = (IWhileLoopNode) getNode(
+ "while(a > b){a++;--b;}", IWhileLoopNode.class);
+ asBlockWalker.visitWhileLoop(node);
+ assertOut("while (a > b) {\n a++;\n --b;\n}");
+ }
+
+ @Override
+ @Test
+ public void testVisitWhileLoop_1a()
+ {
+ IWhileLoopNode node = (IWhileLoopNode) getNode("while(a > b) a++;",
+ IWhileLoopNode.class);
+ asBlockWalker.visitWhileLoop(node);
+ assertOut("while (a > b)\n a++;");
+ }
+
+ //----------------------------------
+ // do {} while ()
+ //----------------------------------
+
+ @Override
+ @Test
+ public void testVisitWhileLoop_Do_1()
+ {
+ IWhileLoopNode node = (IWhileLoopNode) getNode(
+ "do {a++;--b;} while(a > b);", IWhileLoopNode.class);
+ asBlockWalker.visitWhileLoop(node);
+ assertOut("do {\n a++;\n --b;\n} while (a > b);");
+ }
+
+ @Override
+ @Test
+ public void testVisitWhileLoop_Do_1a()
+ {
+ IWhileLoopNode node = (IWhileLoopNode) getNode("do a++; while(a > b);",
+ IWhileLoopNode.class);
+ asBlockWalker.visitWhileLoop(node);
+ assertOut("do\n a++;\nwhile (a > b);");
+ }
+
+ //----------------------------------
+ // 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 : for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n{\n break foo;\n}}\n");
+ }
+
+ @Override
+ @Test
+ public void testVisitLabel_1a()
+ {
+ // TODO (mschmalle) LabelStatement messes up in finally{} block, something is wrong there
+ LabeledStatementNode node = (LabeledStatementNode) getNode(
+ "foo: for each(var i:int in obj) break foo;",
+ LabeledStatementNode.class);
+ asBlockWalker.visitLabeledStatement(node);
+ assertOut("foo : for (var foreachiter0 in obj) \n{\nvar i = obj[foreachiter0];\n\n break foo;}\n");
+ }
+
+ //----------------------------------
+ // with () {}
+ //----------------------------------
+
+ @Test
+ public void testVisitWith()
+ {
+ IWithNode node = (IWithNode) getNode("with (a) { b; }", IWithNode.class);
+ asBlockWalker.visitWith(node);
+ assertOut("with (a) {\n b;\n}");
+ }
+
+ @Test
+ public void testVisitWith_1a()
+ {
+ IWithNode node = (IWithNode) getNode("with (a) b;", IWithNode.class);
+ asBlockWalker.visitWith(node);
+ assertOut("with (a)\n b;");
+ }
+
+ @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("/**\n * FalconTest_A\n *\n * @fileoverview\n *\n * @suppress {checkTypes}\n */\n\ngoog.provide('FalconTest_A');\n\n\n\n/**\n * @constructor\n */\nFalconTest_A = function() {\n};\n\n\nFalconTest_A.prototype.falconTest_a = function() {\n try {\n a;\n } catch (e) {\n if (a) {\n if (b) {\n if (c)\n b;\n else if (f)\n a;\n else\n e;\n }\n }\n } finally {\n }\n if (d)\n for (var /** @type {number} */ i = 0; i < len; i++)\n break;\n if (a) {\n with (ab) {\n c();\n }\n do {\n a++;\n do\n a++;\n while (a > b);\n } while (c > d);\n }\n if (b) {\n try {\n a;\n throw new Error('foo');\n } catch (e) {\n switch (i) {\n case 1:\n break;\n default:\n return;\n }\n } finally {\n d;\n var /** @type {Object} */ a = function(foo, bar) {\n bar = typeof bar !== 'undefined' ? bar : 'goo';\n
return -1;\n };\n eee.dd;\n eee.dd;\n eee.dd;\n eee.dd;\n }\n }\n foo : for (var foreachiter0 in obj) \n {\n var i = obj[foreachiter0];\n \n break foo;}\n ;\n};\n\n\n/**\n * Metadata\n *\n * @type {Object.<string, Array.<Object>>}\n */\nFalconTest_A.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'FalconTest_A', qName: 'FalconTest_A'}] };\n");
+ }
+
+ @Override
+ protected IBackend createBackend()
+ {
+ return new VF2JSBackend();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/26117b18/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java
index 6ecadfa..376e95d 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/vf2js/TestVF2JSMXMLApplication.java
@@ -18,15 +18,29 @@
*/
package org.apache.flex.compiler.internal.codegen.mxml.vf2js;
-import org.apache.flex.compiler.internal.test.VF2JSTestBase;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.flex.compiler.internal.test.VF2JSMXMLTestBase;
import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
-import org.junit.Ignore;
+import org.apache.flex.utils.FilenameNormalization;
import org.junit.Test;
-public class TestVF2JSMXMLApplication extends VF2JSTestBase
+public class TestVF2JSMXMLApplication extends VF2JSMXMLTestBase
{
- @Ignore
+ @Override
+ protected void addSourcePaths(List<File> sourcePaths)
+ {
+ sourcePaths.add(new File(FilenameNormalization.normalize("test-files/vf2js/files")));
+ sourcePaths.add(new File(FilenameNormalization.normalize("test-files/vf2js/projects/simpleMXML/src")));
+
+ super.addSourcePaths(sourcePaths);
+ }
+
@Test
public void testSimple()
{
@@ -42,4 +56,39 @@ public class TestVF2JSMXMLApplication extends VF2JSTestBase
assertOut(getCodeFromFile(fileName + "_result", true, "vf2js/files"));
}
+
+ @Test
+ public void testSimpleMXMLProject()
+ {
+ String testDirPath = "vf2js/projects/simpleMXML/src";
+
+ String fileName = "SimpleMXML_Project";
+
+ List<String> compiledFileNames = compileProject(fileName, testDirPath);
+
+ assertProjectOut(compiledFileNames, testDirPath);
+ }
+
+ protected void assertProjectOut(List<String> compiledFileNames,
+ String testDirPath)
+ {
+ 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("test-files").getAbsolutePath()
+ + File.separator + testDirPath + File.separator
+ + compiledFileName + "_result" + "."
+ + backend.getOutputExtension();
+ String expectedResult = readCodeFile(new File(expectedFilePath));
+
+ assertThat(compiledResult, is(expectedResult));
+ }
+ }
}