flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject [20/50] git commit: [flex-falcon] [refs/heads/master] - add test for XML output
Date Tue, 21 Mar 2017 23:10:57 GMT
add test for XML output


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

Branch: refs/heads/master
Commit: 84a6f63f9903cdf7e58b5dbba699fa1666f3b051
Parents: 2531a9c
Author: Alex Harui <aharui@apache.org>
Authored: Mon Jan 23 13:42:42 2017 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Jan 23 13:42:42 2017 -0800

----------------------------------------------------------------------
 .../mxml/flexjs/TestFlexJSMXMLApplication.java  | 117 +++++++++++++++++++
 .../flex/compiler/internal/test/TestBase.java   |  13 +++
 2 files changed, 130 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/84a6f63f/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLApplication.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLApplication.java
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLApplication.java
index e740b6e..8cb54be 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLApplication.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/TestFlexJSMXMLApplication.java
@@ -670,6 +670,123 @@ public class TestFlexJSMXMLApplication extends FlexJSTestBase
         assertOutWithMetadata(outTemplate.replaceAll("AppName", appName));
     }
 
+    @Test
+    public void testXMLUsage()
+    {
+        String code = "<basic:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\" xmlns:basic=\"library://ns.apache.org/flexjs/basic\">"
+        		+ "<fx:Script><![CDATA["
+        		+ "    public var xml:XML = new XML();\n"
+                + "]]></fx:Script><basic:initialView><basic:Label text=\"Hello
World\"/></basic:initialView></basic:Application>";
+
+        IMXMLDocumentNode dnode = (IMXMLDocumentNode) getNode(code,
+        		IMXMLDocumentNode.class, FlexJSTestBase.WRAP_LEVEL_NONE);
+
+        ((JSFlexJSEmitter)(mxmlBlockWalker.getASEmitter())).getModel().setCurrentClass(dnode.getDefinition());
+        mxmlBlockWalker.visitDocument(dnode);
+        String appName = dnode.getQualifiedName();
+        String outTemplate = "/**\n" +
+        		" * AppName\n" +
+        		" *\n" +
+        		" * @fileoverview\n" +
+        		" *\n" +
+        		" * @suppress {checkTypes|accessControls}\n" +
+        		" */\n" +
+        		"\n" +
+        		"goog.provide('AppName');\n" +
+        		"\n" +
+        		"goog.require('org.apache.flex.core.Application');\n" +
+        		"goog.require('org.apache.flex.html.Label');\n" +
+        		"goog.require('XML');\n" +
+        		"goog.require('XML');\n" +
+        		"\n" +
+        		"\n" +
+        		"\n" +
+        		"/**\n" +
+        		" * @constructor\n" +
+        		" * @extends {org.apache.flex.core.Application}\n" +
+        		" */\n" +
+        		"AppName = function() {\n" +
+        		"  AppName.base(this, 'constructor');\n" +
+        		"  \n" +
+        		"  this.xml = new XML();\n" +
+        		"  /**\n" +
+        		"   * @private\n" +
+        		"   * @type {org.apache.flex.html.Label}\n" +
+        		"   */\n" +
+        		"  this.$ID0_;\n" +
+        		"  \n" +
+        		"  /**\n" +
+        		"   * @private\n" +
+        		"   * @type {Array}\n" +
+        		"   */\n" +
+        		"  this.mxmldd;\n" +
+        		"  \n" +
+        		"  /**\n" +
+        		"   * @private\n" +
+        		"   * @type {Array}\n" +
+        		"   */\n" +
+        		"  this.mxmldp;\n" +
+        		"\n" +
+        		"  this.generateMXMLAttributes\n" +
+        		"  ([1,\n" +
+        		"'initialView',\n" +
+        		"false,\n" +
+        		"[org.apache.flex.html.Label, 2, '_id', true, '$ID0', 'text', true, 'Hello World',
0, 0, null],\n" +
+        		"0,\n" +
+        		"0\n" +
+        		"  ]);\n" +
+        		"  \n" +
+        		"};\n" +
+        		"goog.inherits(AppName, org.apache.flex.core.Application);\n" +
+        		"\n" +
+        		"\n" +
+				"\n" +
+        		"/**\n" +
+        		" * @export\n" +
+        		" * @type {XML}\n" +
+        		" */\n" +
+        		"AppName.prototype.xml;\n" +
+        		"\n" +
+				"\n" +
+        		"/**\n" +
+        		" * Metadata\n" +
+        		" *\n" +
+        		" * @type {Object.<string, Array.<Object>>}\n" +
+        		" */\n" +
+        		"AppName.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'AppName', qName: 'AppName',
kind: 'class'  }] };\n" +
+          		"\n" +
+        		"\n" +
+        		"/**\n" +
+        		" * Prevent renaming of class. Needed for reflection.\n" +
+        		" */\n" +
+        		"goog.exportSymbol('AppName', AppName);\n" +
+          		"\n" +
+        		"\n" +
+        		"\n" +
+        		"/**\n" +
+        		" * Reflection\n" +
+        		" *\n" +
+        		" * @return {Object.<string, Function>}\n" +
+        		" */\n" +
+        		"AppName.prototype.FLEXJS_REFLECTION_INFO = function () {\n" +
+        		"  return {\n" +
+        		"    variables: function () {\n" +
+        		"      return {\n" +
+        		"        'xml': { type: 'XML'}\n" +
+        		"      };\n" +
+        		"    },\n" +
+				"    accessors: function () {return {};},\n" +
+        		"    methods: function () {\n" +
+        		"      return {\n" +
+				"        'AppName': { type: '', declaredBy: 'AppName'}\n"+
+        		"      };\n" +
+        		"    }\n" +
+        		"  };\n" +
+        		"};";
+
+        assertOutMXMLPostProcess(outTemplate.replaceAll("AppName", appName), true);
+    }
+
     @Override
     protected void addSourcePaths(List<File> sourcePaths)
     {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/84a6f63f/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
index 056a078..ab18cbd 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
@@ -242,6 +242,19 @@ public class TestBase implements ITestBase
         assertThat(mCode, is(code));
     }
     
+    protected void assertOutMXMLPostProcess(String code, boolean keepMetadata)
+    {
+    	mCode = removeGeneratedString(mxmlEmitter.postProcess(writer.toString()));
+    	if (!keepMetadata)
+    		mCode = removeMetadata(mCode);
+        //System.out.println(mCode);
+        /*if (!code.equals(mCode)) {
+            System.out.println("mCode:\n"+mCode);
+            System.out.println("code:\n"+code);
+        }*/
+        assertThat(mCode, is(code));
+    }
+    
     protected void assertOut(String code)
     {
         assertOut(code, false);


Mime
View raw message