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
The following commit(s) were added to refs/heads/develop by this push: new b6fd010 TestRoyaleAccessors: more tests for custom namespaces, including member access and static (for commit ac42eadd5a8b8d89bc66c997d811aeb9b75b5bb1) b6fd010 is described below commit b6fd010e4c141e8762dae1eb3d76bf6e09166b27 Author: Josh Tynjala <joshtynj...@apache.org> AuthorDate: Thu Feb 6 16:16:59 2020 -0800 TestRoyaleAccessors: more tests for custom namespaces, including member access and static (for commit ac42eadd5a8b8d89bc66c997d811aeb9b75b5bb1) --- .../codegen/js/royale/TestRoyaleAccessors.java | 44 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java index 917f615..6330183 100644 --- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java +++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java @@ -100,7 +100,7 @@ public class TestRoyaleAccessors extends ASTestBase } @Test - public void testGetSetCustomNamespaceAccessor() + public void testGetSetCustomNamespaceAccessorWithoutMemberAccess() { IClassNode node = (IClassNode) getNode( "import custom.custom_namespace;use namespace custom_namespace;public class B { public function B() {}; public function doStuff():void {var theLabel:String = label; label = theLabel;}; private var _label:String; custom_namespace function get label():String {return _label}; custom_namespace function set label(value:String):void {_label = value};}", @@ -114,6 +114,48 @@ public class TestRoyaleAccessors extends ASTestBase } @Test + public void testGetSetCustomNamespaceAccessorWithMemberAccess() + { + IClassNode node = (IClassNode) getNode( + "import custom.custom_namespace;use namespace custom_namespace;public class B { public function B() {}; public function doStuff():void {var theLabel:String = this.label; this.label = theLabel;}; private var _label:String; custom_namespace function get label():String {return _label}; custom_namespace function set label(value:String):void {_label = value};}", + IClassNode.class, WRAP_LEVEL_PACKAGE); + asBlockWalker.visitClass(node); + String expected = "/**\n * @constructor\n */\nB = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('B', B);\n\n\n/**\n * @export\n */\nB.prototype.doStuff = function() {\n var /** @type {string} */ theLabel = this.http_$$ns_apache_org$2017$custom$namespace__label;\n this.http_$$ns_apache_org$2017$custom$namespace__label = theLabel;\n};\n\n\n/**\n * @private\n * @type {string}\n */\nB.prototype._label = null;\n\n\n" + + "B.prototype.http_$$ns_apache_org$2017$custom$namespace__get__label = function() {\n return this._label;\n};\n\n\n" + + "B.prototype.http_$$ns_apache_org$2017$custom$namespace__set__label = function(value) {\n this._label = value;\n};\n\n\n" + + "Object.defineProperties(B.prototype, /** @lends {B.prototype} */ {\n/**\n * @export\n * @type {string} */\nhttp_$$ns_apache_org$2017$custom$namespace__label: {\nget: B.prototype.http_$$ns_apache_org$2017$custom$namespace__get__label,\nset: B.prototype.http_$$ns_apache_org$2017$custom$namespace__set__label}}\n);"; + assertOut(expected); + } + + @Test + public void testGetSetCustomNamespaceStaticAccessorWithoutMemberAccess() + { + IClassNode node = (IClassNode) getNode( + "import custom.custom_namespace;use namespace custom_namespace;public class B { public function B() {}; public function doStuff():void {var theLabel:String = label; label = theLabel;}; private static var _label:String; custom_namespace static function get label():String {return _label}; custom_namespace static function set label(value:String):void {_label = value};}", + IClassNode.class, WRAP_LEVEL_PACKAGE); + asBlockWalker.visitClass(node); + String expected = "/**\n * @constructor\n */\nB = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('B', B);\n\n\n/**\n * @export\n */\nB.prototype.doStuff = function() {\n var /** @type {string} */ theLabel = B.http_$$ns_apache_org$2017$custom$namespace__label;\n B.http_$$ns_apache_org$2017$custom$namespace__label = theLabel;\n};\n\n\n/**\n * @private\n * @type {string}\n */\nB._label = null;\n\n\n" + + "B.http_$$ns_apache_org$2017$custom$namespace__get__label = function() {\n return B._label;\n};\n\n\n" + + "B.http_$$ns_apache_org$2017$custom$namespace__set__label = function(value) {\n B._label = value;\n};\n\n\n" + + "Object.defineProperties(B, /** @lends {B} */ {\n/**\n * @export\n * @type {string} */\nhttp_$$ns_apache_org$2017$custom$namespace__label: {\nget: B.http_$$ns_apache_org$2017$custom$namespace__get__label,\nset: B.http_$$ns_apache_org$2017$custom$namespace__set__label}}\n);"; + assertOut(expected); + } + + @Test + public void testGetSetCustomNamespaceStaticAccessorWithMemberAccess() + { + IClassNode node = (IClassNode) getNode( + "import custom.custom_namespace;use namespace custom_namespace;public class B { public function B() {}; public function doStuff():void {var theLabel:String = B.label; B.label = theLabel;}; private static var _label:String; custom_namespace static function get label():String {return _label}; custom_namespace static function set label(value:String):void {_label = value};}", + IClassNode.class, WRAP_LEVEL_PACKAGE); + asBlockWalker.visitClass(node); + String expected = "/**\n * @constructor\n */\nB = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('B', B);\n\n\n/**\n * @export\n */\nB.prototype.doStuff = function() {\n var /** @type {string} */ theLabel = B.http_$$ns_apache_org$2017$custom$namespace__label;\n B.http_$$ns_apache_org$2017$custom$namespace__label = theLabel;\n};\n\n\n/**\n * @private\n * @type {string}\n */\nB._label = null;\n\n\n" + + "B.http_$$ns_apache_org$2017$custom$namespace__get__label = function() {\n return B._label;\n};\n\n\n" + + "B.http_$$ns_apache_org$2017$custom$namespace__set__label = function(value) {\n B._label = value;\n};\n\n\n" + + "Object.defineProperties(B, /** @lends {B} */ {\n/**\n * @export\n * @type {string} */\nhttp_$$ns_apache_org$2017$custom$namespace__label: {\nget: B.http_$$ns_apache_org$2017$custom$namespace__get__label,\nset: B.http_$$ns_apache_org$2017$custom$namespace__set__label}}\n);"; + assertOut(expected); + } + + @Test public void testBindableGetAndSetAccessor() { IClassNode node = (IClassNode) getNode(