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

commit 070f64d8cb4de84a49b52845345acf9f0b9a5253
Author: greg-dove <[email protected]>
AuthorDate: Thu Oct 8 10:06:51 2020 +1300

    Updated tests for recent Reflection improvements
---
 .../reflection/ReflectionTesterTest.as             | 31 ++++++++++++++++++++--
 .../reflection/ReflectionTesterTestAlias.as        | 23 +++++++++++++++-
 .../reflection/ReflectionTesterTestDynamic.as      | 11 +++-----
 .../reflection/ReflectionTesterTestUseCache.as     |  1 +
 .../flexUnitTests/reflection/support/TestClass1.as |  4 +--
 5 files changed, 58 insertions(+), 12 deletions(-)

diff --git 
a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTest.as
 
b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTest.as
index 3eefc5e..e57f631 100644
--- 
a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTest.as
+++ 
b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTest.as
@@ -76,6 +76,7 @@ package flexUnitTests.reflection
         public function testBasicDescribeTypeClass():void
         {
             var def:TypeDefinition = describeType(TestClass2);
+
             
             assertEquals( def.packageName, "flexUnitTests.reflection.support", 
"Unexpected package name");
             assertEquals( def.name, "TestClass2", "Unexpected type name");
@@ -122,14 +123,40 @@ package flexUnitTests.reflection
             assertEquals(
                     "flexUnitTests.reflection.support.TestClass4",
                     constructor.declaredBy.qualifiedName, "unexpected 
constructor declaredBy");
-            
+
+            assertEquals(
+                    0,
+                    constructor.parameters.length, "unexpected constructor 
params");
+            //TestClass3 extends TestClass1
+            def =  describeType(TestClass3);
+            //TestClass3 has no explicit constructor defined, it should still 
be represented and has no parameters
+            constructor = def.constructorMethod;
+
+            assertEquals(
+                    "flexUnitTests.reflection.support.TestClass3",
+                    constructor.declaredBy.qualifiedName, "unexpected 
constructor declaredBy");
+
             assertEquals(
                     0,
                     constructor.parameters.length, "unexpected constructor 
params");
+
+            def =  describeType(TestClass1);
+
+            constructor = def.constructorMethod;
+
+            assertEquals(
+                    "flexUnitTests.reflection.support.TestClass1",
+                    constructor.declaredBy.qualifiedName, "unexpected 
constructor declaredBy");
+
+
+            //there is one optional parameter in the base class
+            assertEquals(
+                    1,
+                    constructor.parameters.length, "unexpected constructor 
params");
             
             
         }
-        
+
         
         [TestVariance(variance="JS", description="Variance in test due to 
current inability for js target to reflect into non-Royale base classes or 
typedefs")]
         [Test]
diff --git 
a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestAlias.as
 
b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestAlias.as
index 57aeb95..729454f 100644
--- 
a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestAlias.as
+++ 
b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestAlias.as
@@ -35,11 +35,13 @@ package flexUnitTests.reflection
         [BeforeClass]
         public static function setUpBeforeClass():void
         {
+            ExtraData.addAll()
         }
         
         [AfterClass]
         public static function tearDownAfterClass():void
         {
+            ExtraData.reset();
         }
         
         [Before]
@@ -73,7 +75,26 @@ package flexUnitTests.reflection
             //class is retrievable by alias
             assertEquals( TestClass3, getClassByAlias("fjsTest"), "unexpected 
Class value");
             
-            
+        }
+
+        [Test]
+        public function testNativeTypes():void
+        {
+            //no initial alias
+            assertNull(getAliasByClass(String));
+            registerClassAlias("myStringAlias", String);
+            //alias is registered
+            assertEquals( "myStringAlias", getAliasByClass(String), 
"unexpected Alias value");
+            //register same alias for another class
+            registerClassAlias("myStringAlias", TestClass3);
+            //original alias mapping is deregistered
+            assertNull(getAliasByClass(String));
+            //alias is registered for new class
+            assertEquals( "myStringAlias", getAliasByClass(TestClass3), 
"unexpected Alias value");
+
+            //class is retrievable by alias
+            assertEquals( TestClass3, getClassByAlias("myStringAlias"), 
"unexpected Class value");
+
         }
         
         
diff --git 
a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestDynamic.as
 
b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestDynamic.as
index 4064790..730ef71 100644
--- 
a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestDynamic.as
+++ 
b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestDynamic.as
@@ -113,13 +113,10 @@ package flexUnitTests.reflection
             assertTrue( contentStringsMatch(getDynamicFields(Object), 
singleDynField), "dynamic fields should match reference list");
             delete Object['test'];
             
-            //temporarily disable dynamic fields test for class because
-            //goog.exportSymbol for static method creates enumerable field -JT
-            //goog.exportSymbol creates enumerable static methods, these won't 
work
-            //assertTrue( contentStringsMatch(getDynamicFields(TestClass1), 
emptyArray), "dynamic fields should match reference list");
-            //TestClass1['test'] = true;
-            //assertTrue( contentStringsMatch(getDynamicFields(TestClass1), 
singleDynField), "dynamic fields should match reference list");
-            //delete TestClass1['test'];
+            assertTrue( contentStringsMatch(getDynamicFields(TestClass1), 
emptyArray), "dynamic fields should match reference list");
+            TestClass1['test'] = true;
+            assertTrue( contentStringsMatch(getDynamicFields(TestClass1), 
singleDynField), "dynamic fields should match reference list");
+            delete TestClass1['test'];
             
             //interface is dynamic (even if it doesn't make much sense)
             assertTrue( contentStringsMatch(getDynamicFields(ITestInterface), 
emptyArray), "dynamic fields should match reference list");
diff --git 
a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestUseCache.as
 
b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestUseCache.as
index 547325d..08d8b49 100644
--- 
a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestUseCache.as
+++ 
b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/ReflectionTesterTestUseCache.as
@@ -40,6 +40,7 @@ package flexUnitTests.reflection
         [AfterClass]
         public static function tearDownAfterClass():void
         {
+            TypeDefinition.useCache = false;
         }
         
         [Before]
diff --git 
a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/TestClass1.as
 
b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/TestClass1.as
index 91b9f35..bca4eb0 100644
--- 
a/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/TestClass1.as
+++ 
b/frameworks/projects/Reflection/src/test/royale/flexUnitTests/reflection/support/TestClass1.as
@@ -27,9 +27,9 @@ package flexUnitTests.reflection.support
      */
     public class TestClass1 implements ITestInterface
     {
-        public function TestClass1()
+        public function TestClass1(somethingElse:ITestInterface = null)
         {
-            // var something:ITestInterface2;
+
         }
         
         [Bindable]

Reply via email to