You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2021/11/08 02:15:25 UTC
[royale-asjs] branch develop updated: Add testing for
@royalesuppressexport,
in Reflection lib. This is within application compilation and is mainly to
detect any changes that could break this in the future. SWC-based
definitions with @royalesuppressexport in them are not tested with these
tests.
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 6de9284 Add testing for @royalesuppressexport, in Reflection lib. This is within application compilation and is mainly to detect any changes that could break this in the future. SWC-based definitions with @royalesuppressexport in them are not tested with these tests.
6de9284 is described below
commit 6de92846ed8cd7bc8d73c00c37393e0f504b9d3c
Author: greg-dove <gr...@gmail.com>
AuthorDate: Mon Nov 8 15:15:10 2021 +1300
Add testing for @royalesuppressexport, in Reflection lib. This is within application compilation and is mainly to detect any changes that could break this in the future.
SWC-based definitions with @royalesuppressexport in them are not tested with these tests.
---
.../test/royale/flexUnitTests/ReflectionTester.as | 5 +-
.../ReflectionTesterTestExportSuppressed.as | 155 +++++++++++++++++++++
.../support/TestClassExportSuppressed1.as | 116 +++++++++++++++
.../support/TestClassExportSuppressed2.as | 116 +++++++++++++++
.../reflection/support/testFunction.as | 31 +++++
.../support/testFunctionExportSuppressed.as | 32 +++++
6 files changed, 454 insertions(+), 1 deletion(-)
diff --git a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/ReflectionTester.as b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/ReflectionTester.as
index dc248b6..27497a3 100644
--- a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/ReflectionTester.as
+++ b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/ReflectionTester.as
@@ -37,7 +37,8 @@ package flexUnitTests
ReflectionTesterTestDynamic,
ReflectionTesterNativeTypes,
ReflectionTesterTestEdgeCases,
- ReflectionTesterTestUtils
+ ReflectionTesterTestUtils,
+ ReflectionTesterTestExportSuppressed
];
}
@@ -54,5 +55,7 @@ package flexUnitTests
public var reflectionTesterTestEdgeCases:ReflectionTesterTestEdgeCases;
public var reflectionTesterTestUtils:ReflectionTesterTestUtils;
+
+ public var reflectionTesterTestSuppression: ReflectionTesterTestExportSuppressed;
}
}
diff --git a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestExportSuppressed.as b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestExportSuppressed.as
new file mode 100644
index 0000000..de59599
--- /dev/null
+++ b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestExportSuppressed.as
@@ -0,0 +1,155 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 flexUnitTests.reflection
+{
+
+ import org.apache.royale.test.asserts.*;
+
+ import flexUnitTests.reflection.support.*;
+
+ import org.apache.royale.reflection.*;
+
+
+
+ COMPILE::JS{
+ import goog.DEBUG;
+ }
+
+
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class ReflectionTesterTestExportSuppressed
+ {
+
+ public static var isJS:Boolean;
+ public static var isJSRelease:Boolean;
+
+ [BeforeClass]
+ public static function setUpBeforeClass():void
+ {
+
+ isJS = COMPILE::JS;
+
+ COMPILE::JS{
+ isJSRelease = !goog.DEBUG;
+ }
+
+ }
+
+ [AfterClass]
+ public static function tearDownAfterClass():void
+ {
+ }
+
+ [Before]
+ public function setUp():void
+ {
+
+ }
+
+ [After]
+ public function tearDown():void
+ {
+
+ }
+
+
+ [Test]
+ public function testControlFunction():void
+ {
+ var f:Function = testFunction;
+ var qName:String = f();
+ // this should also work in release mode, because the function is exported
+ var check:Function = getDefinitionByName(qName) as Function;
+
+ assertStrictlyEquals(check, f, 'unexpected result in reflective function access')
+
+ }
+
+ [Test]
+ public function testSuppressedFunction():void
+ {
+ var f:Function = testFunctionExportSuppressed;
+ var qName:String = f();
+
+ try{
+ //this should work in all cases except js-release build
+ var check:Function = getDefinitionByName(qName) as Function;
+ } catch(e:Error) {
+ //in js-release build the function is not accessible by its qName, so an error is thrown
+ check = null;
+ }
+
+ if (!isJSRelease) {
+ assertStrictlyEquals(check, f, 'unexpected result in suppressed reflective function access')
+ } else {
+ assertNull(check, 'unexpected result in suppressed reflective function access')
+ }
+ }
+
+ [Test]
+ public function testFullySuppressedClass():void
+ {
+ var c:Class = TestClassExportSuppressed1;
+ var expected:String = TestClassExportSuppressed1.CLASSNAME;
+ var qName:String = getQualifiedClassName(c);
+
+ if (isJS) {
+ //there will be no valid qualified name, it will return as 'Function'
+ assertEquals(qName,'Function', 'unexpected result in suppressed reflective qName access')
+ } else {
+ assertEquals(qName, expected, 'unexpected result in suppressed reflective qName access')
+ }
+
+ }
+
+ [Test]
+ public function testPartiallySuppressedClass():void
+ {
+ var c:Class = TestClassExportSuppressed2;
+ var expected:String = TestClassExportSuppressed2.CLASSNAME;
+ var qName:String = getQualifiedClassName(c);
+ assertEquals(qName, expected, 'unexpected result in suppressed reflective qName access')
+
+ var def:TypeDefinition = describeType(c);
+
+ //RoyaleUnitTestRunner.consoleOut(def.toString(true));
+ if (isJS) {
+ assertEquals(def.variables.length, 1, 'unexpected JS reflection data (instance vars)');
+ assertEquals(def.accessors.length, 1, 'unexpected JS reflection data (instance accessors)');
+ assertEquals(def.methods.length, 1, 'unexpected JS reflection data (instance accessors)');
+ assertEquals(def.staticVariables.length, 1, 'unexpected JS reflection data (instance vars)');
+ assertEquals(def.staticAccessors.length, 1, 'unexpected JS reflection data (instance accessors)');
+ assertEquals(def.staticMethods.length, 1, 'unexpected JS reflection data (instance accessors)');
+
+ } else {
+ assertEquals(def.variables.length, 2, 'unexpected JS reflection data (instance vars)');
+ assertEquals(def.accessors.length, 2, 'unexpected JS reflection data (instance accessors)');
+ assertEquals(def.methods.length, 2, 'unexpected JS reflection data (instance accessors)');
+ assertEquals(def.staticVariables.length, 2, 'unexpected JS reflection data (instance vars)');
+ //note 'prototype' is included here, hence 3 instead of 2:
+ assertEquals(def.staticAccessors.length, 3, 'unexpected JS reflection data (instance accessors)');
+ assertEquals(def.staticMethods.length, 2, 'unexpected JS reflection data (instance accessors)');
+ }
+ }
+
+ }
+}
diff --git a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/TestClassExportSuppressed1.as b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/TestClassExportSuppressed1.as
new file mode 100644
index 0000000..40892d9
--- /dev/null
+++ b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/TestClassExportSuppressed1.as
@@ -0,0 +1,116 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 flexUnitTests.reflection.support
+{
+
+
+ /**
+ * @royalesuppresspublicvarwarning
+ * @royalesuppressexport
+ */
+ public class TestClassExportSuppressed1
+ {
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing reflection into it
+
+ public static const CLASSNAME:String = 'flexUnitTests.reflection.support.TestClassExportSuppressed1'
+
+ /**
+ *
+ */
+ public static function myStaticMethod():void{
+
+ }
+ /**
+ *
+ */
+ public static function get somethingStatic():Boolean{
+ return false;
+ }
+
+ /**
+ *
+ */
+ public static var someStaticVar:Boolean;
+
+ /**
+ *
+ */
+ public static function myOtherStaticMethod():void{
+
+ }
+
+ /**
+ *
+ */
+ public static function get somethingElseStatic():Boolean{
+ return false;
+ }
+
+ /**
+ *
+ */
+ public static var someOtherStaticVar:Boolean;
+
+
+
+ public function TestClassExportSuppressed1()
+ {
+
+ }
+
+ /**
+ *
+ */
+ public function myInstanceMethod():void{
+
+ }
+
+ /**
+ *
+ */
+ public function get something():Boolean{
+ return false;
+ }
+
+ /**
+ *
+ */
+ public var someVar:Boolean;
+
+ /**
+ *
+ */
+ public function myOtherInstanceMethod():void{
+
+ }
+
+ /**
+ *
+ */
+ public function get somethingElse():Boolean{
+ return false;
+ }
+
+ /**
+ *
+ */
+ public var someOtherVar:Boolean;
+ }
+}
diff --git a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/TestClassExportSuppressed2.as b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/TestClassExportSuppressed2.as
new file mode 100644
index 0000000..82563a8
--- /dev/null
+++ b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/TestClassExportSuppressed2.as
@@ -0,0 +1,116 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 flexUnitTests.reflection.support
+{
+
+
+ /**
+ * @royalesuppresspublicvarwarning
+ *
+ */
+ public class TestClassExportSuppressed2
+ {
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing reflection into it
+
+ public static const CLASSNAME:String = 'flexUnitTests.reflection.support.TestClassExportSuppressed2'
+
+ /**
+ *
+ */
+ public static function myStaticMethod():void{
+
+ }
+ /**
+ *
+ */
+ public static function get somethingStatic():Boolean{
+ return false;
+ }
+
+ /**
+ *
+ */
+ public static var someStaticVar:Boolean;
+
+ /**
+ * @royalesuppressexport
+ */
+ public static function myOtherStaticMethod():void{
+
+ }
+
+ /**
+ * @royalesuppressexport
+ */
+ public static function get somethingElseStatic():Boolean{
+ return false;
+ }
+
+ /**
+ * @royalesuppressexport
+ */
+ public static var someOtherStaticVar:Boolean;
+
+
+
+ public function TestClassExportSuppressed2()
+ {
+
+ }
+
+ /**
+ *
+ */
+ public function myInstanceMethod():void{
+
+ }
+
+ /**
+ *
+ */
+ public function get something():Boolean{
+ return false;
+ }
+
+ /**
+ *
+ */
+ public var someVar:Boolean;
+
+ /**
+ * @royalesuppressexport
+ */
+ public function myOtherInstanceMethod():void{
+
+ }
+
+ /**
+ * @royalesuppressexport
+ */
+ public function get somethingElse():Boolean{
+ return false;
+ }
+
+ /**
+ * @royalesuppressexport
+ */
+ public var someOtherVar:Boolean;
+ }
+}
diff --git a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/testFunction.as b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/testFunction.as
new file mode 100644
index 0000000..17b274d
--- /dev/null
+++ b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/testFunction.as
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 flexUnitTests.reflection.support
+{
+
+ /**
+ * Only used for testing royalesuppressexport doc-directive (control)
+ * @return echo the qName of this function
+ *
+ */
+ public function testFunction():String{
+ return 'flexUnitTests.reflection.support.testFunction';
+ }
+
+}
diff --git a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/testFunctionExportSuppressed.as b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/testFunctionExportSuppressed.as
new file mode 100644
index 0000000..cbc802a
--- /dev/null
+++ b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/testFunctionExportSuppressed.as
@@ -0,0 +1,32 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 flexUnitTests.reflection.support
+{
+
+ /**
+ * Only used for testing royalesuppressexport doc-directive (active)
+ * @return echo the qName of this function
+ *
+ * @royalesuppressexport
+ */
+ public function testFunctionExportSuppressed():String{
+ return 'flexUnitTests.reflection.support.testFunctionExportSuppressed';
+ }
+
+}