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 2020/04/17 22:49:53 UTC

[royale-asjs] 02/03: Added initial tests for mx Collections. ArrayCollection iteration tests, passing after a recent compiler change.

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 f240ddad74bd43b6536f7a3fe4b7dabe24adfa76
Author: greg-dove <gr...@gmail.com>
AuthorDate: Sat Apr 18 10:48:15 2020 +1200

    Added initial tests for mx Collections.
    ArrayCollection iteration tests, passing after a recent compiler change.
---
 .../test/royale/flexUnitTests/MXRoyaleTester.as    |   6 +-
 .../flexUnitTests/mxroyale/CollectionsTest.as      | 112 +++++++++++++++++++++
 .../support/ACTestOne.as}                          |  33 +++---
 .../support/ACTestTwo.as}                          |  25 ++---
 4 files changed, 147 insertions(+), 29 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/MXRoyaleTester.as b/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/MXRoyaleTester.as
index 510a492..e7920c6 100644
--- a/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/MXRoyaleTester.as
+++ b/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/MXRoyaleTester.as
@@ -29,9 +29,9 @@ package flexUnitTests
     {
         public function MXRoyaleTester()
         {
-           }
-        
-        
+        }
+
+        public var acTest:CollectionsTest;
         public var objectUtilTest:ObjectUtilTest;
         public var flexSDK_ObjectUtilTests:FlexSDK_ObjectUtil_Tests;
         public var flexSDK_ObjectUtil_FLEX_34852_Tests:FlexSDK_ObjectUtil_FLEX_34852_Tests;
diff --git a/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/mxroyale/CollectionsTest.as b/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/mxroyale/CollectionsTest.as
new file mode 100644
index 0000000..c2fd747
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/mxroyale/CollectionsTest.as
@@ -0,0 +1,112 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.mxroyale
+{
+    
+    
+
+    import org.apache.royale.test.asserts.*;
+    import flexUnitTests.mxroyale.support.*;
+
+
+    import mx.collections.ArrayCollection;
+
+
+
+/**
+     * @royalesuppresspublicvarwarning
+     */
+    public class CollectionsTest
+    {
+    
+        
+        public static var isJS:Boolean = COMPILE::JS;
+    
+
+        [Before]
+        public function setUp():void
+        {
+        
+        }
+        
+        [After]
+        public function tearDown():void
+        {
+
+        }
+        
+        [BeforeClass]
+        public static function setUpBeforeClass():void
+        {
+        }
+        
+        [AfterClass]
+        public static function tearDownAfterClass():void
+        {
+        }
+
+        
+        private var testAC2:ACTestTwo = new ACTestTwo();
+    
+        [Test]
+        public function testForEachViaMemberAccess():void{
+            var testOut:Array = [];
+
+            for each(var item:Object in testAC2.nestedOne.ac) {
+                testOut.push(item)
+            }
+
+            var expected:Array = testAC2.nestedOne.getOriginalContents();
+            assertEquals(testOut.toString(), expected.toString(), 'unexpected results from for-each iteration');
+
+        }
+
+
+        private var localMemberAC:ArrayCollection = new ArrayCollection(['localMember1', 'localMember2']);
+
+        [Test]
+        public function testForEachViaLocalMember():void{
+            var testOut:Array = [];
+
+            for each(var item:Object in localMemberAC) {
+                testOut.push(item)
+            }
+
+            var expected:Array = ['localMember1', 'localMember2'];
+            assertEquals(testOut.toString(), expected.toString(), 'unexpected results from for-each iteration');
+
+        }
+
+
+        [Test]
+        public function testForEachViaLocalVar():void{
+            var testOut:Array = [];
+            var localVarAC:ArrayCollection = new ArrayCollection(['localVar1', 'localVar2']);
+
+            for each(var item:Object in localVarAC) {
+                testOut.push(item)
+            }
+
+            var expected:Array = ['localVar1', 'localVar2'];
+            assertEquals(testOut.toString(), expected.toString(), 'unexpected results from for-each iteration');
+
+        }
+        
+    }
+}
diff --git a/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/MXRoyaleTester.as b/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/mxroyale/support/ACTestOne.as
similarity index 67%
copy from frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/MXRoyaleTester.as
copy to frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/mxroyale/support/ACTestOne.as
index 510a492..7f7eb40 100644
--- a/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/MXRoyaleTester.as
+++ b/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/mxroyale/support/ACTestOne.as
@@ -16,26 +16,31 @@
 //  limitations under the License.
 //
 ////////////////////////////////////////////////////////////////////////////////
-package flexUnitTests
+package flexUnitTests.mxroyale.support
 {
-    import flexUnitTests.mxroyale.*
-    
-    [Suite]
-    [RunWith("org.apache.royale.test.runners.SuiteRunner")]
+
+    import mx.collections.ArrayCollection;
+
     /**
      * @royalesuppresspublicvarwarning
      */
-    public class MXRoyaleTester
+    public class ACTestOne
     {
-        public function MXRoyaleTester()
-        {
-           }
+        //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 var objectUtilTest:ObjectUtilTest;
-        public var flexSDK_ObjectUtilTests:FlexSDK_ObjectUtil_Tests;
-        public var flexSDK_ObjectUtil_FLEX_34852_Tests:FlexSDK_ObjectUtil_FLEX_34852_Tests;
-        public var flexSDK_ObjectUtil_Compare_Tests:FlexSDK_ObjectUtil_Compare_Tests;
+        public function ACTestOne()
+        {
+         ac = new ArrayCollection(getOriginalContents());
+        }
+
+        public function getOriginalContents():Array{
+            return ['one', 'two'];
+        }
+
+        public var ac:ArrayCollection;
+
         
     }
     
diff --git a/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/MXRoyaleTester.as b/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/mxroyale/support/ACTestTwo.as
similarity index 68%
copy from frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/MXRoyaleTester.as
copy to frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/mxroyale/support/ACTestTwo.as
index 510a492..088b6b4 100644
--- a/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/MXRoyaleTester.as
+++ b/frameworks/projects/MXRoyale/src/test/royale/flexUnitTests/mxroyale/support/ACTestTwo.as
@@ -16,26 +16,27 @@
 //  limitations under the License.
 //
 ////////////////////////////////////////////////////////////////////////////////
-package flexUnitTests
+package flexUnitTests.mxroyale.support
 {
-    import flexUnitTests.mxroyale.*
     
-    [Suite]
-    [RunWith("org.apache.royale.test.runners.SuiteRunner")]
+    import flexUnitTests.mxroyale.support.testnamespace;
+    
     /**
      * @royalesuppresspublicvarwarning
      */
-    public class MXRoyaleTester
+    public class ACTestTwo
     {
-        public function MXRoyaleTester()
-        {
-           }
+        //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 function ACTestTwo()
+        {
+            nestedOne = new ACTestOne();
+        }
         
-        public var objectUtilTest:ObjectUtilTest;
-        public var flexSDK_ObjectUtilTests:FlexSDK_ObjectUtil_Tests;
-        public var flexSDK_ObjectUtil_FLEX_34852_Tests:FlexSDK_ObjectUtil_FLEX_34852_Tests;
-        public var flexSDK_ObjectUtil_Compare_Tests:FlexSDK_ObjectUtil_Compare_Tests;
+
+        public var nestedOne:ACTestOne;
+
         
     }