flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject [1/5] git commit: [flex-falcon] - [FalconJX] add test for local function call
Date Sat, 20 Apr 2013 10:54:16 GMT
Updated Branches:
  refs/heads/develop 0cf1d9c72 -> eba24a91f


[FalconJX] add test for local function call

Added a test file for the 'local function call' output using 'goog.bind'; aharui already provided
handling in JSFlexJSEmitter.

Signed-off-by: Erik de Bruin <erik@ixsoftware.nl>


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/305038ff
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/305038ff
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/305038ff

Branch: refs/heads/develop
Commit: 305038ff56a4c99210b9897e7e346712b724d9a9
Parents: 0cf1d9c
Author: Erik de Bruin <erik@ixsoftware.nl>
Authored: Sat Apr 20 10:28:12 2013 +0200
Committer: Erik de Bruin <erik@ixsoftware.nl>
Committed: Sat Apr 20 10:28:12 2013 +0200

----------------------------------------------------------------------
 .../internal/codegen/js/flexjs/TestFlexJSFile.java |   18 ++++++++
 .../test-files/flexjs/files/LocalFunction.as       |   26 ++++++++++++
 .../flexjs/files/LocalFunction_result.js           |   31 +++++++++++++++
 .../codegen/mxml/flexjs/MXMLFlexJSPublisher.java   |    7 +++
 4 files changed, 82 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/305038ff/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
index 187e747..8c66c4f 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSFile.java
@@ -36,6 +36,24 @@ import org.junit.Test;
 public class TestFlexJSFile extends FlexJSTestBase
 {
     @Test
+    public void testLocalFunction()
+    {
+        String fileName = "LocalFunction";
+
+        IFileNode node = compileAS(fileName, true,
+                "test-files"
+                        + File.separator + "flexjs" + File.separator + "files",
+                false);
+        
+        asBlockWalker.visitFile(node);
+        
+        writeResultToFile(writer.toString(), fileName);
+        
+        assertOut(getCodeFromFile(fileName + "_result", true,
+                "flexjs" + File.separator + "files"));
+    }
+
+    @Test
     public void testFlexJSMyController()
     {
         String fileName = "MyController";

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/305038ff/compiler.jx.tests/test-files/flexjs/files/LocalFunction.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/files/LocalFunction.as b/compiler.jx.tests/test-files/flexjs/files/LocalFunction.as
new file mode 100644
index 0000000..e7e9b70
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/files/LocalFunction.as
@@ -0,0 +1,26 @@
+package
+{
+	
+	public class LocalFunction
+	{
+		public function LocalFunction() {}
+		
+		private var myMemberProperty:String = "got it: ";
+		
+		private function myMemberMethod(value:int):void
+		{
+			function myLocalFunction(value:int):String
+			{
+				return myMemberProperty + value;
+			}
+			
+			trace("WOW! :: " + myLocalFunction(value + 42));
+		}
+		
+		public function doIt():void
+		{
+			myMemberMethod(624);
+		}
+	}
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/305038ff/compiler.jx.tests/test-files/flexjs/files/LocalFunction_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/files/LocalFunction_result.js b/compiler.jx.tests/test-files/flexjs/files/LocalFunction_result.js
new file mode 100644
index 0000000..f416447
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/files/LocalFunction_result.js
@@ -0,0 +1,31 @@
+goog.provide('LocalFunction');
+
+/**
+ * @constructor
+ */
+LocalFunction = function() {
+};
+
+/**
+ * @private
+ * @type {string}
+ */
+LocalFunction.prototype.myMemberProperty = "got it: ";
+
+/**
+ * @private
+ * @param {number} value
+ */
+LocalFunction.prototype.myMemberMethod = function(value) {
+	function myLocalFunction(value) {
+		return this.myMemberProperty + value;
+	};
+	trace("WOW! :: " + goog.bind(myLocalFunction, this)(value + 42));
+};
+
+/**
+ * @expose
+ */
+LocalFunction.prototype.doIt = function() {
+	this.myMemberMethod(624);
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/305038ff/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
index c22ff1f..f6b358a 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
@@ -279,10 +279,17 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         htmlFile.append("\t<script type=\"text/javascript\">\n");
 
         // TODO (erikdebruin) the utility methods should have their own place...
+        // is()
         htmlFile.append("\t\tfunction is(object, type) {\n");
         htmlFile.append("\t\t\treturn true;\n");
         htmlFile.append("\t\t};\n");
         htmlFile.append("\t\t\n");
+        // trace()
+        htmlFile.append("\t\tfunction trace(value) {\n");
+        htmlFile.append("\t\t\tif (console && console.log)\n");
+        htmlFile.append("\t\t\t\tconsole.log(value);\n");
+        htmlFile.append("\t\t};\n");
+        htmlFile.append("\t\t\n");
 
         htmlFile.append("\t\tnew ");
         htmlFile.append(projectName);


Mime
View raw message