This is an automated email from the ASF dual-hosted git repository. joshtynjala pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
commit 43ee0f7d9243a36b2d9bcc6c8329a1b03f37e8da Author: Josh Tynjala <[email protected]> AuthorDate: Thu Mar 13 15:31:31 2025 -0700 compiler-jx: some more royale.dependent.tests for tags/properties with primitive types --- .../codegen/mxml/royale/TestRoyaleMXMLBoolean.java | 279 +++++++++++++++++++++ .../codegen/mxml/royale/TestRoyaleMXMLInt.java | 279 +++++++++++++++++++++ .../codegen/mxml/royale/TestRoyaleMXMLNumber.java | 279 +++++++++++++++++++++ .../codegen/mxml/royale/TestRoyaleMXMLUint.java | 279 +++++++++++++++++++++ .../codegen/mxml/royale/TestRoyaleMXMLXML.java | 151 +++++++++++ 5 files changed, 1267 insertions(+) diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLBoolean.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLBoolean.java new file mode 100644 index 000000000..7c1512f41 --- /dev/null +++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLBoolean.java @@ -0,0 +1,279 @@ +/* + * + * 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.royale.compiler.internal.codegen.mxml.royale; + +import org.apache.royale.compiler.internal.test.RoyaleTestBase; +import org.apache.royale.compiler.tree.mxml.IMXMLDeclarationsNode; +import org.apache.royale.compiler.tree.mxml.IMXMLDocumentNode; +import org.junit.Test; + +public class TestRoyaleMXMLBoolean extends RoyaleTestBase +{ + @Test + public void testBooleanTag() + { + String code = "<fx:Declarations>\n" + + "\t<fx:Boolean id=\"boolean\">true</fx:Boolean>\n" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " this.boolean = true;\n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @export\n" + + " * @type {boolean}\n" + + " */\n" + + "AppName.prototype.boolean;"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } + + @Test + public void testBooleanPropertyAttribute() + { + String code = "<fx:Declarations>\n" + + "\t<basic:Label visible=\"true\"/>\n" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "goog.require('org.apache.royale.html.Label');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {org.apache.royale.html.Label}\n" + + " */\n" + + " this.$ID_8_0;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Object.defineProperties(AppName.prototype, /** @lends {AppName.prototype} */ {\n" + + " 'MXMLDescriptor': {\n" + + " /** @this {AppName} */\n" + + " get: function() {\n" + + " if (this.mxmldd == undefined)\n" + + " {\n" + + " /** @type {Array} */\n" + + " var arr = AppName.superClass_.get__MXMLDescriptor.apply(this);\n" + + " /** @type {Array} */\n" + + " var mxmldd = [\n" + + " org.apache.royale.html.Label,\n" + + " 2,\n" + + " '_id',\n" + + " true,\n" + + " '$ID_8_0',\n" + + " 'visible',\n" + + " true,\n" + + " true,\n" + + " 0,\n" + + " 0,\n" + + " null\n" + + " ];\n" + + " if (arr)\n" + + " this.mxmldd = arr.concat(mxmldd);\n" + + " else\n" + + " this.mxmldd = mxmldd;\n" + + " }\n" + + " return this.mxmldd;\n" + + " }\n" + + " }\n" + + "});"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } + + @Test + public void testBooleanPropertyChildTag() + { + String code = "<fx:Declarations>\n" + + "\t<basic:Label>\n" + + "\t\t<basic:visible>true</basic:visible>\n" + + "\t</basic:Label>" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "goog.require('org.apache.royale.html.Label');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {org.apache.royale.html.Label}\n" + + " */\n" + + " this.$ID_8_0;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Object.defineProperties(AppName.prototype, /** @lends {AppName.prototype} */ {\n" + + " 'MXMLDescriptor': {\n" + + " /** @this {AppName} */\n" + + " get: function() {\n" + + " if (this.mxmldd == undefined)\n" + + " {\n" + + " /** @type {Array} */\n" + + " var arr = AppName.superClass_.get__MXMLDescriptor.apply(this);\n" + + " /** @type {Array} */\n" + + " var mxmldd = [\n" + + " org.apache.royale.html.Label,\n" + + " 2,\n" + + " '_id',\n" + + " true,\n" + + " '$ID_8_0',\n" + + " 'visible',\n" + + " true,\n" + + " true,\n" + + " 0,\n" + + " 0,\n" + + " null\n" + + " ];\n" + + " if (arr)\n" + + " this.mxmldd = arr.concat(mxmldd);\n" + + " else\n" + + " this.mxmldd = mxmldd;\n" + + " }\n" + + " return this.mxmldd;\n" + + " }\n" + + " }\n" + + "});"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } +} diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLInt.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLInt.java new file mode 100644 index 000000000..bff73975a --- /dev/null +++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLInt.java @@ -0,0 +1,279 @@ +/* + * + * 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.royale.compiler.internal.codegen.mxml.royale; + +import org.apache.royale.compiler.internal.test.RoyaleTestBase; +import org.apache.royale.compiler.tree.mxml.IMXMLDeclarationsNode; +import org.apache.royale.compiler.tree.mxml.IMXMLDocumentNode; +import org.junit.Test; + +public class TestRoyaleMXMLInt extends RoyaleTestBase +{ + @Test + public void testIntTag() + { + String code = "<fx:Declarations>\n" + + "\t<fx:int id=\"integer\">1234</fx:int>\n" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " this.integer = 1234;\n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @export\n" + + " * @type {number}\n" + + " */\n" + + "AppName.prototype.integer;"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } + + @Test + public void testIntegerPropertyAttribute() + { + String code = "<fx:Declarations>\n" + + "\t<basic:ContextMenu offsetX=\"1234\"/>\n" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "goog.require('org.apache.royale.html.beads.ContextMenu');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {org.apache.royale.html.beads.ContextMenu}\n" + + " */\n" + + " this.$ID_8_0;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Object.defineProperties(AppName.prototype, /** @lends {AppName.prototype} */ {\n" + + " 'MXMLDescriptor': {\n" + + " /** @this {AppName} */\n" + + " get: function() {\n" + + " if (this.mxmldd == undefined)\n" + + " {\n" + + " /** @type {Array} */\n" + + " var arr = AppName.superClass_.get__MXMLDescriptor.apply(this);\n" + + " /** @type {Array} */\n" + + " var mxmldd = [\n" + + " org.apache.royale.html.beads.ContextMenu,\n" + + " 2,\n" + + " '_id',\n" + + " true,\n" + + " '$ID_8_0',\n" + + " 'offsetX',\n" + + " true,\n" + + " 1234,\n" + + " 0,\n" + + " 0,\n" + + " null\n" + + " ];\n" + + " if (arr)\n" + + " this.mxmldd = arr.concat(mxmldd);\n" + + " else\n" + + " this.mxmldd = mxmldd;\n" + + " }\n" + + " return this.mxmldd;\n" + + " }\n" + + " }\n" + + "});"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } + + @Test + public void testIntegerPropertyChildTag() + { + String code = "<fx:Declarations>\n" + + "\t<basic:ContextMenu>\n" + + "\t\t<basic:offsetX>1234</basic:offsetX>\n" + + "\t</basic:ContextMenu>" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "goog.require('org.apache.royale.html.beads.ContextMenu');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {org.apache.royale.html.beads.ContextMenu}\n" + + " */\n" + + " this.$ID_8_0;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Object.defineProperties(AppName.prototype, /** @lends {AppName.prototype} */ {\n" + + " 'MXMLDescriptor': {\n" + + " /** @this {AppName} */\n" + + " get: function() {\n" + + " if (this.mxmldd == undefined)\n" + + " {\n" + + " /** @type {Array} */\n" + + " var arr = AppName.superClass_.get__MXMLDescriptor.apply(this);\n" + + " /** @type {Array} */\n" + + " var mxmldd = [\n" + + " org.apache.royale.html.beads.ContextMenu,\n" + + " 2,\n" + + " '_id',\n" + + " true,\n" + + " '$ID_8_0',\n" + + " 'offsetX',\n" + + " true,\n" + + " 1234,\n" + + " 0,\n" + + " 0,\n" + + " null\n" + + " ];\n" + + " if (arr)\n" + + " this.mxmldd = arr.concat(mxmldd);\n" + + " else\n" + + " this.mxmldd = mxmldd;\n" + + " }\n" + + " return this.mxmldd;\n" + + " }\n" + + " }\n" + + "});"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } +} diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLNumber.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLNumber.java new file mode 100644 index 000000000..75a3af0b3 --- /dev/null +++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLNumber.java @@ -0,0 +1,279 @@ +/* + * + * 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.royale.compiler.internal.codegen.mxml.royale; + +import org.apache.royale.compiler.internal.test.RoyaleTestBase; +import org.apache.royale.compiler.tree.mxml.IMXMLDeclarationsNode; +import org.apache.royale.compiler.tree.mxml.IMXMLDocumentNode; +import org.junit.Test; + +public class TestRoyaleMXMLNumber extends RoyaleTestBase +{ + @Test + public void testNumberTag() + { + String code = "<fx:Declarations>\n" + + "\t<fx:Number id=\"number\">123.4</fx:Number>\n" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " this.number = 123.4;\n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @export\n" + + " * @type {number}\n" + + " */\n" + + "AppName.prototype.number;"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } + + @Test + public void testNumberPropertyAttribute() + { + String code = "<fx:Declarations>\n" + + "\t<basic:Label alpha=\"0.5\"/>\n" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "goog.require('org.apache.royale.html.Label');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {org.apache.royale.html.Label}\n" + + " */\n" + + " this.$ID_8_0;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Object.defineProperties(AppName.prototype, /** @lends {AppName.prototype} */ {\n" + + " 'MXMLDescriptor': {\n" + + " /** @this {AppName} */\n" + + " get: function() {\n" + + " if (this.mxmldd == undefined)\n" + + " {\n" + + " /** @type {Array} */\n" + + " var arr = AppName.superClass_.get__MXMLDescriptor.apply(this);\n" + + " /** @type {Array} */\n" + + " var mxmldd = [\n" + + " org.apache.royale.html.Label,\n" + + " 2,\n" + + " '_id',\n" + + " true,\n" + + " '$ID_8_0',\n" + + " 'alpha',\n" + + " true,\n" + + " 0.5,\n" + + " 0,\n" + + " 0,\n" + + " null\n" + + " ];\n" + + " if (arr)\n" + + " this.mxmldd = arr.concat(mxmldd);\n" + + " else\n" + + " this.mxmldd = mxmldd;\n" + + " }\n" + + " return this.mxmldd;\n" + + " }\n" + + " }\n" + + "});"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } + + @Test + public void testNumberPropertyChildTag() + { + String code = "<fx:Declarations>\n" + + "\t<basic:Label>\n" + + "\t\t<basic:alpha>0.5</basic:alpha>\n" + + "\t</basic:Label>" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "goog.require('org.apache.royale.html.Label');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {org.apache.royale.html.Label}\n" + + " */\n" + + " this.$ID_8_0;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Object.defineProperties(AppName.prototype, /** @lends {AppName.prototype} */ {\n" + + " 'MXMLDescriptor': {\n" + + " /** @this {AppName} */\n" + + " get: function() {\n" + + " if (this.mxmldd == undefined)\n" + + " {\n" + + " /** @type {Array} */\n" + + " var arr = AppName.superClass_.get__MXMLDescriptor.apply(this);\n" + + " /** @type {Array} */\n" + + " var mxmldd = [\n" + + " org.apache.royale.html.Label,\n" + + " 2,\n" + + " '_id',\n" + + " true,\n" + + " '$ID_8_0',\n" + + " 'alpha',\n" + + " true,\n" + + " 0.5,\n" + + " 0,\n" + + " 0,\n" + + " null\n" + + " ];\n" + + " if (arr)\n" + + " this.mxmldd = arr.concat(mxmldd);\n" + + " else\n" + + " this.mxmldd = mxmldd;\n" + + " }\n" + + " return this.mxmldd;\n" + + " }\n" + + " }\n" + + "});"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } +} diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLUint.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLUint.java new file mode 100644 index 000000000..dad5dc8ec --- /dev/null +++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLUint.java @@ -0,0 +1,279 @@ +/* + * + * 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.royale.compiler.internal.codegen.mxml.royale; + +import org.apache.royale.compiler.internal.test.RoyaleTestBase; +import org.apache.royale.compiler.tree.mxml.IMXMLDeclarationsNode; +import org.apache.royale.compiler.tree.mxml.IMXMLDocumentNode; +import org.junit.Test; + +public class TestRoyaleMXMLUint extends RoyaleTestBase +{ + @Test + public void testUintTag() + { + String code = "<fx:Declarations>\n" + + "\t<fx:uint id=\"unsignedInteger\">4294967295</fx:uint>\n" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " this.unsignedInteger = 4294967295;\n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @export\n" + + " * @type {number}\n" + + " */\n" + + "AppName.prototype.unsignedInteger;"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } + + @Test + public void testUintPropertyAttribute() + { + String code = "<fx:Declarations>\n" + + "\t<basic:TextFieldItemRenderer downColor=\"4294967295\"/>\n" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "goog.require('org.apache.royale.html.supportClasses.TextFieldItemRenderer');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {org.apache.royale.html.supportClasses.TextFieldItemRenderer}\n" + + " */\n" + + " this.$ID_8_0;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Object.defineProperties(AppName.prototype, /** @lends {AppName.prototype} */ {\n" + + " 'MXMLDescriptor': {\n" + + " /** @this {AppName} */\n" + + " get: function() {\n" + + " if (this.mxmldd == undefined)\n" + + " {\n" + + " /** @type {Array} */\n" + + " var arr = AppName.superClass_.get__MXMLDescriptor.apply(this);\n" + + " /** @type {Array} */\n" + + " var mxmldd = [\n" + + " org.apache.royale.html.supportClasses.TextFieldItemRenderer,\n" + + " 2,\n" + + " '_id',\n" + + " true,\n" + + " '$ID_8_0',\n" + + " 'downColor',\n" + + " true,\n" + + " 4294967295,\n" + + " 0,\n" + + " 0,\n" + + " null\n" + + " ];\n" + + " if (arr)\n" + + " this.mxmldd = arr.concat(mxmldd);\n" + + " else\n" + + " this.mxmldd = mxmldd;\n" + + " }\n" + + " return this.mxmldd;\n" + + " }\n" + + " }\n" + + "});"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } + + @Test + public void testUintPropertyChildTag() + { + String code = "<fx:Declarations>\n" + + "\t<basic:TextFieldItemRenderer>\n" + + "\t\t<basic:downColor>4294967295</basic:downColor>\n" + + "\t</basic:TextFieldItemRenderer>" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "goog.require('org.apache.royale.html.supportClasses.TextFieldItemRenderer');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {org.apache.royale.html.supportClasses.TextFieldItemRenderer}\n" + + " */\n" + + " this.$ID_8_0;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Object.defineProperties(AppName.prototype, /** @lends {AppName.prototype} */ {\n" + + " 'MXMLDescriptor': {\n" + + " /** @this {AppName} */\n" + + " get: function() {\n" + + " if (this.mxmldd == undefined)\n" + + " {\n" + + " /** @type {Array} */\n" + + " var arr = AppName.superClass_.get__MXMLDescriptor.apply(this);\n" + + " /** @type {Array} */\n" + + " var mxmldd = [\n" + + " org.apache.royale.html.supportClasses.TextFieldItemRenderer,\n" + + " 2,\n" + + " '_id',\n" + + " true,\n" + + " '$ID_8_0',\n" + + " 'downColor',\n" + + " true,\n" + + " 4294967295,\n" + + " 0,\n" + + " 0,\n" + + " null\n" + + " ];\n" + + " if (arr)\n" + + " this.mxmldd = arr.concat(mxmldd);\n" + + " else\n" + + " this.mxmldd = mxmldd;\n" + + " }\n" + + " return this.mxmldd;\n" + + " }\n" + + " }\n" + + "});"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } +} diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLXML.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLXML.java new file mode 100644 index 000000000..e2805ddfe --- /dev/null +++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLXML.java @@ -0,0 +1,151 @@ +/* + * + * 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.royale.compiler.internal.codegen.mxml.royale; + +import org.apache.royale.compiler.internal.test.RoyaleTestBase; +import org.apache.royale.compiler.tree.mxml.IMXMLDeclarationsNode; +import org.apache.royale.compiler.tree.mxml.IMXMLDocumentNode; +import org.junit.Test; + +public class TestRoyaleMXMLXML extends RoyaleTestBase +{ + @Test + public void testTagWithChildText() + { + String code = "<fx:Declarations>\n" + + "\t<fx:XML id=\"xml\"><root> abc 123 </root></fx:XML>\n" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " this.xml = new XML('<root> abc 123 <\\/root>');\n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @export\n" + + " * @type {XML}\n" + + " */\n" + + "AppName.prototype.xml;"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } + + @Test + public void testTagWithChildTextContainingCharsThatShouldNotBeEscaped() + { + String code = "<fx:Declarations>\n" + + "\t<fx:XML id=\"xml\"><root>\\t\\n\\r\\f\\b\\u00B0</root></fx:XML>\n" + + "</fx:Declarations>"; + + IMXMLDeclarationsNode declNode = (IMXMLDeclarationsNode) getNode(code, + IMXMLDeclarationsNode.class, RoyaleTestBase.WRAP_LEVEL_DOCUMENT); + IMXMLDocumentNode docNode = (IMXMLDocumentNode) declNode.getAncestorOfType(IMXMLDocumentNode.class); + mxmlBlockWalker.visitDocument(docNode); + + String appName = docNode.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.royale.core.Application');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " * @extends {org.apache.royale.core.Application}\n" + + " */\n" + + "AppName = function() {\n" + + " AppName.base(this, 'constructor');\n" + + " \n" + + " this.xml = new XML('<root>\\\\t\\\\n\\\\r\\\\f\\\\b\\\\u00B0<\\/root>');\n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldd;\n" + + " \n" + + " /**\n" + + " * @private\n" + + " * @type {Array}\n" + + " */\n" + + " this.mxmldp;\n" + + "};\n" + + "goog.inherits(AppName, org.apache.royale.core.Application);\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @export\n" + + " * @type {XML}\n" + + " */\n" + + "AppName.prototype.xml;"; + + assertOut(outTemplate.replaceAll("AppName", appName), false); + } +}
