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 2022/10/16 04:06:22 UTC
[royale-asjs] branch develop updated: Fix for missing and/or incorrect functionality in ListCollectionView getProperty/setProperty/hasProperty. -added cross-target unit tests. -in particular, fixes non-functional bracket access index assignment in JS
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 a15bc54092 Fix for missing and/or incorrect functionality in ListCollectionView getProperty/setProperty/hasProperty. -added cross-target unit tests. -in particular, fixes non-functional bracket access index assignment in JS
a15bc54092 is described below
commit a15bc54092d7851f04a1e249a6bac85238b75e06
Author: greg-dove <gr...@gmail.com>
AuthorDate: Sun Oct 16 17:05:44 2022 +1300
Fix for missing and/or incorrect functionality in ListCollectionView getProperty/setProperty/hasProperty.
-added cross-target unit tests.
-in particular, fixes non-functional bracket access index assignment in JS
---
.../royale/mx/collections/ListCollectionView.as | 34 +++++++--------
.../flexUnitTests/mxroyale/CollectionsTest.as | 51 ++++++++++++++++++++++
2 files changed, 66 insertions(+), 19 deletions(-)
diff --git a/frameworks/projects/MXRoyaleBase/src/main/royale/mx/collections/ListCollectionView.as b/frameworks/projects/MXRoyaleBase/src/main/royale/mx/collections/ListCollectionView.as
index 4580d871e8..6b714f3c56 100644
--- a/frameworks/projects/MXRoyaleBase/src/main/royale/mx/collections/ListCollectionView.as
+++ b/frameworks/projects/MXRoyaleBase/src/main/royale/mx/collections/ListCollectionView.as
@@ -949,7 +949,7 @@ public class ListCollectionView extends Proxy implements ICollectionView, IList
if (name is QName)
name = name.localName;
- return proxy_getProperty(name as String);
+ return proxy_getProperty(name +'');
}
COMPILE::JS
override public function getProperty(name:String):*
@@ -967,19 +967,17 @@ public class ListCollectionView extends Proxy implements ICollectionView, IList
{
}
- /*
if (isNaN(n))
{
- var message:String = resourceManager.getString(
- "collections", "unknownProperty", [ name ]);
- throw new Error(message);
+ /*var message:String = resourceManager.getString(
+ "collections", "unknownProperty", [ name ]);*/ //en_US = Unknown Property: '{0}'.
+ throw new Error("Unknown Property: '"+name+"'");
}
else
{
- */
// If caller passed in a number such as 5.5, it will be floored.
return getItemAt(int(n));
- //}
+ }
}
/**
@@ -991,12 +989,12 @@ public class ListCollectionView extends Proxy implements ICollectionView, IList
{
if (name is QName)
name = name.localName;
- proxy_setProperty(name as String, value);
+ proxy_setProperty(name + '', value);
}
COMPILE::JS
override public function setProperty(name:String, value:*):void
{
- proxy_setProperty(name as String, value);
+ proxy_setProperty(name /*as String*/, value);
}
private function proxy_setProperty(name:String, value:*):void
@@ -1004,25 +1002,23 @@ public class ListCollectionView extends Proxy implements ICollectionView, IList
try
{
- var n:Number = parseInt(String(name));
+ var n:Number = parseInt(name);
}
catch(e:Error) // localName was not a number
{
}
- /*
if (isNaN(n))
{
- var message:String = resourceManager.getString(
- "collections", "unknownProperty", [ name ]);
- throw new Error(message);
+ /*var message:String = resourceManager.getString(
+ "collections", "unknownProperty", [ name ]);*/ //en_US = Unknown Property: '{0}'.
+ throw new Error("Unknown Property: '"+name+"'");
}
else
{
- */
// If caller passed in a number such as 5.5, it will be floored.
setItemAt(value, int(n));
- //}
+ }
}
/**
@@ -1038,12 +1034,12 @@ public class ListCollectionView extends Proxy implements ICollectionView, IList
if (name is QName)
name = name.localName;
- return proxy_hasProperty(name as String);
+ return proxy_hasProperty(name +'');
}
COMPILE::JS
override public function hasProperty(name:String):Boolean
{
- return proxy_hasProperty(name as String);
+ return proxy_hasProperty(name );
}
private function proxy_hasProperty(name:String):Boolean
@@ -1052,7 +1048,7 @@ public class ListCollectionView extends Proxy implements ICollectionView, IList
try
{
// If caller passed in a number such as 5.5, it will be floored.
- var n:Number = parseInt(String(name));
+ var n:Number = parseInt(name);
if (!isNaN(n))
index = int(n);
}
diff --git a/frameworks/projects/MXRoyaleBase/src/test/royale/flexUnitTests/mxroyale/CollectionsTest.as b/frameworks/projects/MXRoyaleBase/src/test/royale/flexUnitTests/mxroyale/CollectionsTest.as
index c2fd74790e..191e0de2b6 100644
--- a/frameworks/projects/MXRoyaleBase/src/test/royale/flexUnitTests/mxroyale/CollectionsTest.as
+++ b/frameworks/projects/MXRoyaleBase/src/test/royale/flexUnitTests/mxroyale/CollectionsTest.as
@@ -107,6 +107,57 @@ package flexUnitTests.mxroyale
assertEquals(testOut.toString(), expected.toString(), 'unexpected results from for-each iteration');
}
+
+ [Test]
+ public function testProxyAccess():void{
+ var obj1:Object = {'data':'Object 1'};
+ var obj2:Object = {'data':'Object 2'};
+
+ var ac:ArrayCollection = new ArrayCollection([obj1,obj2]);
+
+ assertEquals(ac[0], obj1, 'unexpected value from proxy access into ListCollectionView');
+
+ assertEquals(ac[1], obj2, 'unexpected value from proxy access into ListCollectionView');
+
+ var val:Object;
+ var err:Boolean;
+ try {
+ val = ac['fail'];
+ } catch(e:Error) {
+ err = true;
+ }
+
+ assertTrue(err, 'unexpected non-error state ListCollectionView')
+
+ }
+
+ [Test]
+ public function testProxyAssign():void{
+ var obj1:Object = {'data':'Object 1'};
+ var obj2:Object = {'data':'Object 2'};
+
+ var ac:ArrayCollection = new ArrayCollection([obj1.data,obj2.data]);
+
+ assertEquals(ac[0], obj1.data, 'unexpected value from proxy access into ListCollectionView');
+
+ assertEquals(ac[1], obj2.data, 'unexpected value from proxy access into ListCollectionView');
+
+ ac[0] = obj1;
+ ac[1] = obj2;
+
+ assertEquals(ac[0], obj1, 'unexpected value from proxy access following proxy assign in ListCollectionView');
+
+ assertEquals(ac[1], obj2, 'unexpected value from proxy access following proxy assign in ListCollectionView');
+
+ var err:Boolean;
+ try {
+ ac['fail'] = obj1;
+ } catch(e:Error) {
+ err = true;
+ }
+
+ assertTrue(err, 'unexpected non-error state ListCollectionView')
+ }
}
}