Prepare test for AS side of VF2JS. Signed-off-by: Erik de Bruin <e...@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/1964615a Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/1964615a Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/1964615a Branch: refs/heads/develop Commit: 1964615a0f68d63e6f7f47c1b451319bf14aaac0 Parents: c8e8929 Author: Erik de Bruin <e...@ixsoftware.nl> Authored: Tue Jul 1 11:18:37 2014 +0200 Committer: Erik de Bruin <e...@ixsoftware.nl> Committed: Fri Aug 1 12:59:15 2014 +0200 ---------------------------------------------------------------------- .../codegen/js/vf2js/TestVF2JSFile.java | 61 ++++++++++++++++++++ .../test-files/vf2js/files/SimpleAS.as | 39 +++++++++++++ .../test-files/vf2js/files/SimpleAS_result.js | 47 +++++++++++++++ 3 files changed, 147 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1964615a/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 new file mode 100644 index 0000000..5de3ecc --- /dev/null +++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/vf2js/TestVF2JSFile.java @@ -0,0 +1,61 @@ +/* + * + * 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 java.io.File; + +import org.apache.flex.compiler.driver.IBackend; +import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend; +import org.apache.flex.compiler.internal.test.VF2JSTestBase; +import org.apache.flex.compiler.tree.as.IFileNode; +import org.junit.Test; + +/** + * This class tests the production of valid 'goog' JS code from an external + * file. + * + * @author Erik de Bruin + */ +public class TestVF2JSFile extends VF2JSTestBase +{ + @Test + public void testSimple() + { + String fileName = "SimpleAS"; + + IFileNode node = compileAS(fileName, true, + "test-files" + + File.separator + "vf2js" + File.separator + "files", + false); + + asBlockWalker.visitFile(node); + + writeResultToFile(writer.toString(), fileName); + + assertOut(getCodeFromFile(fileName + "_result", true, + "vf2js" + File.separator + "files")); + } + + @Override + protected IBackend createBackend() + { + return new FlexJSBackend(); + } +} http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1964615a/compiler.jx.tests/test-files/vf2js/files/SimpleAS.as ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/vf2js/files/SimpleAS.as b/compiler.jx.tests/test-files/vf2js/files/SimpleAS.as new file mode 100644 index 0000000..fd9baf3 --- /dev/null +++ b/compiler.jx.tests/test-files/vf2js/files/SimpleAS.as @@ -0,0 +1,39 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + +import flash.events.IEventDispatcher; + +import spark.components.Button; + +public dynamic class A extends spark.components.Button implements IEventDispatcher +{ + public static const MY_CLASS_CONST:String = "myClassConst"; + + public function A() + { + trace(typeof "a"); + } + + private var _a:ArgumentError = new ArgumentError(); + + public const MY_INSTANCE_CONST:String = "myInstanceConst"; +} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1964615a/compiler.jx.tests/test-files/vf2js/files/SimpleAS_result.js ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/test-files/vf2js/files/SimpleAS_result.js b/compiler.jx.tests/test-files/vf2js/files/SimpleAS_result.js new file mode 100644 index 0000000..e6ef05a --- /dev/null +++ b/compiler.jx.tests/test-files/vf2js/files/SimpleAS_result.js @@ -0,0 +1,47 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +goog.provide('org.apache.flex.A'); + +goog.require('flash.events.IEventDispatcher'); +goog.require('spark.components.Button'); + +/** + * @constructor + * @extends {spark.components.Button} + * @implements {flash.events.IEventDispatcher} + */ +org.apache.flex.A = function() { + var self = this; + goog.base(this); + self.trace(typeof("a")); +} +goog.inherits(org.apache.flex.A, spark.components.Button); + +/** + * @const + * @type {string} + */ +org.apache.flex.A.MY_CLASS_CONST = "myClassConst"; + +/** + * @private + * @type {ArgumentError} + */ +org.apache.flex.A.prototype._a = new ArgumentError(); + +/** + * @const + * @type {string} + */ +org.apache.flex.A.prototype.MY_INSTANCE_CONST = "myInstanceConst"; \ No newline at end of file