Thanks for bringing that to my attention, Josh. it should be fixed now (I tested with your example, thanks for that).
On Tue, Oct 15, 2019 at 10:31 AM Greg Dove <greg.d...@gmail.com> wrote: > > Hi Josh, thanks, I will look into that today. > > > On Tue, Oct 15, 2019 at 10:30 AM Josh Tynjala <joshtynj...@apache.org> > wrote: > >> Hey Greg, >> >> Starting with the commit, there are times when compilation gets stuck in >> an infinite loop. It should be possible to reproduce using the following >> code: >> >> for each(var key:Object in Fake.hello) >> { >> } >> >> "Fake" is a class that does not exist. It should result in an error, but >> the compiler seems to get stuck trying to resolve it over and over again. >> >> - Josh >> >> On 2019/10/02 08:39:35, gregd...@apache.org wrote: >> > 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 e52954b22a4599c75ba242955273627867e00e4d >> > Author: greg-dove <greg.d...@gmail.com> >> > AuthorDate: Sun Sep 29 15:16:21 2019 +1300 >> > >> > RoyaleArrayLike support (IArrayList and BinaryData) >> > --- >> > frameworks/projects/Collections/pom.xml | 14 ++ >> > .../src/main/config/compile-swf-config.xml | 1 + >> > .../src/main/royale/CollectionsClasses.as | 2 + >> > .../org/apache/royale/collections/ArrayList.as | 2 +- >> > .../org/apache/royale/collections/IArrayList.as | 13 +- >> > frameworks/projects/Core/pom.xml | 19 +- >> > .../Core/src/main/config/compile-swf-config.xml | 6 +- >> > .../projects/Core/src/main/royale/CoreClasses.as | 3 + >> > .../royale/org/apache/royale/utils/BinaryData.as | 11 +- >> > .../Language/src/main/royale/LanguageClasses.as | 2 +- >> > .../apache/royale/language/iterator/arrayLike.as | 73 +++++++ >> > .../main/royale/flexUnitTests/LanguageTester.as | 8 +- >> > .../language/LanguageTesterTestArraylikeGetSet.as | 227 >> +++++++++++++++++++++ >> > .../language/LanguageTesterTestForEach.as | 205 >> +++++++++++++++++++ >> > .../language/support/checkArrayLikeFunc.as | 30 +-- >> > 15 files changed, 587 insertions(+), 29 deletions(-) >> > >> > diff --git a/frameworks/projects/Collections/pom.xml >> b/frameworks/projects/Collections/pom.xml >> > index a105423..59cb218 100644 >> > --- a/frameworks/projects/Collections/pom.xml >> > +++ b/frameworks/projects/Collections/pom.xml >> > @@ -60,6 +60,20 @@ >> > <dependencies> >> > <dependency> >> > <groupId>org.apache.royale.framework</groupId> >> > + <artifactId>Language</artifactId> >> > + <version>0.9.6-SNAPSHOT</version> >> > + <type>swc</type> >> > + <classifier>swf</classifier> >> > + </dependency> >> > + <dependency> >> > + <groupId>org.apache.royale.framework</groupId> >> > + <artifactId>Language</artifactId> >> > + <version>0.9.6-SNAPSHOT</version> >> > + <type>swc</type> >> > + <classifier>js</classifier> >> > + </dependency> >> > + <dependency> >> > + <groupId>org.apache.royale.framework</groupId> >> > <artifactId>Core</artifactId> >> > <version>0.9.6-SNAPSHOT</version> >> > <type>swc</type> >> > diff --git >> a/frameworks/projects/Collections/src/main/config/compile-swf-config.xml >> b/frameworks/projects/Collections/src/main/config/compile-swf-config.xml >> > index 6116aec..1c00110 100644 >> > --- >> a/frameworks/projects/Collections/src/main/config/compile-swf-config.xml >> > +++ >> b/frameworks/projects/Collections/src/main/config/compile-swf-config.xml >> > @@ -31,6 +31,7 @@ >> > <external-library-path> >> > >> <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element> >> > <path-element>../../../../../libs/Core.swc</path-element> >> > + >> <path-element>../../../../../libs/Language.swc</path-element> >> > </external-library-path> >> > >> > <mxml> >> > diff --git >> a/frameworks/projects/Collections/src/main/royale/CollectionsClasses.as >> b/frameworks/projects/Collections/src/main/royale/CollectionsClasses.as >> > index fe946df..ecc1033 100644 >> > --- >> a/frameworks/projects/Collections/src/main/royale/CollectionsClasses.as >> > +++ >> b/frameworks/projects/Collections/src/main/royale/CollectionsClasses.as >> > @@ -43,6 +43,8 @@ internal class CollectionsClasses >> > import org.apache.royale.collections.SortField; SortField; >> > import org.apache.royale.collections.SortFieldCompareTypes; >> SortFieldCompareTypes; >> > import org.apache.royale.collections.CompareUtils; CompareUtils; >> > + >> > + import org.apache.royale.language.iterator.arrayLike;arrayLike; >> > >> > } >> > >> > diff --git >> a/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/ArrayList.as >> b/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/ArrayList.as >> > index 38164aa..75ea856 100644 >> > --- >> a/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/ArrayList.as >> > +++ >> b/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/ArrayList.as >> > @@ -34,7 +34,6 @@ package org.apache.royale.collections >> > import flash.utils.IDataInput; >> > import flash.utils.IDataOutput; >> > } >> > - >> > >> > //-------------------------------------- >> > // Events >> > @@ -90,6 +89,7 @@ package org.apache.royale.collections >> > * @productversion Royale 0.0 >> > */ >> > [Event(name="itemUpdated", >> type="org.apache.royale.events.CollectionEvent")] >> > + >> > >> > /** >> > * The ArrayList class provides an event-driven wrapper for the >> > diff --git >> a/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/IArrayList.as >> b/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/IArrayList.as >> > index 32638b0..454d27f 100644 >> > --- >> a/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/IArrayList.as >> > +++ >> b/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/IArrayList.as >> > @@ -27,8 +27,17 @@ package org.apache.royale.collections >> > import org.apache.royale.collections.converters.IItemConverter; >> > >> > //-------------------------------------- >> > - >> > - >> > + >> > + /** >> > + * Support for Arraylike access (typed index access via []) and >> also via iteration when used with for-each loops. >> > + * >> > + * @langversion 3.0 >> > + * @playerversion Flash 10.2 >> > + * @playerversion AIR 2.6 >> > + * @productversion Royale 0.0 >> > + */ >> > + >> >> [RoyaleArrayLike(getValue="getItemAt",setValue="setItemAt",setterArgSequence="value,index",length="length",lengthAccess="getter")] >> > + >> > /** >> > * The ArrayList class provides an event-driven wrapper for the >> > * standard Array. Events are dispatched when items are added, >> removed, >> > diff --git a/frameworks/projects/Core/pom.xml >> b/frameworks/projects/Core/pom.xml >> > index 947ce17..49b3b6f 100644 >> > --- a/frameworks/projects/Core/pom.xml >> > +++ b/frameworks/projects/Core/pom.xml >> > @@ -68,5 +68,22 @@ >> > </plugin> >> > </plugins> >> > </build> >> > - >> > + <dependencies> >> > + <!-- Language is included to permit a concrete reference >> > + to the arrayLike iterator to be re-exported, so that it is always >> available --> >> > + <dependency> >> > + <groupId>org.apache.royale.framework</groupId> >> > + <artifactId>Language</artifactId> >> > + <version>0.9.6-SNAPSHOT</version> >> > + <type>swc</type> >> > + <classifier>swf</classifier> >> > + </dependency> >> > + <dependency> >> > + <groupId>org.apache.royale.framework</groupId> >> > + <artifactId>Language</artifactId> >> > + <version>0.9.6-SNAPSHOT</version> >> > + <type>swc</type> >> > + <classifier>js</classifier> >> > + </dependency> >> > + </dependencies> >> > </project> >> > diff --git >> a/frameworks/projects/Core/src/main/config/compile-swf-config.xml >> b/frameworks/projects/Core/src/main/config/compile-swf-config.xml >> > index 265d4d8..4d0d2a7 100644 >> > --- a/frameworks/projects/Core/src/main/config/compile-swf-config.xml >> > +++ b/frameworks/projects/Core/src/main/config/compile-swf-config.xml >> > @@ -31,7 +31,11 @@ >> > <external-library-path> >> > >> <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element> >> > </external-library-path> >> > - >> > + >> > + <library-path> >> > + >> <path-element>../../../../../libs/Language.swc</path-element> >> > + </library-path> >> > + >> > <allow-subclass-overrides>true</allow-subclass-overrides> >> > >> > <mxml> >> > diff --git a/frameworks/projects/Core/src/main/royale/CoreClasses.as >> b/frameworks/projects/Core/src/main/royale/CoreClasses.as >> > index 4e258c7..6d03a3b 100644 >> > --- a/frameworks/projects/Core/src/main/royale/CoreClasses.as >> > +++ b/frameworks/projects/Core/src/main/royale/CoreClasses.as >> > @@ -324,6 +324,9 @@ internal class CoreClasses >> > >> > import org.apache.royale.core.TextLineMetrics; TextLineMetrics; >> > import org.apache.royale.utils.ClassSelectorList; >> ClassSelectorList; >> > + >> > + //explicit support for RoyaleArrayLike for each iteration >> (BinaryData) >> > + import org.apache.royale.language.iterator.arrayLike;arrayLike; >> > } >> > >> > } >> > diff --git >> a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as >> b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as >> > index 2143d31..483bfb1 100644 >> > --- >> a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as >> > +++ >> b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as >> > @@ -27,7 +27,16 @@ COMPILE::JS >> > { >> > import goog.DEBUG; >> > } >> > - >> > + >> > +/** >> > + * Support for Arraylike access (typed index access via []) and also >> iteration when used with for-each loops. >> > + * >> > + * @langversion 3.0 >> > + * @playerversion Flash 10.2 >> > + * @playerversion AIR 2.6 >> > + * @productversion Royale 0.0 >> > + */ >> > >> +[RoyaleArrayLike(getValue="readByteAt",setValue="writeByteAt",setterArgSequence="index,value",length="length",lengthAccess="getter")] >> > >> > /** >> > * The BinaryData class is a class that represents binary data. The >> way >> > diff --git >> a/frameworks/projects/Language/src/main/royale/LanguageClasses.as >> b/frameworks/projects/Language/src/main/royale/LanguageClasses.as >> > index 2d4388e..f0e5ed3 100644 >> > --- a/frameworks/projects/Language/src/main/royale/LanguageClasses.as >> > +++ b/frameworks/projects/Language/src/main/royale/LanguageClasses.as >> > @@ -31,10 +31,10 @@ internal class LanguageClasses >> > import org.apache.royale.utils.Language; Language; >> > import QName; QName; >> > import Namespace; Namespace; >> > - >> > } >> > import org.apache.royale.language.string.match; match; >> > import org.apache.royale.language.string.search; search; >> > + import org.apache.royale.language.iterator.arrayLike; arrayLike; >> > } >> > >> > } >> > diff --git >> a/frameworks/projects/Language/src/main/royale/org/apache/royale/language/iterator/arrayLike.as >> b/frameworks/projects/Language/src/main/royale/org/apache/royale/language/iterator/arrayLike.as >> > new file mode 100644 >> > index 0000000..38b1c65 >> > --- /dev/null >> > +++ >> b/frameworks/projects/Language/src/main/royale/org/apache/royale/language/iterator/arrayLike.as >> > @@ -0,0 +1,73 @@ >> > >> +//////////////////////////////////////////////////////////////////////////////// >> > +// >> > +// 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.language.iterator >> > +{ >> > + /** >> > + * Used by the compiler for classes with [RoyaleArrayLike] >> metadata when processing for each loops >> > + * @param forInstance the instance to be checked >> > + * @param lengthCheck either a string that represents a property >> to return length value, or a function method reference, e.g. >> instance.length() >> > + * @param getAt the String name of the accessor for the item at >> index... e.g. 'getItemAt'. If null it will default to Array Access [] >> > + * @param lengthIsMethodCall true if the length accessor is an >> explicit method call instead of a getter >> > + * @return a lightweight iterator Object with hasNext() and next() >> methods >> > + * >> > + * @royalesuppressexport >> > + */ >> > + public function arrayLike(forInstance:Object, lengthCheck:String, >> getAt:String, lengthIsMethodCall:Boolean):Object{ >> > + if (forInstance) { >> > + var i:int = 0; >> > + var ret:Object = { }; >> > + if (lengthIsMethodCall) { >> > + ret['hasNext'] = function():Boolean{ >> > + return i < forInstance[lengthCheck](); >> > + } >> > + } else { >> > + ret['hasNext'] = function():Boolean{ >> > + return i < forInstance[lengthCheck] >> > + } >> > + } >> > + if (getAt != null){ >> > + ret['next'] = function():*{ >> > + return forInstance[getAt](i++); >> > + } >> > + } else { >> > + ret['next'] = function():*{ >> > + return forInstance[i++]; >> > + } >> > + } >> > + } else { >> > + //no need to create a new instance: >> > + ret = NULL_ITERABLE; >> > + } >> > + return ret; >> > + } >> > +} >> > +/** >> > + * @royalesuppressexport >> > + */ >> > +const NULL_ITERABLE:* = { >> > + 'hasNext':function():Boolean{ >> > + return false; >> > + }, >> > + 'next':function():*{ >> > + //this should never be called in compiler-generated code in >> any case >> > + throw new TypeError('Cannot iterate over a null object >> reference'); >> > + } >> > +}; >> > + >> > + >> > diff --git >> a/manualtests/UnitTests/src/main/royale/flexUnitTests/LanguageTester.as >> b/manualtests/UnitTests/src/main/royale/flexUnitTests/LanguageTester.as >> > index 441932b..52337ba 100644 >> > --- >> a/manualtests/UnitTests/src/main/royale/flexUnitTests/LanguageTester.as >> > +++ >> b/manualtests/UnitTests/src/main/royale/flexUnitTests/LanguageTester.as >> > @@ -30,7 +30,7 @@ package flexUnitTests >> > public function LanguageTester() >> > { >> > // see notes in CoreTester >> > - var arr:Array = [LanguageTesterTestIs, >> LanguageTesterIntUint, LanguageTesterTestVector,LanguageTesterTestClass]; >> > + // var arr:Array = [LanguageTesterTestIs, >> LanguageTesterIntUint, LanguageTesterTestVector,LanguageTesterTestClass]; >> > } >> > >> > public var languageTestIs:LanguageTesterTestIs; >> > @@ -40,5 +40,11 @@ package flexUnitTests >> > public var languageTestVector:LanguageTesterTestVector; >> > >> > public var languageTestClass:LanguageTesterTestClass; >> > + >> > + public var languageTestForeach:LanguageTesterTestForEach; >> > + >> > + public var languageTestgetSet:LanguageTesterTestArraylikeGetSet >> > + >> > + >> > } >> > } >> > diff --git >> a/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestArraylikeGetSet.as >> b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestArraylikeGetSet.as >> > new file mode 100644 >> > index 0000000..8ff14fe >> > --- /dev/null >> > +++ >> b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestArraylikeGetSet.as >> > @@ -0,0 +1,227 @@ >> > >> +//////////////////////////////////////////////////////////////////////////////// >> > +// >> > +// 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.language >> > +{ >> > + >> > + >> > + import org.apache.royale.test.asserts.*; >> > + >> > + import flexUnitTests.language.support.*; >> > + import org.apache.royale.collections.ArrayList; >> > + import org.apache.royale.collections.ArrayListView; >> > + import org.apache.royale.collections.IArrayList; >> > + import org.apache.royale.utils.BinaryData; >> > + import testshim.RoyaleUnitTestRunner; >> > + >> > + /** >> > + * @royalesuppresspublicvarwarning >> > + */ >> > + public class LanguageTesterTestArraylikeGetSet >> > + { >> > + >> > + public static var isJS:Boolean = COMPILE::JS; >> > + >> > + [BeforeClass] >> > + public static function setUpBeforeClass():void >> > + { >> > + >> > + } >> > + >> > + [AfterClass] >> > + public static function tearDownAfterClass():void >> > + { >> > + } >> > + >> > + [Before] >> > + public function setUp():void >> > + { >> > + arrayList= new ArrayList(['dog', 'cat','mouse','gerbil']); >> > + } >> > + >> > + [After] >> > + public function tearDown():void >> > + { >> > + } >> > + >> > + >> > + /*public function LanguageTesterTestArraylikeGetSet(){ >> > + >> > + }*/ >> > + >> > + public var arrayList:ArrayList; >> > + >> > + /* [Test] >> > + public function testImpl():void >> > + { >> > + var other:ArrayList = new ArrayList([1,2,3]); >> > + var local:ArrayList = new ArrayList(['gerbil','something >> else']); >> > + arrayList[0] = local[0]; >> > + assertEquals(arrayList.getItemAt(0),'gerbil', 'unexpected >> get/set result') >> > + >> //RoyaleUnitTestRunner.consoleOut(arrayList.source.toString()); >> > + arrayList.setItemAt('manually assigned gerbil',0); >> > + >> RoyaleUnitTestRunner.consoleOut(arrayList.source.toString()); >> > + if (arrayList[0] == 'manually assigned gerbil') { >> > + arrayList[0] = local[1]; >> > + } >> > + assertEquals(arrayList.getItemAt(0),'something else', >> 'unexpected get/set result'); >> > + var collect:Array = []; >> > + for(var i:int =0; i<other[2];i++) { // 'getItemAt' used in >> here >> > + collect.push(other[i]); //'getItemAt' >> > + } >> > + assertEquals(collect.toString(),'1,2,3', 'unexpected loop >> result'); >> > + >> > + if (arrayList[0] == 'not the value') { >> > + arrayList[0] = 'bad assignment'; >> > + } else { >> > + arrayList[0] = 'correct assignment'; >> > + } >> > + assertEquals(arrayList.getItemAt(0),'correct assignment', >> 'unexpected assignment result in else block'); >> > + >> RoyaleUnitTestRunner.consoleOut(arrayList.source.toString()); >> > + >> > + try{ >> > + arrayList[0] = "inside try"; >> > + } catch (e:Error) >> > + { >> > + //no error >> > + } finally{ >> > + arrayList[1] = "inside finally"; >> > + } >> > + assertEquals(arrayList.getItemAt(0),'inside try', >> 'unexpected try/catch/finally result'); >> > + assertEquals(arrayList.getItemAt(1),'inside finally', >> 'unexpected try/catch/finally result'); >> > + >> > + } >> > + >> > + [Test] >> > + public function testSubClass():void{ >> > + //test 'inheritance' via class (ArrayListView in this case) >> > + arrayList= new ArrayList(['dog', 'cat','mouse','gerbil']); >> > + var other:ArrayList = new ArrayList([1,2,3]); >> > + var local:ArrayList = new ArrayList(['gerbil','something >> else']); >> > + >> > + var alv:ArrayListView = new ArrayListView(arrayList); >> > + var alv1:ArrayListView = new ArrayListView(other); >> > + var alv2:ArrayListView = new ArrayListView(local); >> > + alv[0] = alv2[0]; >> > + assertEquals(alv.getItemAt(0),'gerbil', 'unexpected >> get/set result'); >> > + >> //RoyaleUnitTestRunner.consoleOut(arrayList.source.toString()); >> > + alv.setItemAt('manually assigned gerbil',0); >> > + RoyaleUnitTestRunner.consoleOut(alv.source.toString()); >> > + if (alv[0] == 'manually assigned gerbil') { >> > + alv[0] = alv2[1]; >> > + } >> > + assertEquals(alv.getItemAt(0),'something else', >> 'unexpected get/set result'); >> > + var collect:Array = []; >> > + for(var i:int =0; i<alv1[2];i++) { // 'getItemAt' used in >> here >> > + collect.push(alv1[i]); //'getItemAt' >> > + } >> > + assertEquals(collect.toString(),'1,2,3', 'unexpected loop >> result'); >> > + >> > + if (alv[0] == 'not the value') { >> > + alv[0] = 'bad assignment'; >> > + } else { >> > + alv[0] = 'correct assignment'; >> > + } >> > + assertEquals(alv.getItemAt(0),'correct assignment', >> 'unexpected assignment result in else block'); >> > + RoyaleUnitTestRunner.consoleOut(alv.source.toString()); >> > + >> > + try{ >> > + alv[0] = "inside try"; >> > + } catch (e:Error) >> > + { >> > + //no error >> > + } finally{ >> > + alv[1] = "inside finally"; >> > + } >> > + assertEquals(alv.getItemAt(0),'inside try', 'unexpected >> try/catch/finally result'); >> > + assertEquals(alv.getItemAt(1),'inside finally', >> 'unexpected try/catch/finally result'); >> > + } >> > + */ >> > + >> > + [Test] >> > + public function testNested():void >> > + { >> > + arrayList= new ArrayList(['dog', 'cat','mouse','gerbil']); >> > + >> > + var f:Function = function something():String{ >> > + arrayList[1] = 'another dog'; >> > + return arrayList[1] as String; >> > + }; >> > + >> > + var f2:Function = function():String{ >> > + arrayList[1] = 'yet another dog'; >> > + return arrayList[1] as String; >> > + }; >> > + >> > + var check:String = f(); >> > + assertEquals(check,'another dog', 'unexpected get/set >> result'); >> > + >> > + assertEquals(arrayList.getItemAt(1),'another dog', >> 'unexpected get/set result'); >> > + >> > + check = f2(); >> > + assertEquals(check,'yet another dog', 'unexpected get/set >> result'); >> > + >> > + assertEquals(arrayList.getItemAt(1),'yet another dog', >> 'unexpected get/set result'); >> > + >> > + } >> > + >> > + private function localReturn(val:ArrayList):String{ >> > + val[0] = 'get and set from localMethod'; >> > + return val[0] as String; >> > + } >> > + >> > + [Test] >> > + public function testLocalMethodReturn():void{ >> > + arrayList= new ArrayList(['dog', 'cat','mouse','gerbil']); >> > + >> > + var check:String = localReturn(arrayList); >> > + assertEquals(check,'get and set from localMethod', >> 'unexpected get/set result'); >> > + assertEquals(arrayList.getItemAt(0),'get and set from >> localMethod', 'unexpected get/set result'); >> > + } >> > + >> > + >> > + [Test] >> > + public function testExternalFunc():void{ >> > + arrayList= new ArrayList(['dog', 'cat','mouse','gerbil']); >> > + >> > + var check:String = checkArrayLikeFunc(arrayList); >> > + assertEquals(check,'get and set from checkArrayLikeFunc', >> 'unexpected get/set result'); >> > + assertEquals(arrayList.getItemAt(0),'get and set from >> checkArrayLikeFunc', 'unexpected get/set result'); >> > + } >> > + >> > + >> > + public function testBinaryData():void{ >> > + var bd:BinaryData = new BinaryData(); >> > + bd.length = 100; >> > + var checkVal:uint = 0; >> > + for (var i:uint=0;i<100;i++) { >> > + checkVal += i; >> > + bd[i] = i; >> > + } >> > + var summationCheck:uint=0; >> > + for each(var byte:uint in bd) { >> > + summationCheck += byte; >> > + } >> > + assertEquals(bd[99], 99, 'unexpected value at index'); >> > + assertEquals(summationCheck, checkVal, 'unexpected check >> on result') >> > + } >> > + >> > + >> > + >> > + } >> > +} >> > diff --git >> a/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestForEach.as >> b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestForEach.as >> > new file mode 100644 >> > index 0000000..2a2c2e2 >> > --- /dev/null >> > +++ >> b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestForEach.as >> > @@ -0,0 +1,205 @@ >> > >> +//////////////////////////////////////////////////////////////////////////////// >> > +// >> > +// 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.language >> > +{ >> > + >> > + >> > + import org.apache.royale.test.asserts.*; >> > + >> > + import flexUnitTests.language.support.*; >> > + import org.apache.royale.collections.ArrayList; >> > + import org.apache.royale.collections.IArrayList; >> > + >> > + import testshim.RoyaleUnitTestRunner; >> > + >> > + /** >> > + * @royalesuppresspublicvarwarning >> > + */ >> > + public class LanguageTesterTestForEach >> > + { >> > + /*import org.apache.royale.language.iterator.arrayLike;*/ >> > + >> > + public static var isJS:Boolean = COMPILE::JS; >> > + >> > + [BeforeClass] >> > + public static function setUpBeforeClass():void >> > + { >> > + >> > + } >> > + >> > + [AfterClass] >> > + public static function tearDownAfterClass():void >> > + { >> > + } >> > + >> > + [Before] >> > + public function setUp():void >> > + { >> > + _myList = new ArrayList(['dog', 'cat','mouse','gerbil']) >> > + } >> > + >> > + [After] >> > + public function tearDown():void >> > + { >> > + } >> > + private var _animal:String; >> > + private var _char:String; >> > + private var _myList:ArrayList >> > + >> > + >> > + [Test] >> > + public function testNested1():void >> > + { >> > + var arrayList:ArrayList = new ArrayList(['dog', >> 'cat','mouse','gerbil']); >> > + >> > + var foundItems:Array = []; >> > + var charItems:Array = []; >> > + for each(var animal:String in arrayList) { >> > + foundItems.push(animal); >> > + var deepList:ArrayList = new >> ArrayList(animal.split('')); >> > + for each(var char:String in deepList) { >> > + // RoyaleUnitTestRunner.consoleOut(char); >> > + charItems.push(char); >> > + } >> > + } >> > + // RoyaleUnitTestRunner.consoleOut(value + ''); >> > + assertEquals(foundItems.toString(), >> 'dog,cat,mouse,gerbil', 'unexpected for each result'); >> > + //check nested loop content >> > + assertEquals(charItems.toString(), >> 'd,o,g,c,a,t,m,o,u,s,e,g,e,r,b,i,l', 'unexpected for each result'); >> > + } >> > + >> > + >> > + >> > + [Test] >> > + public function testNested1a():void >> > + { >> > + var array:Array=['dog', 'cat','mouse','gerbil']; >> > + >> > + var foundItems:Array = []; >> > + var charItems:Array = []; >> > + for each(_animal in array) { >> > + foundItems.push(_animal); >> > + var deepList:Array = _animal.split(''); >> > + for each(_char in deepList) { >> > + // RoyaleUnitTestRunner.consoleOut(char); >> > + charItems.push(_char); >> > + } >> > + } >> > + // RoyaleUnitTestRunner.consoleOut(value + ''); >> > + assertEquals(foundItems.toString(), >> 'dog,cat,mouse,gerbil', 'unexpected for each result'); >> > + //check nested loop content >> > + assertEquals(charItems.toString(), >> 'd,o,g,c,a,t,m,o,u,s,e,g,e,r,b,i,l', 'unexpected for each result'); >> > + } >> > + >> > + [Test] >> > + public function testNested1b():void >> > + { >> > + //using a target referenced externally >> > + var foundItems:Array = []; >> > + var charItems:Array = []; >> > + for each(_animal in _myList) { >> > + foundItems.push(_animal); >> > + var deepList:ArrayList = new >> ArrayList(_animal.split('')); >> > + for each(_char in deepList) { >> > + // RoyaleUnitTestRunner.consoleOut(char); >> > + charItems.push(_char); >> > + } >> > + } >> > + // RoyaleUnitTestRunner.consoleOut(value + ''); >> > + assertEquals(foundItems.toString(), >> 'dog,cat,mouse,gerbil', 'unexpected for each result'); >> > + //check nested loop content >> > + assertEquals(charItems.toString(), >> 'd,o,g,c,a,t,m,o,u,s,e,g,e,r,b,i,l', 'unexpected for each result'); >> > + } >> > + >> > + >> > + [Test] >> > + public function testNested2():void >> > + { >> > + var arrayList:ArrayList = new ArrayList(['dog', >> 'cat','mouse','gerbil']); >> > + >> > + var foundItems:Array = []; >> > + var charItems:Array = []; >> > + for each(_animal in arrayList) { >> > + foundItems.push(_animal); >> > + var deepList:ArrayList = new >> ArrayList(_animal.split('')); >> > + for each(_char in deepList) { >> > + // RoyaleUnitTestRunner.consoleOut(char); >> > + charItems.push(_char); >> > + } >> > + } >> > + // RoyaleUnitTestRunner.consoleOut(value + ''); >> > + assertEquals(foundItems.toString(), >> 'dog,cat,mouse,gerbil', 'unexpected for each result'); >> > + //check nested loop content >> > + assertEquals(charItems.toString(), >> 'd,o,g,c,a,t,m,o,u,s,e,g,e,r,b,i,l', 'unexpected for each result'); >> > + } >> > + >> > + >> > + [Test] >> > + public function testNested3():void >> > + { >> > + var arrayList:IArrayList = new ArrayList(['dog', >> 'cat','mouse','gerbil']); >> > + >> > + var foundItems:Array = []; >> > + var charItems:Array = []; >> > + for each(_animal in arrayList) { >> > + foundItems.push(_animal); >> > + var deepList:IArrayList = new >> ArrayList(_animal.split('')); >> > + for each(_char in deepList) { >> > + // RoyaleUnitTestRunner.consoleOut(char); >> > + charItems.push(_char); >> > + } >> > + } >> > + // RoyaleUnitTestRunner.consoleOut(value + ''); >> > + assertEquals(foundItems.toString(), >> 'dog,cat,mouse,gerbil', 'unexpected for each result'); >> > + //check nested loop content >> > + assertEquals(charItems.toString(), >> 'd,o,g,c,a,t,m,o,u,s,e,g,e,r,b,i,l', 'unexpected for each result'); >> > + } >> > + >> > + >> > + [Test] >> > + public function testXML():void{ >> > + var xm:XML = <test><child><child/></child></test>; >> > + RoyaleUnitTestRunner.consoleOut('xml' ); >> > + for each(var xml:XML in xm..child) { >> > + RoyaleUnitTestRunner.consoleOut(xml.toXMLString() ); >> > + } >> > + RoyaleUnitTestRunner.consoleOut('thing' ); >> > + for each(var thing:XML in xm) { >> > + RoyaleUnitTestRunner.consoleOut(thing.toXMLString() ); >> > + } >> > + assertTrue(true) >> > + } >> > + >> > + >> > + [Test] >> > + public function tesTargetMutation():void{ >> > + var arrayList:ArrayList = new ArrayList(['dog', >> 'cat','mouse','gerbil']); >> > + >> > + var foundItems:Array = []; >> > + var charItems:Array = []; >> > + for each(_animal in arrayList) { >> > + foundItems.push(_animal); >> > + if (arrayList.length) arrayList.removeAll();//should >> stop iterating after first item >> > + } >> > + assertEquals(foundItems.toString(), 'dog', 'unexpected for >> each result'); >> > + } >> > + >> > + >> > + } >> > +} >> > diff --git >> a/frameworks/projects/Language/src/main/royale/LanguageClasses.as >> b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/checkArrayLikeFunc.as >> > similarity index 66% >> > copy from >> frameworks/projects/Language/src/main/royale/LanguageClasses.as >> > copy to >> manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/checkArrayLikeFunc.as >> > index 2d4388e..11ae093 100644 >> > --- a/frameworks/projects/Language/src/main/royale/LanguageClasses.as >> > +++ >> b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/checkArrayLikeFunc.as >> > @@ -16,26 +16,14 @@ >> > // limitations under the License. >> > // >> > >> //////////////////////////////////////////////////////////////////////////////// >> > -package { >> > - >> > -/** >> > - * @private >> > - * This class is used to link additional classes into Language.swc >> > - * beyond those that are found by dependency analysis starting >> > - * from the classes specified in manifest.xml. >> > - */ >> > -internal class LanguageClasses >> > +package flexUnitTests.language.support >> > { >> > - COMPILE::JS >> > - { >> > - import org.apache.royale.utils.Language; Language; >> > - import QName; QName; >> > - import Namespace; Namespace; >> > - >> > - } >> > - import org.apache.royale.language.string.match; match; >> > - import org.apache.royale.language.string.search; search; >> > + import org.apache.royale.collections.ArrayList; >> > + >> > + public function checkArrayLikeFunc(val:ArrayList):String >> > + { >> > + val[0] = 'get and set from checkArrayLikeFunc'; >> > + return val[0] as String; >> > + // return val.getItemAt(0) as String; >> > + } >> > } >> > - >> > -} >> > - >> > >> > >> >