flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mschma...@apache.org
Subject svn commit: r1452955 [3/9] - in /flex/falcon/trunk: compiler.jx.tests/src/org/apache/flex/compiler/internal/as/ compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/ compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/as/ compile...
Date Tue, 05 Mar 2013 19:22:09 GMT
Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,132 @@
+/*
+ *
+ *  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 spark.components.Button;"
+                + "public class MyTextButton extends Button {"
+                + "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("goog.provide('com.example.components.MyTextButton');\n\ngoog.require('spark.components.Button');\n\n/**\n * @constructor\n * @extends {spark.components.Button}\n */\ncom.example.components.MyTextButton = function() {\n\tvar self = this;\n\tgoog.base(this);\n\tif (foo() != 42) {\n\t\tbar();\n\t}\n}\ngoog.inherits(com.example.components.MyTextButton, spark.components.Button);\n\n/**\n * @private\n * @type {string}\n */\ncom.example.components.MyTextButton.prototype._privateVar = \"do \";\n\n/**\n * @type {number}\n */\ncom.example.components.MyTextButton.prototype.publicProperty = 100;\n\n/**\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyTextButton.prototype.myFunction = function(value) {\n\tvar self = this;\n\treturn \"Don't \" + self._privateVar + value;\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 = getMethodWithPackage("function method1(bar:int):int{\n}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {number} bar\n * @return {number}\n */\n"
+                + "foo.bar.A.prototype.method1 = function(bar) {\n}");
+    }
+
+    @Test
+    public void testSimpleMultipleParameter()
+    {
+        IFunctionNode node = getMethodWithPackage("function method1(bar:int, baz:String, goo:A):void{\n}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {number} bar\n * @param {string} baz\n * @param {foo.bar.A} goo\n */\n"
+                + "foo.bar.A.prototype.method1 = function(bar, baz, goo) {\n}");
+    }
+
+    @Test
+    public void testSimpleMultipleParameter_JSDoc()
+    {
+        IFunctionNode node = getMethodWithPackage("function method1(bar:int, baz:String, goo:A):void{\n}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {number} bar\n * @param {string} baz\n * @param {foo.bar.A} goo\n */\n"
+                + "foo.bar.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.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.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.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();
+    }
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmiter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogExpressions.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogExpressions.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogExpressions.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogExpressions.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,175 @@
+/*
+ *
+ *  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.codegen.as.TestExpressions;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.internal.tree.as.NamespaceAccessExpressionNode;
+import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IIfNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Test;
+
+/**
+ * @author Michael Schmalle
+ * @author Erik de Bruin
+ */
+public class TestGoogExpressions extends TestExpressions
+{
+    @Override
+    @Test
+    public void testVisitLanguageIdentifierNode_SuperMethod_1()
+    {
+        IFunctionNode node = getMethod("function foo(){if (a) super.foo();}");
+        asBlockWalker.visitFunction(node);
+        assertOut("A.prototype.foo = function() {\n\tvar self = this;\n\tif (a)\n\t\tgoog.base(this, 'foo');\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitLanguageIdentifierNode_SuperMethod_2()
+    {
+        IFunctionNode node = getMethod("function foo(){if (a) super.foo(a, b, c);}");
+        asBlockWalker.visitFunction(node);
+        assertOut("A.prototype.foo = function() {\n\tvar self = this;\n\tif (a)\n\t\tgoog.base(this, 'foo', a, b, c);\n}");
+    }
+
+    //----------------------------------
+    // Primary expression keywords
+    //----------------------------------
+
+    //----------------------------------
+    // Logical
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitBinaryOperatorNode_LogicalAndAssignment()
+    {
+        IBinaryOperatorNode node = getBinaryNode("a &&= b");
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("a = a && b");
+    }
+
+    @Override
+    @Test
+    public void testVisitBinaryOperatorNode_LogicalOrAssignment()
+    {
+        IBinaryOperatorNode node = getBinaryNode("a ||= b");
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("a = a || b");
+    }
+
+    //----------------------------------
+    // Other
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testAnonymousFunction()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a = function(){};",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {*} */ a = function() {\n}");
+    }
+
+    @Override
+    @Test
+    public void testAnonymousFunctionWithParamsReturn()
+    {
+        IVariableNode node = (IVariableNode) getNode(
+                "var a:Object = function(foo:int, bar:String = 'goo'):int{return -1;};",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Object} */ a = function(foo, bar) {\n\tvar self = this;\n\tbar = typeof bar !== 'undefined' ? bar : 'goo';\n\treturn -1;\n}");
+    }
+
+    @Override
+    @Test
+    public void testAnonymousFunctionAsArgument()
+    {
+        // TODO (mschmalle) using IIfNode in expressions test, any other way to do this without statement?
+        IIfNode node = (IIfNode) getNode(
+                "if (a) {addListener('foo', function(event:Object):void{doit();});}",
+                IIfNode.class);
+        asBlockWalker.visitIf(node);
+        assertOut("if (a) {\n\taddListener('foo', function(event) {\n\t\tvar self = this;\n\t\tdoit();\n\t});\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitAs()
+    {
+        IBinaryOperatorNode node = getBinaryNode("a as b");
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("(is(a, b) ? a : null)");
+    }
+
+    @Override
+    @Test
+    public void testVisitBinaryOperator_Instancof()
+    {
+        IBinaryOperatorNode node = getBinaryNode("a instanceof b");
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("a instanceof b");
+    }
+
+    @Override
+    @Test
+    public void testVisitBinaryOperator_Is()
+    {
+        IBinaryOperatorNode node = getBinaryNode("a is b");
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("is(a, b)");
+    }
+
+    @Override
+    @Test
+    public void testVisitBinaryOperator_NamespaceAccess_1()
+    {
+        // TODO (mschmalle) this needs INamespaceAccessExpressionNode interface
+        // TODO (erikdebruin) we need a 'goog.require("a")' in the header
+        NamespaceAccessExpressionNode node = (NamespaceAccessExpressionNode) getExpressionNode(
+                "a::b", NamespaceAccessExpressionNode.class);
+        asBlockWalker.visitNamespaceAccessExpression(node);
+        assertOut("a.b");
+    }
+
+    @Override
+    @Test
+    public void testVisitBinaryOperator_NamespaceAccess_2()
+    {
+        // TODO (mschmalle) this needs INamespaceAccessExpressionNode interface
+        // TODO (erikdebruin) we need a 'goog.require("a.b")' in the header
+        NamespaceAccessExpressionNode node = (NamespaceAccessExpressionNode) getExpressionNode(
+                "a::b::c", NamespaceAccessExpressionNode.class);
+        asBlockWalker.visitNamespaceAccessExpression(node);
+        assertOut("a.b.c");
+    }
+
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogExpressions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogFieldMembers.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogFieldMembers.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogFieldMembers.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogFieldMembers.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,226 @@
+/*
+ *
+ *  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.codegen.as.TestFieldMembers;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Test;
+
+/**
+ * This class tests the production of 'goog' JavaScript for Class Field members.
+ * 
+ * @author Michael Schmalle
+ * @author Erik de Bruin
+ */
+public class TestGoogFieldMembers extends TestFieldMembers
+{
+    //--------------------------------------------------------------------------
+    // Fields
+    //--------------------------------------------------------------------------
+
+    @Override
+    @Test
+    public void testField()
+    {
+        IVariableNode node = getField("var foo;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @type {*}\n */\nA.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testField_withType()
+    {
+        IVariableNode node = getField("var foo:int;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @type {number}\n */\nA.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testField_withTypeValue()
+    {
+        IVariableNode node = getField("var foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @type {number}\n */\nA.prototype.foo = 420");
+    }
+
+    @Test
+    public void testField_withTypeValue_Negative()
+    {
+        IVariableNode node = getField("var foo:int = -420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @type {number}\n */\nA.prototype.foo = -420");
+    }
+
+    @Override
+    @Test
+    public void testField_withNamespaceTypeValue()
+    {
+        IVariableNode node = getField("private var foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @private\n * @type {number}\n */\nA.prototype.foo = 420");
+    }
+
+    @Override
+    @Test
+    public void testField_withCustomNamespaceTypeValue()
+    {
+        IVariableNode node = getField("mx_internal var foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        // (erikdebruin) we ignore custom namespaces completely (are there side effects I'm missing?)
+        assertOut("/**\n * @type {number}\n */\nA.prototype.foo = 420");
+    }
+
+    @Override
+    @Test
+    public void testField_withNamespaceTypeCollection()
+    {
+        IVariableNode node = getField("protected var foo:Vector.<Foo>;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @protected\n * @type {Vector.<Foo>}\n */\nA.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testField_withNamespaceTypeCollectionComplex()
+    {
+        IVariableNode node = getField("protected var foo:Vector.<Vector.<Vector.<Foo>>>;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @protected\n * @type {Vector.<Vector.<Vector.<Foo>>>}\n */\nA.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testField_withNamespaceTypeValueComplex()
+    {
+        IVariableNode node = getField("protected var foo:Foo = new Foo('bar', 42);");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @protected\n * @type {Foo}\n */\nA.prototype.foo = new Foo('bar', 42)");
+    }
+
+    @Override
+    @Test
+    public void testField_withList()
+    {
+        IVariableNode node = getField("protected var a:int = 4, b:int = 11, c:int = 42;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @protected\n * @type {number}\n */\nA.prototype.a = 4;\n\n/**\n * @protected\n * @type {number}\n */\nA.prototype.b = 11;\n\n/**\n * @protected\n * @type {number}\n */\nA.prototype.c = 42");
+    }
+
+    //--------------------------------------------------------------------------
+    // Constants
+    //--------------------------------------------------------------------------
+
+    @Override
+    @Test
+    public void testConstant()
+    {
+        IVariableNode node = getField("static const foo;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @const\n * @type {*}\n */\nA.foo");
+    }
+
+    @Test
+    public void testConstant_nonStatic()
+    {
+        IVariableNode node = getField("const foo;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @const\n * @type {*}\n */\nA.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testConstant_withType()
+    {
+        IVariableNode node = getField("static const foo:int;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @const\n * @type {number}\n */\nA.foo");
+    }
+
+    @Test
+    public void testConstant_withType_nonStatic()
+    {
+        IVariableNode node = getField("const foo:int;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @const\n * @type {number}\n */\nA.prototype.foo");
+    }
+
+    @Override
+    @Test
+    public void testConstant_withTypeValue()
+    {
+        IVariableNode node = getField("static const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @const\n * @type {number}\n */\nA.foo = 420");
+    }
+
+    @Test
+    public void testConstant_withTypeValue_nonStatic()
+    {
+        IVariableNode node = getField("const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @const\n * @type {number}\n */\nA.prototype.foo = 420");
+    }
+
+    @Override
+    @Test
+    public void testConstant_withNamespaceTypeValue()
+    {
+        IVariableNode node = getField("private static const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @private\n * @const\n * @type {number}\n */\nA.foo = 420");
+    }
+
+    @Test
+    public void testConstant_withNamespaceTypeValue_nonStatic()
+    {
+        IVariableNode node = getField("private const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @private\n * @const\n * @type {number}\n */\nA.prototype.foo = 420");
+    }
+
+    @Override
+    @Test
+    public void testConstant_withCustomNamespaceTypeValue()
+    {
+        IVariableNode node = getField("mx_internal static const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        // (erikdebruin) we ignore custom namespaces completely (are there side effects I'm missing?)
+        assertOut("/**\n * @const\n * @type {number}\n */\nA.foo = 420");
+    }
+
+    @Test
+    public void testConstant_withCustomNamespaceTypeValue_nonStatic()
+    {
+        IVariableNode node = getField("mx_internal const foo:int = 420;");
+        asBlockWalker.visitVariable(node);
+        // (erikdebruin) we ignore custom namespaces completely (are there side effects I'm missing?)
+        assertOut("/**\n * @const\n * @type {number}\n */\nA.prototype.foo = 420");
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogFieldMembers.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogFile.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogFile.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogFile.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogFile.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,93 @@
+/*
+ *
+ *  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 java.io.File;
+
+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.junit.Test;
+
+/**
+ * This class tests the production of valid 'goog' JS code from an external
+ * file.
+ * 
+ * @author Erik de Bruin
+ */
+public class TestGoogFile extends ASTestBase
+{
+    @Test
+    public void testFile_plain()
+    {
+        IFileNode node = compileAS("input", true, "goog" + File.separator
+                + "files");
+        asBlockWalker.visitFile(node);
+        assertOut(getCodeFromFile("output", true, "goog" + File.separator
+                + "files"));
+    }
+
+    @Test
+    public void testFile_getset()
+    {
+        IFileNode node = compileAS("get-set", true, "goog" + File.separator
+                + "files");
+        asBlockWalker.visitFile(node);
+        assertOut(getCodeFromFile("get-set_result", true, "goog"
+                + File.separator + "files"));
+    }
+
+    @Test
+    public void testFile_callsuper()
+    {
+        IFileNode node = compileAS("call-super", true, "goog" + File.separator
+                + "files");
+        asBlockWalker.visitFile(node);
+        assertOut(getCodeFromFile("call-super_result", true, "goog"
+                + File.separator + "files"));
+    }
+
+    @Test
+    public void testFile_qualifynewobject()
+    {
+        IFileNode node = compileAS("qualify-new-object", true, "goog"
+                + File.separator + "files");
+        asBlockWalker.visitFile(node);
+        assertOut(getCodeFromFile("qualify-new-object_result", true, "goog"
+                + File.separator + "files"));
+    }
+
+    @Test
+    public void testFile_poc()
+    {
+        IFileNode node = compileAS("poc", true, "goog" + File.separator
+                + "files");
+        asBlockWalker.visitFile(node);
+        assertOut(getCodeFromFile("poc_result", true, "goog" + File.separator
+                + "files"));
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogFile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalClasses.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalClasses.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalClasses.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalClasses.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,322 @@
+/*
+ *
+ *  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.codegen.as.TestGlobalClasses;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Erik de Bruin
+ */
+public class TestGoogGlobalClasses extends TestGlobalClasses
+{
+    @Override
+    @Test
+    public void testArgumentError()
+    {
+        IVariableNode node = getVariable("var a:ArgumentError = new ArgumentError();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {ArgumentError} */ a = new ArgumentError()");
+    }
+
+    @Override
+    @Test
+    public void testArguments()
+    {
+        IFunctionNode node = getMethod("function a():void {\ttrace(arguments);}");
+        asBlockWalker.visitFunction(node);
+        assertOut("A.prototype.a = function() {\n\tvar self = this;\n\ttrace(arguments);\n}");
+    }
+
+    @Override
+    @Test
+    public void testArray()
+    {
+        IVariableNode node = getVariable("var a:Array = new Array(1);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Array} */ a = new Array(1)");
+    }
+
+    @Override
+    @Test
+    public void testBoolean()
+    {
+        IVariableNode node = getVariable("var a:Boolean = new Boolean(1);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {boolean} */ a = new Boolean(1)");
+    }
+
+    @Override
+    @Test
+    public void testClass()
+    {
+        IVariableNode node = getVariable("var a:Class = new Class();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Class} */ a = new Class()");
+    }
+
+    @Override
+    @Test
+    public void testDate()
+    {
+        IVariableNode node = getVariable("var a:Date = new Date();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Date} */ a = new Date()");
+    }
+
+    @Override
+    @Test
+    public void testDefinitionError()
+    {
+        IVariableNode node = getVariable("var a:DefinitionError = new DefinitionError();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {DefinitionError} */ a = new DefinitionError()");
+    }
+
+    @Override
+    @Test
+    public void testError()
+    {
+        IVariableNode node = getVariable("var a:Error = new Error();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Error} */ a = new Error()");
+    }
+
+    @Override
+    @Test
+    public void testEvalError()
+    {
+        IVariableNode node = getVariable("var a:EvalError = new EvalError();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {EvalError} */ a = new EvalError()");
+    }
+
+    @Override
+    @Test
+    public void testFunction()
+    {
+        IVariableNode node = getVariable("var a:Function = new Function();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Function} */ a = new Function()");
+    }
+
+    @Override
+    @Test
+    public void testInt()
+    {
+        IVariableNode node = getVariable("var a:int = new int(1.8);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a = new int(1.8)");
+    }
+
+    @Override
+    @Test
+    public void testJSON()
+    {
+        IVariableNode node = getVariable("var a:JSON = new JSON();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {JSON} */ a = new JSON()");
+    }
+
+    @Override
+    @Test
+    public void testMath()
+    {
+        IVariableNode node = getVariable("var a:Number = Math.PI;");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a = Math.PI");
+    }
+
+    @Override
+    @Test
+    public void testNamespace()
+    {
+        IVariableNode node = getVariable("var a:Namespace = new Namespace(\"http://example.com\");");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Namespace} */ a = new Namespace(\"http://example.com\")");
+    }
+
+    @Override
+    @Test
+    public void testNumber()
+    {
+        IVariableNode node = getVariable("var a:Number = new Number(\"1\");");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a = new Number(\"1\")");
+    }
+
+    @Override
+    @Test
+    public void testObject()
+    {
+        IVariableNode node = getVariable("var a:Object = new Object();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Object} */ a = new Object()");
+    }
+
+    @Override
+    @Test
+    public void testQName()
+    {
+        IVariableNode node = getVariable("var a:QName = new QName();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {QName} */ a = new QName()");
+    }
+
+    @Override
+    @Test
+    public void testRangeError()
+    {
+        IVariableNode node = getVariable("var a:RangeError = new RangeError();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {RangeError} */ a = new RangeError()");
+    }
+
+    @Override
+    @Test
+    public void testReferenceError()
+    {
+        IVariableNode node = getVariable("var a:ReferenceError = new ReferenceError();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {ReferenceError} */ a = new ReferenceError()");
+    }
+
+    @Ignore
+    @Override
+    @Test
+    public void testRegExp()
+    {
+        // TODO (mschmalle) how to handle the escaping of backslashes in
+        //                    strings in the tests?
+        IVariableNode node = getVariable("var a:RegExp = new RegExp('test-\\d', 'i');");
+        asBlockWalker.visitVariable(node);
+        assertOut("var a:RegExp = new RegExp('test-\\\\d', 'i')");
+    }
+
+    @Override
+    @Test
+    public void testRegExp_Literal()
+    {
+        IVariableNode node = getVariable("var a:RegExp = /test-\\d/i;");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {RegExp} */ a = /test-\\d/i");
+    }
+
+    @Override
+    @Test
+    public void testSecurityError()
+    {
+        IVariableNode node = getVariable("var a:SecurityError = new SecurityError();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {SecurityError} */ a = new SecurityError()");
+    }
+
+    @Override
+    @Test
+    public void testString()
+    {
+        IVariableNode node = getVariable("var a:String = new String(\"100\");");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {string} */ a = new String(\"100\")");
+    }
+
+    @Override
+    @Test
+    public void testSyntaxError()
+    {
+        IVariableNode node = getVariable("var a:SyntaxError = new SyntaxError();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {SyntaxError} */ a = new SyntaxError()");
+    }
+
+    @Override
+    @Test
+    public void testTypeError()
+    {
+        IVariableNode node = getVariable("var a:TypeError = new TypeError();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {TypeError} */ a = new TypeError()");
+    }
+
+    @Override
+    @Test
+    public void testUint()
+    {
+        IVariableNode node = getVariable("var a:uint = new uint(-100);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a = new uint(-100)");
+    }
+
+    @Override
+    @Test
+    public void testURIError()
+    {
+        IVariableNode node = getVariable("var a:URIError = new URIError();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {URIError} */ a = new URIError()");
+    }
+
+    @Override
+    @Test
+    public void testVector()
+    {
+        IVariableNode node = getVariable("var a:Vector.<String> = new Vector.<String>(['Hello', 'World']);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Vector.<string>} */ a = new Vector(['Hello', 'World'])");
+    }
+
+    @Override
+    @Test
+    public void testVerifyError()
+    {
+        IVariableNode node = getVariable("var a:VerifyError = new VerifyError();");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {VerifyError} */ a = new VerifyError()");
+    }
+
+    @Override
+    @Test
+    public void testXML()
+    {
+        IVariableNode node = getVariable("var a:XML = new XML('@');");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {XML} */ a = new XML('@')");
+    }
+
+    @Override
+    @Test
+    public void testXMLList()
+    {
+        IVariableNode node = getVariable("var a:XMLList = new XMLList('<!-- comment -->');");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {XMLList} */ a = new XMLList('<!-- comment -->')");
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalClasses.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalConstants.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalConstants.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalConstants.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalConstants.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,74 @@
+/*
+ *
+ *  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.codegen.as.TestGlobalConstants;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Test;
+
+/**
+ * @author Erik de Bruin
+ */
+public class TestGoogGlobalConstants extends TestGlobalConstants
+{
+    @Override
+    @Test
+    public void testInfinity()
+    {
+        IVariableNode node = getField("var a:Number = Infinity;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @type {number}\n */\nA.prototype.a = Infinity");
+    }
+
+    @Override
+    @Test
+    public void testNegativeInfinity()
+    {
+        IVariableNode node = getField("var a:Number = -Infinity;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @type {number}\n */\nA.prototype.a = -Infinity");
+    }
+
+    @Override
+    @Test
+    public void testNaN()
+    {
+        IVariableNode node = getField("var a:Number = NaN;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @type {number}\n */\nA.prototype.a = NaN");
+    }
+
+    @Override
+    @Test
+    public void testUndefined()
+    {
+        IVariableNode node = getField("var a:* = undefined;");
+        asBlockWalker.visitVariable(node);
+        assertOut("/**\n * @type {*}\n */\nA.prototype.a = undefined");
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalFunctions.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalFunctions.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalFunctions.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalFunctions.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,238 @@
+/*
+ *
+ *  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.codegen.as.TestGlobalFunctions;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.tree.as.IFunctionCallNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Test;
+
+/**
+ * @author Erik de Bruin
+ */
+public class TestGoogGlobalFunctions extends TestGlobalFunctions
+{
+    @Override
+    @Test
+    public void testArray()
+    {
+        IVariableNode node = getVariable("var a:Array = Array(1);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Array} */ a = Array(1)");
+    }
+
+    @Override
+    @Test
+    public void testBoolean()
+    {
+        IVariableNode node = getVariable("var a:Boolean = Boolean(1);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {boolean} */ a = Boolean(1)");
+    }
+
+    @Override
+    @Test
+    public void testDecodeURI()
+    {
+        IVariableNode node = getVariable("var a:String = decodeURI('http://whatever.com');");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {string} */ a = decodeURI('http://whatever.com')");
+    }
+
+    @Override
+    @Test
+    public void testDecodeURIComponent()
+    {
+        IVariableNode node = getVariable("var a:String = decodeURIComponent('http://whatever.com');");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {string} */ a = decodeURIComponent('http://whatever.com')");
+    }
+
+    @Override
+    @Test
+    public void testEncodeURI()
+    {
+        IVariableNode node = getVariable("var a:String = encodeURI('http://whatever.com');");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {string} */ a = encodeURI('http://whatever.com')");
+    }
+
+    @Override
+    @Test
+    public void testEncodeURIComponent()
+    {
+        IVariableNode node = getVariable("var a:String = encodeURIComponent('http://whatever.com');");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {string} */ a = encodeURIComponent('http://whatever.com')");
+    }
+
+    @Override
+    @Test
+    public void testEscape()
+    {
+        IVariableNode node = getVariable("var a:String = escape('http://whatever.com');");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {string} */ a = escape('http://whatever.com')");
+    }
+
+    @Override
+    @Test
+    public void testInt()
+    {
+        IVariableNode node = getVariable("var a:int = int(1.8);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a = int(1.8)");
+    }
+
+    @Override
+    @Test
+    public void testIsFinite()
+    {
+        IVariableNode node = getVariable("var a:Boolean = isFinite(1000000.9);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {boolean} */ a = isFinite(1000000.9)");
+    }
+
+    @Override
+    @Test
+    public void testIsNaN()
+    {
+        IVariableNode node = getVariable("var a:Boolean = isNaN(NaN);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {boolean} */ a = isNaN(NaN)");
+    }
+
+    @Override
+    @Test
+    public void testIsXMLName()
+    {
+        IVariableNode node = getVariable("var a:Boolean = isXMLName(\"?\");");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {boolean} */ a = isXMLName(\"?\")");
+    }
+
+    @Override
+    @Test
+    public void testNumber()
+    {
+        IVariableNode node = getVariable("var a:Number = Number(\"1\");");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a = Number(\"1\")");
+    }
+
+    @Override
+    @Test
+    public void testObject()
+    {
+        IVariableNode node = getVariable("var a:Object = Object(\"1\");");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Object} */ a = Object(\"1\")");
+    }
+
+    @Override
+    @Test
+    public void testParseFloat()
+    {
+        IVariableNode node = getVariable("var a:Number = parseFloat(\"1.8\");");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a = parseFloat(\"1.8\")");
+    }
+
+    @Override
+    @Test
+    public void testParseInt()
+    {
+        IVariableNode node = getVariable("var a:Number = parseInt(\"666\", 10);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a = parseInt(\"666\", 10)");
+    }
+
+    @Override
+    @Test
+    public void testString()
+    {
+        IVariableNode node = getVariable("var a:String = String(100);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {string} */ a = String(100)");
+    }
+
+    @Override
+    @Test
+    public void testTrace()
+    {
+        IFunctionCallNode node = (IFunctionCallNode) getNode(
+                "trace('Hello World');", IFunctionCallNode.class);
+        asBlockWalker.visitFunctionCall(node);
+        assertOut("trace('Hello World')");
+    }
+
+    @Override
+    @Test
+    public void testUint()
+    {
+        IVariableNode node = getVariable("var a:uint = uint(-100);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a = uint(-100)");
+    }
+
+    @Override
+    @Test
+    public void testUnescape()
+    {
+        IVariableNode node = getVariable("var a:String = unescape('%25');");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {string} */ a = unescape('%25')");
+    }
+
+    @Override
+    @Test
+    public void testVector()
+    {
+        IVariableNode node = getVariable("var a:Vector.<String> = Vector.<String>(['Hello', 'World']);");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Vector.<string>} */ a = Vector(['Hello', 'World'])");
+    }
+
+    @Override
+    @Test
+    public void testXML()
+    {
+        IVariableNode node = getVariable("var a:XML = XML('@');");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {XML} */ a = XML('@')");
+    }
+
+    @Override
+    @Test
+    public void testXMLList()
+    {
+        IVariableNode node = getVariable("var a:XMLList = XMLList('<!-- comment -->');");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {XMLList} */ a = XMLList('<!-- comment -->')");
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogGlobalFunctions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogInterface.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogInterface.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogInterface.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogInterface.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,113 @@
+/*
+ *
+ *  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.codegen.as.TestInterface;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.tree.as.IInterfaceNode;
+import org.junit.Test;
+
+/**
+ * This class tests the production of valid 'goog' JS code for Interface
+ * production.
+ * 
+ * @author Michael Schmalle
+ * @author Erik de Bruin
+ */
+public class TestGoogInterface extends TestInterface
+{
+    @Override
+    @Test
+    public void testSimple()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA{}");
+        asBlockWalker.visitInterface(node);
+        assertOut("/**\n * @interface\n */\npublic interface IA {\n}");
+    }
+
+    @Override
+    @Test
+    public void testSimpleExtends()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA extends IB{}");
+        asBlockWalker.visitInterface(node);
+        assertOut("/**\n * @interface\n * @extends {IB}\n */\npublic interface IA {\n}");
+    }
+
+    @Override
+    @Test
+    public void testSimpleExtendsMultiple()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA extends IB, IC, ID {}");
+        asBlockWalker.visitInterface(node);
+        assertOut("/**\n * @interface\n * @extends {IB}\n * @extends {IC}\n * @extends {ID}\n */\npublic interface IA {\n}");
+    }
+
+    @Override
+    @Test
+    public void testQualifiedExtendsMultiple()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA extends foo.bar.IB, baz.goo.IC, foo.ID {}");
+        asBlockWalker.visitInterface(node);
+        assertOut("/**\n * @interface\n * @extends {foo.bar.IB}\n * @extends {baz.goo.IC}\n * @extends {foo.ID}\n */\npublic interface IA {\n}");
+    }
+
+    @Override
+    @Test
+    public void testAccessors()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA {"
+                + "function get foo1():Object;"
+                + "function set foo1(value:Object):void;}");
+        asBlockWalker.visitInterface(node);
+        assertOut("/**\n * @interface\n */\npublic interface IA {\n}\nIA.prototype.foo1;");
+    }
+
+    @Override
+    @Test
+    public void testMethods()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA {"
+                + "function baz1():Object;"
+                + "function baz2(value:Object):void;}");
+        asBlockWalker.visitInterface(node);
+        assertOut("/**\n * @interface\n */\npublic interface IA {\n}\nIA.prototype.baz1 = function();\nIA.prototype.baz2 = function(value);");
+    }
+
+    @Override
+    @Test
+    public void testAccessorsMethods()
+    {
+        IInterfaceNode node = getInterfaceNode("public interface IA {"
+                + "function get foo1():Object;"
+                + "function set foo1(value:Object):void;"
+                + "function baz1():Object;"
+                + "function baz2(value:Object):void;}");
+        asBlockWalker.visitInterface(node);
+        assertOut("/**\n * @interface\n */\npublic interface IA {\n}\nIA.prototype.foo1;\nIA.prototype.baz1 = function();\nIA.prototype.baz2 = function(value);");
+    }
+
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogInterface.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogMethodMembers.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogMethodMembers.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogMethodMembers.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogMethodMembers.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,183 @@
+/*
+ *
+ *  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.codegen.as.TestMethodMembers;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.junit.Test;
+
+/**
+ * This class tests the production of 'goog'-ified JS code for Class Method
+ * members.
+ * 
+ * @author Michael Schmalle
+ * @author Erik de Bruin
+ */
+public class TestGoogMethodMembers extends TestMethodMembers
+{
+    @Override
+    @Test
+    public void testMethod()
+    {
+        IFunctionNode node = getMethod("function foo(){}");
+        asBlockWalker.visitFunction(node);
+        assertOut("A.prototype.foo = function() {\n}");
+    }
+
+    @Override
+    @Test
+    public void testMethod_withReturnType()
+    {
+        IFunctionNode node = getMethod("function foo():int{\treturn -1;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @return {number}\n */\nA.prototype.foo = function() {\n\tvar self = this;\n\treturn -1;\n}");
+    }
+
+    @Override
+    @Test
+    public void testMethod_withParameterReturnType()
+    {
+        IFunctionNode node = getMethod("function foo(bar):int{\treturn -1;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {*} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\tvar self = this;\n\treturn -1;\n}");
+    }
+
+    @Override
+    @Test
+    public void testMethod_withParameterTypeReturnType()
+    {
+        IFunctionNode node = getMethod("function foo(bar:String):int{\treturn -1;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {string} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\tvar self = this;\n\treturn -1;\n}");
+    }
+
+    @Override
+    @Test
+    public void testMethod_withDefaultParameterTypeReturnType()
+    {
+        IFunctionNode node = getMethod("function foo(bar:String = \"baz\"):int{\treturn -1;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {string=} bar\n * @return {number}\n */\nA.prototype.foo = function(bar) {\n\tvar self = this;\n\tbar = typeof bar !== 'undefined' ? bar : \"baz\";\n\treturn -1;\n}");
+    }
+
+    @Override
+    @Test
+    public void testMethod_withMultipleDefaultParameterTypeReturnType()
+    {
+        IFunctionNode node = getMethod("function foo(bar:String, baz:int = null):int{\treturn -1;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+    }
+
+    @Override
+    @Test
+    public void testMethod_withRestParameterTypeReturnType()
+    {
+        IFunctionNode node = getMethod("function foo(bar:String, ...rest):int{\treturn -1;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {string} bar\n * @param {...} rest\n * @return {number}\n */\nA.prototype.foo = function(bar, rest) {\n\tvar self = this;\n\trest = Array.prototype.slice.call(arguments, 1);\n\treturn -1;\n}");
+    }
+
+    @Override
+    @Test
+    public void testMethod_withNamespace()
+    {
+        IFunctionNode node = getMethod("public function foo(bar:String, baz:int = null):int{\treturn -1;}");
+        asBlockWalker.visitFunction(node);
+        // we ignore the 'public' namespace completely
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+    }
+
+    @Override
+    @Test
+    public void testMethod_withNamespaceCustom()
+    {
+        IFunctionNode node = getMethod("mx_internal function foo(bar:String, baz:int = null):int{\treturn -1;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+    }
+
+    @Override
+    @Test
+    public void testMethod_withNamespaceModifiers()
+    {
+        IFunctionNode node = getMethod("public static function foo(bar:String, baz:int = null):int{\treturn -1;}");
+        asBlockWalker.visitFunction(node);
+        // (erikdebruin) here we actually DO want to declare the method
+        //               directly on the 'class' constructor instead of the
+        //               prototype!
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nA.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+    }
+
+    @Override
+    @Test
+    public void testMethod_withNamespaceModifierOverride()
+    {
+        IFunctionNode node = getMethod("public override function foo(bar:String, baz:int = null):int{\treturn -1;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nA.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+    }
+
+    @Override
+    @Test
+    public void testMethod_withNamespaceModifierOverrideBackwards()
+    {
+        IFunctionNode node = getMethod("override public function foo(bar:String, baz:int = null):int{return -1;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n * @override\n */\nA.prototype.foo = function(bar, baz) {\n\tvar self = this;\n\tbaz = typeof baz !== 'undefined' ? baz : null;\n\treturn -1;\n}");
+    }
+
+    //--------------------------------------------------------------------------
+    // Doc Specific Tests 
+    //--------------------------------------------------------------------------
+
+    @Test
+    public void testConstructor_withThisInBody()
+    {
+        IFunctionNode node = getMethod("public function A(){this.foo;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @constructor\n */\nA = function() {\n\tvar self = this;\n\tthis.foo;\n}");
+    }
+
+    @Test
+    public void testMethod_withThisInBody()
+    {
+        IFunctionNode node = getMethod("function foo(){this.foo;}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @this {A}\n */\nA.prototype.foo = function() {\n\tvar self = this;\n\tthis.foo;\n}");
+    }
+
+    @Test
+    public void testMethod_withThisInBodyComplex()
+    {
+        IFunctionNode node = getMethod("function foo(){if(true){while(i){this.bar(42);}}}");
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @this {A}\n */\nA.prototype.foo = function() {\n\tvar self = this;\n\tif (true) "
+                + "{\n\t\twhile (i) {\n\t\t\tthis.bar(42);\n\t\t}\n\t}\n}");
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogMethodMembers.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogPackage.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogPackage.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogPackage.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogPackage.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,112 @@
+/*
+ *
+ *  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.codegen.as.TestPackage;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.junit.Test;
+
+/**
+ * This class tests the production of 'goog' JavaScript for AS package.
+ * 
+ * @author Michael Schmalle
+ * @author Erik de Bruin
+ */
+public class TestGoogPackage extends TestPackage
+{
+    @Override
+    @Test
+    public void testPackage_Simple()
+    {
+        IFileNode node = compileAS("package{}");
+        asBlockWalker.visitFile(node);
+        assertOut("");
+    }
+
+    @Test
+    public void testPackage_SimpleName()
+    {
+        IFileNode node = compileAS("package foo {}");
+        asBlockWalker.visitFile(node);
+        assertOut("");
+    }
+
+    @Override
+    @Test
+    public void testPackage_Name()
+    {
+        IFileNode node = compileAS("package foo.bar.baz {}");
+        asBlockWalker.visitFile(node);
+        assertOut("");
+    }
+
+    @Override
+    @Test
+    public void testPackageSimple_Class()
+    {
+        // does JS need a implicit constructor function? ... always?
+        // All class nodes in AST get either an implicit or explicit constructor
+        // this is an implicit and the way I have the before/after handler working
+        // with block disallows implicit blocks from getting { }
+
+        // (erikdebruin) the constuctor IS the class definition, in 'goog' JS,
+        //               therefor we need to write out implicit constructors 
+        //               (if I understand the term correctly)
+
+        IFileNode node = compileAS("package {public class A{}}");
+        asBlockWalker.visitFile(node);
+        assertOut("goog.provide('A');\n\n/**\n * @constructor\n */\nA = function() {\n};");
+    }
+
+    @Override
+    @Test
+    public void testPackageQualified_Class()
+    {
+        IFileNode node = compileAS("package foo.bar.baz {public class A{}}");
+        asBlockWalker.visitFile(node);
+        assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n};");
+    }
+
+    @Override
+    @Test
+    public void testPackageQualified_ClassBody()
+    {
+        IFileNode node = compileAS("package foo.bar.baz {public class A{public function A(){}}}");
+        asBlockWalker.visitFile(node);
+        assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n};");
+    }
+
+    @Override
+    @Test
+    public void testPackageQualified_ClassBodyMethodContents()
+    {
+        IFileNode node = compileAS("package foo.bar.baz {public class A{public function A(){if (a){for (var i:Object in obj){doit();}}}}}");
+        asBlockWalker.visitFile(node);
+        assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n\tvar self = this;\n\tif (a) {\n\t\tfor (var /** @type {Object} */ i in obj) {\n\t\t\tdoit();\n\t\t}\n\t}\n};");
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogPackage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogStatements.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogStatements.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogStatements.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogStatements.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,296 @@
+/*
+ *
+ *  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.codegen.as.TestStatements;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+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.ITryNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Test;
+
+/**
+ * @author Michael Schmalle
+ * @author Erik de Bruin
+ */
+public class TestGoogStatements extends TestStatements
+{
+    //----------------------------------
+    // var declaration
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVarDeclaration()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a;",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {*} */ a");
+    }
+
+    @Override
+    @Test
+    public void testVarDeclaration_withType()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a:int;",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a");
+    }
+
+    @Override
+    @Test
+    public void testVarDeclaration_withTypeAssignedValue()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a:int = 42;",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a = 42");
+    }
+
+    @Override
+    @Test
+    public void testVarDeclaration_withTypeAssignedValueComplex()
+    {
+        IVariableNode node = (IVariableNode) getNode(
+                "var a:Foo = new Foo(42, 'goo');", IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {Foo} */ a = new Foo(42, 'goo')");
+    }
+
+    @Override
+    @Test
+    public void testVarDeclaration_withList()
+    {
+        IVariableNode node = (IVariableNode) getNode(
+                "var a:int = 4, b:int = 11, c:int = 42;", IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {number} */ a = 4, /** @type {number} */ b = 11, /** @type {number} */ c = 42");
+    }
+
+    //----------------------------------
+    // const declaration
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testConstDeclaration()
+    {
+        IVariableNode node = (IVariableNode) getNode("const a = 42;",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("\n/**\n * @const\n * @type {*}\n */\na = 42");
+    }
+
+    @Override
+    @Test
+    public void testConstDeclaration_withType()
+    {
+        IVariableNode node = (IVariableNode) getNode("const a:int = 42;",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("\n/**\n * @const\n * @type {number}\n */\na = 42");
+    }
+
+    @Override
+    @Test
+    public void testConstDeclaration_withList()
+    {
+        IVariableNode node = (IVariableNode) getNode(
+                "const a:int = 4, b:int = 11, c:int = 42;", IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        assertOut("\n/**\n * @const\n * @type {number}\n */\na = 4, \n/**\n * @const\n * @type {number}\n */\nb = 11, \n/**\n * @const\n * @type {number}\n */\nc = 42");
+    }
+
+    //----------------------------------
+    // for () { }
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitFor_1a()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int = 0; i < len; i++) { break; }",
+                IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var /** @type {number} */ i = 0; i < len; i++) {\n\tbreak;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitFor_1b()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int = 0; i < len; i++) break;", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var /** @type {number} */ i = 0; i < len; i++)\n\tbreak;");
+    }
+
+    @Override
+    @Test
+    public void testVisitForIn_1()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int in obj) { break; }", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var /** @type {number} */ i in obj) {\n\tbreak;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitForIn_1a()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int in obj)  break; ", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("for (var /** @type {number} */ i in obj)\n\tbreak;");
+    }
+
+    @Override
+    @Test
+    public void testVisitForEach_1()
+    {
+        // TODO (erikdebruin) we need to insert a "goog.require('goog.array')"
+        //                    into the header
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for each(var i:int in obj) { break; }", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("goog.array.forEach(obj, function (i) {\n\tbreak;\n})");
+    }
+
+    @Override
+    @Test
+    public void testVisitForEach_1a()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for each(var i:int in obj)  break; ", IForLoopNode.class);
+        asBlockWalker.visitForLoop(node);
+        assertOut("goog.array.forEach(obj, function (i) {\n\tbreak;\n})");
+    }
+
+    //----------------------------------
+    // try {} catch () {} finally {}
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitTry_Catch()
+    {
+        ITryNode node = (ITryNode) getNode("try { a; } catch (e:Error) { b; }",
+                ITryNode.class);
+        asBlockWalker.visitTry(node);
+        assertOut("try {\n\ta;\n} catch (e) {\n\tb;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitTry_Catch_Finally()
+    {
+        ITryNode node = (ITryNode) getNode(
+                "try { a; } catch (e:Error) { b; } finally { c; }",
+                ITryNode.class);
+        asBlockWalker.visitTry(node);
+        assertOut("try {\n\ta;\n} catch (e) {\n\tb;\n} finally {\n\tc;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitTry_Catch_Catch_Finally()
+    {
+        // 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\ta;\n} catch (e) {\n\tb;\n} catch (f) {\n\tc;\n} finally {\n\td;\n}");
+    }
+
+    @Override
+    @Test
+    public void testVisitTry_CatchEmpty_FinallyEmpty_()
+    {
+        ITryNode node = (ITryNode) getNode(
+                "try { a; } catch (e:Error) {  } finally {  }", ITryNode.class);
+        asBlockWalker.visitTry(node);
+        assertOut("try {\n\ta;\n} catch (e) {\n} finally {\n}");
+    }
+
+    //----------------------------------
+    // label : for () {}
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisitLabel_1()
+    {
+        LabeledStatementNode node = (LabeledStatementNode) getNode(
+                "foo: for each(var i:int in obj) { break foo; }",
+                LabeledStatementNode.class);
+        asBlockWalker.visitLabeledStatement(node);
+        assertOut("foo : goog.array.forEach(obj, function (i) {\n\tbreak foo;\n})");
+    }
+
+    @Override
+    @Test
+    public void testVisitLabel_1a()
+    {
+        // 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 : goog.array.forEach(obj, function (i) {\n\tbreak foo;\n})");
+    }
+
+    //----------------------------------
+    // all together now!
+    //----------------------------------
+
+    @Override
+    @Test
+    public void testVisit()
+    {
+        IFileNode node = (IFileNode) getNode(
+                "try { a; } catch (e:Error) { if (a) { if (b) { if (c) b; else if (f) a; else e; }} } finally {  }"
+                        + "if (d) for (var i:int = 0; i < len; i++) break;"
+                        + "if (a) { with (ab) { c(); } "
+                        + "do {a++;do a++; while(a > b);} while(c > d); }"
+                        + "if (b) { try { a; throw new Error('foo'); } catch (e:Error) { "
+                        + " switch(i){case 1: break; default: return;}"
+                        + " } finally { "
+                        + "  d;  var a:Object = function(foo:int, bar:String = 'goo'):int{return -1;};"
+                        + "  eee.dd; eee.dd; eee.dd; eee.dd;} }"
+                        + "foo: for each(var i:int in obj) break foo;",
+                IFileNode.class);
+        asBlockWalker.visitFile(node);
+        assertOut("goog.provide('A');\n\n/**\n * @constructor\n */\nA = function() {\n};\n\nA.prototype.a = function() {\n\tvar self = this;\n\ttry {\n\t\ta;\n\t} catch (e) {\n\t\tif (a) {\n\t\t\tif (b) {\n\t\t\t\tif (c)\n\t\t\t\t\tb;\n\t\t\t\telse if (f)\n\t\t\t\t\ta;\n\t\t\t\telse\n\t\t\t\t\te;\n\t\t\t}\n\t\t}\n\t} finally {\n\t}\n\tif (d)\n\t\tfor (var /** @type {number} */ i = 0; i < len; i++)\n\t\t\tbreak;\n\tif (a) {\n\t\twith (ab) {\n\t\t\tc();\n\t\t}\n\t\tdo {\n\t\t\ta++;\n\t\t\tdo\n\t\t\t\ta++;\n\t\t\twhile (a > b);\n\t\t} while (c > d);\n\t}\n\tif (b) {\n\t\ttry {\n\t\t\ta;\n\t\t\tthrow new Error('foo');\n\t\t} catch (e) {\n\t\t\tswitch (i) {\n\t\t\t\tcase 1:\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t} finally {\n\t\t\td;\n\t\t\tvar /** @type {Object} */ a = function(foo, bar) {\n\t\t\t\tvar self = this;\n\t\t\t\tbar = typeof bar !== 'undefined' ? bar : 'goo';\n\t\t\t\treturn -1;\n\t\t\t};\n\t\t\teee.dd;\n\t\t\teee.dd;\n\t\t\teee.dd;\n\t\
 t\teee.dd;\n\t\t}\n\t}\n\tfoo : goog.array.forEach(obj, function (i) {\n\t\tbreak foo;\n\t});\n};");
+    }
+
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogStatements.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/TestMXMLApplication.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/TestMXMLApplication.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/TestMXMLApplication.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/TestMXMLApplication.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,95 @@
+package org.apache.flex.compiler.internal.codegen.mxml;
+
+import org.apache.flex.compiler.internal.test.MXMLTestBase;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class TestMXMLApplication extends MXMLTestBase
+{
+
+    @Test
+    public void testBasicApp()
+    {
+        String code = ""
+                + "<s:Application xmlns:s=\"library://ns.adobe.com/flex/spark\">"
+                + "</s:Application>";
+
+        IMXMLFileNode node = compileMXML(code);
+
+        mxmlBlockWalker.visitFile(node);
+
+        assertOut("<Application>\n\t\n</Application>");
+    }
+
+    @Test
+    public void testBasicAppWithOneComponent()
+    {
+        String code = ""
+                + "<s:Application xmlns:s=\"library://ns.adobe.com/flex/spark\">"
+                + "    <s:Button id=\"myBtn\" label=\"Hello world\"></s:Button>"
+                + "</s:Application>";
+
+        IMXMLFileNode node = compileMXML(code);
+
+        mxmlBlockWalker.visitFile(node);
+
+        assertOut("<Application>\n\t<Button id=\"myBtn\" label=\"Hello world\"></Button>\n</Application>");
+    }
+
+    @Test
+    public void testBasicAppWithTwoComponents()
+    {
+        String code = ""
+                + "<s:Application xmlns:s=\"library://ns.adobe.com/flex/spark\">"
+                + "    <s:Label id=\"myLbl\" text=\"Bye bye\"></s:Label>"
+                + "    <s:Button id=\"myBtn\" label=\"Hello world\"></s:Button>"
+                + "</s:Application>";
+
+        IMXMLFileNode node = compileMXML(code);
+
+        mxmlBlockWalker.visitFile(node);
+
+        assertOut("<Application>\n\t<Label id=\"myLbl\" text=\"Bye bye\"></Label>\n\t<Button id=\"myBtn\" label=\"Hello world\"></Button>\n</Application>");
+    }
+
+    @Ignore
+    @Test
+    public void testBasicAppWithSimpleScript()
+    {
+        // TODO (erikdebruin) handle AS script parsing...
+
+        String code = ""
+                + "<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\" xmlns:s=\"library://ns.adobe.com/flex/spark\">"
+                + "    <fx:Script><![CDATA["
+                + "        private const GREETING:String = \"Hello world!\""
+                + "    ]]></fx:Script>" + "</s:Application>";
+
+        IMXMLFileNode node = compileMXML(code);
+
+        mxmlBlockWalker.visitFile(node);
+
+        assertOut("");
+    }
+
+    @Test
+    public void testDefaultApp()
+    {
+        String code = ""
+                + "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+                + "<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\""
+                + "               xmlns:s=\"library://ns.adobe.com/flex/spark\" "
+                + "               xmlns:mx=\"library://ns.adobe.com/flex/mx\" "
+                + "               minWidth=\"955\" minHeight=\"600\">"
+                + "    <fx:Declarations>"
+                + "        <!-- Place non-visual elements (e.g., services, value objects) here -->"
+                + "    </fx:Declarations>" + "</s:Application>";
+
+        IMXMLFileNode node = compileMXML(code);
+
+        mxmlBlockWalker.visitFile(node);
+
+        assertOut("<Application minHeight=\"600\" minWidth=\"955\">\n\t\n</Application>");
+    }
+
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/TestMXMLApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/TestMXMLAttributes.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/TestMXMLAttributes.java?rev=1452955&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/TestMXMLAttributes.java (added)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/TestMXMLAttributes.java Tue Mar  5 19:22:05 2013
@@ -0,0 +1,97 @@
+package org.apache.flex.compiler.internal.codegen.mxml;
+
+import org.apache.flex.compiler.internal.test.MXMLTestBase;
+import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class TestMXMLAttributes extends MXMLTestBase
+{
+
+    @Ignore
+    @Test
+    public void testIdAttribute()
+    {
+        // TODO (erikdebruin) id attributes are a special case...
+        String code = "id=\"myGrp\"";
+
+        IMXMLPropertySpecifierNode node = (IMXMLPropertySpecifierNode) getNode(
+                code, IMXMLPropertySpecifierNode.class,
+                MXMLTestBase.WRAP_LEVEL_NODE);
+
+        mxmlBlockWalker.visitPropertySpecifier(node);
+
+        assertOut("id=\"myBtn\"");
+    }
+
+    @Test
+    public void testSimpleBooleanAttribute()
+    {
+        String code = "visible=\"false\"";
+
+        IMXMLPropertySpecifierNode node = (IMXMLPropertySpecifierNode) getNode(
+                code, IMXMLPropertySpecifierNode.class,
+                MXMLTestBase.WRAP_LEVEL_NODE);
+
+        mxmlBlockWalker.visitPropertySpecifier(node);
+
+        assertOut("visible=\"false\"");
+    }
+
+    @Test
+    public void testSimpleIntAttribute()
+    {
+        String code = "x=\"100\"";
+
+        IMXMLPropertySpecifierNode node = (IMXMLPropertySpecifierNode) getNode(
+                code, IMXMLPropertySpecifierNode.class,
+                MXMLTestBase.WRAP_LEVEL_NODE);
+
+        mxmlBlockWalker.visitPropertySpecifier(node);
+
+        assertOut("x=\"100\"");
+    }
+
+    @Test
+    public void testSimpleNumberAttribute()
+    {
+        String code = "width=\"1.5\"";
+
+        IMXMLPropertySpecifierNode node = (IMXMLPropertySpecifierNode) getNode(
+                code, IMXMLPropertySpecifierNode.class,
+                MXMLTestBase.WRAP_LEVEL_NODE);
+
+        mxmlBlockWalker.visitPropertySpecifier(node);
+
+        assertOut("width=\"1.5\"");
+    }
+
+    @Test
+    public void testSimpleStringAttribute()
+    {
+        String code = "label=\"Click me ;-)\"";
+
+        IMXMLPropertySpecifierNode node = (IMXMLPropertySpecifierNode) getNode(
+                code, IMXMLPropertySpecifierNode.class,
+                MXMLTestBase.WRAP_LEVEL_NODE);
+
+        mxmlBlockWalker.visitPropertySpecifier(node);
+
+        assertOut("label=\"Click me ;-)\"");
+    }
+
+    @Test
+    public void testSimpleUintAttribute()
+    {
+        String code = "color=\"0xFF0000\"";
+
+        IMXMLPropertySpecifierNode node = (IMXMLPropertySpecifierNode) getNode(
+                code, IMXMLPropertySpecifierNode.class,
+                MXMLTestBase.WRAP_LEVEL_NODE);
+
+        mxmlBlockWalker.visitPropertySpecifier(node);
+
+        assertOut("color=\"16711680\"");
+    }
+
+}

Propchange: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/mxml/TestMXMLAttributes.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message