flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject svn commit: r1430211 - in /flex/whiteboard/mschmalle/falconjx: compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/ compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/ compiler.jx/src/org/apache/flex/compiler/interna...
Date Tue, 08 Jan 2013 11:18:54 GMT
Author: erikdebruin
Date: Tue Jan  8 11:18:53 2013
New Revision: 1430211

URL: http://svn.apache.org/viewvc?rev=1430211&view=rev
Log:
- added AS and 'goog' JS tests for Global Constants
- fixed issue where 'goog' type annotation of 'Number' wasn't lowercased

Added:
    flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalConstants.java
  (with props)
    flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalConstants.java
  (with props)
Modified:
    flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java

Added: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalConstants.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalConstants.java?rev=1430211&view=auto
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalConstants.java
(added)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalConstants.java
Tue Jan  8 11:18:53 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.as.codegen;
+
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Erik de Bruin
+ */
+public class TestGlobalConstants extends TestWalkerBase
+{
+    @Test
+    public void testInfinity()
+    {
+        IVariableNode node = getField("var a:Number = Infinity;");
+        visitor.visitVariable(node);
+        assertOut("var a:Number = Infinity");
+    }
+
+    @Ignore
+    @Test
+    public void testNegativeInfinity()
+    {
+    	// TODO (erikdebruin) Mike, why is this failing?
+        IVariableNode node = getField("var a:Number = -Infinity;");
+        visitor.visitVariable(node);
+        assertOut("var a:Number = -Infinity");
+    }
+
+    @Test
+    public void testNaN()
+    {
+        IVariableNode node = getField("var a:Number = NaN;");
+        visitor.visitVariable(node);
+        assertOut("var a:Number = NaN");
+    }
+
+    @Test
+    public void testUndefined()
+    {
+        IVariableNode node = getField("var a:* = undefined;");
+        visitor.visitVariable(node);
+        assertOut("var a:* = undefined");
+    }
+
+    protected IVariableNode getField(String code)
+    {
+        String source = "package {public class A {" + code + "}}";
+        IFileNode node = getFileNode(source);
+        IVariableNode child = (IVariableNode) findFirstDescendantOfType(node,
+                IVariableNode.class);
+        return child;
+    }
+}

Propchange: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestGlobalConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalConstants.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalConstants.java?rev=1430211&view=auto
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalConstants.java
(added)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogGlobalConstants.java
Tue Jan  8 11:18:53 2013
@@ -0,0 +1,85 @@
+/*
+ *
+ *  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.js.codegen.goog;
+
+import org.apache.flex.compiler.clients.IBackend;
+import org.apache.flex.compiler.internal.as.codegen.TestGlobalConstants;
+import org.apache.flex.compiler.internal.js.codegen.JSSharedData;
+import org.apache.flex.compiler.internal.js.driver.goog.GoogBackend;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.junit.Ignore;
+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;");
+        JSSharedData.OUTPUT_JSDOC = false;
+        visitor.visitVariable(node);
+        JSSharedData.OUTPUT_JSDOC = true;
+        assertOut("A.prototype.a = Infinity");
+    }
+
+    @Ignore
+    @Override
+    @Test
+    public void testNegativeInfinity()
+    {
+        IVariableNode node = getField("var a:Number = -Infinity;");
+        JSSharedData.OUTPUT_JSDOC = false;
+        visitor.visitVariable(node);
+        JSSharedData.OUTPUT_JSDOC = true;
+        assertOut("A.prototype.a = -Infinity");
+    }
+
+    @Override
+    @Test
+    public void testNaN()
+    {
+        IVariableNode node = getField("var a:Number = NaN;");
+        JSSharedData.OUTPUT_JSDOC = false;
+        visitor.visitVariable(node);
+        JSSharedData.OUTPUT_JSDOC = true;
+        assertOut("A.prototype.a = NaN");
+    }
+
+    @Override
+    @Test
+    public void testUndefined()
+    {
+        IVariableNode node = getField("var a:* = undefined;");
+        JSSharedData.OUTPUT_JSDOC = false;
+        visitor.visitVariable(node);
+        JSSharedData.OUTPUT_JSDOC = true;
+        assertOut("A.prototype.a = undefined");
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+}

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

Modified: flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java
URL: http://svn.apache.org/viewvc/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java?rev=1430211&r1=1430210&r2=1430211&view=diff
==============================================================================
--- flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java
(original)
+++ flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java
Tue Jan  8 11:18:53 2013
@@ -190,7 +190,7 @@ public class JSGoogDocEmitter extends JS
     	if (name.equals("String"))
     		result = "string";
     	
-    	if (name.equals("int") || name.equals("uint"))
+    	if (name.equals("int") || name.equals("uint") || name.equals("Number"))
     		result = "number";
     	
     	// TODO (erikdebruin) this will not work right with nested Vector



Mime
View raw message