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/24 06:55:50 UTC

[royale-asjs] branch develop updated (f445b4d -> c7c7c6d)

This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git.


    from f445b4d  jewel-listview: maybe something to consider at somepoint
     new ed645b9  Ported support for ChangeWatcher.watch (without weakReference)
     new 5f10eb7  Fix for XMLList top level function should return the original when passed an XMLList instance
     new 843ba88  Add XMLList top level 'coercion' test.
     new 6898a43  Add test for XML literal interpolation
     new 030377a  Merge branch 'develop' of https://github.com/apache/royale-asjs into develop
     new c7c7c6d  Small change in Crux to cover both default (empty string key) and named ('event') argument for Bindable tags

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/royale/crux/binding/BindabilityInfo.as  |  11 +-
 .../src/main/royale/mx/binding/BindabilityInfo.as  | 179 +++++++++++++++------
 .../main/royale/mx/binding/utils/ChangeWatcher.as  |  56 +++----
 frameworks/projects/XML/src/main/royale/XMLList.as |   4 +-
 .../XML/src/test/royale/flexUnitTests/XMLTester.as |   2 +
 .../flexUnitTests/xml/XMLListTesterGeneralTest.as  |  27 ++++
 .../royale/flexUnitTests/xml/XMLLiteralTest.as     | 127 +++++++++++++++
 7 files changed, 329 insertions(+), 77 deletions(-)
 create mode 100644 frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLLiteralTest.as


[royale-asjs] 03/06: Add XMLList top level 'coercion' test.

Posted by gr...@apache.org.
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 843ba88365692e575a096d6f9ac06d01aa171848
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Apr 24 18:18:19 2020 +1200

    Add XMLList top level 'coercion' test.
---
 .../flexUnitTests/xml/XMLListTesterGeneralTest.as  | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLListTesterGeneralTest.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLListTesterGeneralTest.as
index c9b9e6e..139dafd 100644
--- a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLListTesterGeneralTest.as
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLListTesterGeneralTest.as
@@ -216,5 +216,32 @@ package flexUnitTests.xml
             }
             assertTrue(hadError, 'expected an error');
         }
+
+
+
+        [Test]
+        public function testCoercion():void{
+            var source:XML = <data>
+                <row>
+                    <Item someattribute="item1Att">item1</Item>
+                </row>
+                <row>
+                    <Item someattribute="item2Att">item2</Item>
+                </row>
+            </data>;
+
+            var list:XMLList = XMLList(source);
+            assertEquals(list.length(), 1, 'unexpected XMLList length');
+            assertEquals(source.row.length(), 2, 'unexpected XMLList length');
+
+            assertEquals(list.row.length(), 2, 'unexpected XMLList length');
+            var alt:XMLList = XMLList(list)
+            assertEquals(alt.length(), 1, 'unexpected XMLList length');
+            assertEquals(alt.row.length(), 2, 'unexpected XMLList length');
+            assertEquals(alt, list, 'unexpected XMLList equality');
+            assertStrictlyEquals(alt, list, 'unexpected XMLList strict equality');
+            assertStrictlyEquals(alt[0], source, 'unexpected XMLList content strict equality');
+
+        }
     }
 }


[royale-asjs] 01/06: Ported support for ChangeWatcher.watch (without weakReference)

Posted by gr...@apache.org.
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 ed645b9806e82dcd43722d4640c95e41798d545f
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Apr 24 17:47:51 2020 +1200

    Ported support for ChangeWatcher.watch (without weakReference)
---
 .../src/main/royale/mx/binding/BindabilityInfo.as  | 179 +++++++++++++++------
 .../main/royale/mx/binding/utils/ChangeWatcher.as  |  56 +++----
 2 files changed, 161 insertions(+), 74 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/binding/BindabilityInfo.as b/frameworks/projects/MXRoyale/src/main/royale/mx/binding/BindabilityInfo.as
index 8500fbe..ede40bf 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/binding/BindabilityInfo.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/binding/BindabilityInfo.as
@@ -20,8 +20,22 @@
 package mx.binding
 {
 
+COMPILE::SWF{
+	import flash.utils.Dictionary;
+}
+
 import mx.events.PropertyChangeEvent;
 
+
+import org.apache.royale.events.ValueChangeEvent;
+import org.apache.royale.reflection.DefinitionWithMetaData;
+import org.apache.royale.reflection.MetaDataArgDefinition;
+import org.apache.royale.reflection.MetaDataDefinition;
+import org.apache.royale.reflection.TypeDefinition;
+import org.apache.royale.reflection.describeType;
+import org.apache.royale.reflection.utils.getMembersWithNameMatch;
+import org.apache.royale.reflection.utils.filterForMetaTags;
+
 [ExcludeClass]
 
 /**
@@ -38,7 +52,7 @@ public class BindabilityInfo
 	//  Class constants
 	//
 	//--------------------------------------------------------------------------
-	
+
 	/**
 	 *  Name of [Bindable] metadata.
 	 *  
@@ -57,7 +71,7 @@ public class BindabilityInfo
 	 *  @playerversion AIR 1.1
 	 *  @productversion Flex 3
 	 */
-	public static const MANAGED:String = "Managed";
+//	public static const MANAGED:String = "Managed";
 	
 	/**
 	 *  Name of [ChangeEvent] metadata.
@@ -67,7 +81,7 @@ public class BindabilityInfo
 	 *  @playerversion AIR 1.1
 	 *  @productversion Flex 3
 	 */
-	public static const CHANGE_EVENT:String = "ChangeEvent";
+//	public static const CHANGE_EVENT:String = "ChangeEvent";
 	
 	/**
 	 *  Name of [NonCommittingChangeEvent] metadata.
@@ -77,8 +91,8 @@ public class BindabilityInfo
 	 *  @playerversion AIR 1.1
 	 *  @productversion Flex 3
 	 */
-	public static const NON_COMMITTING_CHANGE_EVENT:String =
-		"NonCommittingChangeEvent";
+	//public static const NON_COMMITTING_CHANGE_EVENT:String =
+	//	"NonCommittingChangeEvent";
 
 	/**
 	 *  Name of describeType() <accessor> element.
@@ -100,6 +114,50 @@ public class BindabilityInfo
 	 */
 	public static const METHOD:String = "method";
 
+
+	COMPILE::SWF
+	private static const cache:Dictionary = new Dictionary();
+
+	COMPILE::JS
+	private static const cache:Map = new Map()
+
+	//--------------------------------------------------------------------------
+	//
+	//  Static methods
+	//
+	//--------------------------------------------------------------------------
+
+	public static function getCachedInfo(forTarget:Object):BindabilityInfo{
+		var typeDef:TypeDefinition = describeType(forTarget);
+		var info:BindabilityInfo = getFromCache(typeDef);
+		if (!info) {
+			info = new BindabilityInfo(typeDef, true);
+		}
+		return info;
+	}
+
+	private static function getFromCache(typeDef:TypeDefinition):BindabilityInfo{
+		var info:BindabilityInfo;
+		COMPILE::SWF{
+			info = cache[typeDef.getClass()]
+		}
+		COMPILE::JS{
+			info = cache.get(typeDef.getClass())
+		}
+		return info;
+	}
+
+	private static function storeInCache(info:BindabilityInfo):void{
+		var typeDef:TypeDefinition = info.typeDefinition;
+		COMPILE::SWF{
+			cache[typeDef.getClass()] = info;
+		}
+		COMPILE::JS{
+			cache.set(typeDef.getClass(), info);
+		}
+	}
+
+
 	//--------------------------------------------------------------------------
 	//
 	//  Constructor
@@ -114,11 +172,14 @@ public class BindabilityInfo
 	 *  @playerversion AIR 1.1
 	 *  @productversion Flex 3
 	 */
-	public function BindabilityInfo(typeDescription:XML)
+	public function BindabilityInfo(typeDefinition:TypeDefinition, cache:Boolean=false)
 	{
 		super();
 
-		this.typeDescription = typeDescription;
+		this.typeDefinition = typeDefinition;
+		if (cache) {
+			storeInCache(this);
+		}
 	}
 
 	//--------------------------------------------------------------------------
@@ -130,7 +191,7 @@ public class BindabilityInfo
 	/**
 	 *  @private
 	 */
-	private var typeDescription:XML;
+	private var typeDefinition:TypeDefinition;
 	
 	/**
 	 *  @private
@@ -168,33 +229,29 @@ public class BindabilityInfo
 			// Seed with class-level events.
 			changeEvents = copyProps(getClassChangeEvents(), {});
 
-			// Get child-specific events.
-			var childDesc:XMLList =
-				typeDescription.accessor.(@name == childName) +
-				typeDescription.method.(@name == childName);
-			
-			var numChildren:int = childDesc.length();
+			var accessorsAndMethods:Array = [];
+
+			getMembersWithNameMatch(typeDefinition.accessors, childName, accessorsAndMethods);
+			getMembersWithNameMatch(typeDefinition.methods, childName, accessorsAndMethods);
+
+			var numChildren:int = accessorsAndMethods.length;
 
 			if (numChildren == 0)
 			{
-				// we've been asked for events on an unknown property
-				if (!typeDescription.@dynamic)
-				{
-					trace("warning: no describeType entry for '" +
-						  childName + "' on non-dynamic type '" +
-						  typeDescription.@name + "'");
-				}
+				trace("warning: no describeType entry for '" +
+						childName + "' on non-dynamic type '" +
+						typeDefinition.name + "'");
 			}
 			else
 			{
 				if (numChildren > 1)
 				{
 					trace("warning: multiple describeType entries for '" +
-						  childName + "' on type '" + typeDescription.@name +
-						  "':\n" + childDesc);
+							childName + "' on type '" + typeDefinition.name +
+							"':\n" + accessorsAndMethods);
 				}
 
-				addBindabilityEvents(childDesc.metadata, changeEvents);
+				addBindabilityEvents(accessorsAndMethods, changeEvents);
 			}
 
 			childChangeEvents[childName] = changeEvents;
@@ -207,35 +264,45 @@ public class BindabilityInfo
 	 *  @private
 	 *  Build or return cached class change events object.
 	 */
+
 	private function getClassChangeEvents():Object
 	{
 		if (!classChangeEvents)
 		{
 			classChangeEvents = {};
 
-			addBindabilityEvents(typeDescription.metadata, classChangeEvents);
+			//@todo check this (currently fails in swf at runtime)
+			//addBindabilityEvents(typeDefinition.metadata, classChangeEvents);
+
 
+			//if class has Bindable metadata, assume yes ?
+			if (typeDefinition.retrieveMetaDataByName('Bindable').length) {
+				classChangeEvents[ValueChangeEvent.VALUE_CHANGE] = true;
+			}
+			// tbd, do we want this?
 			// Class-level [Managed] means all properties
-			// dispatch propertyChange.
-			if (typeDescription.metadata.(@name == MANAGED).length() > 0)
-			{
-				classChangeEvents[PropertyChangeEvent.PROPERTY_CHANGE] = true;
+			// dispatch valueChange.
+			if (typeDefinition.retrieveMetaDataByName('Managed').length) {
+				classChangeEvents[ValueChangeEvent.VALUE_CHANGE] = true;
 			}
+
 		}
 
 		return classChangeEvents;
 	}
 
+
 	/**
 	 *  @private
 	 */
-	private function addBindabilityEvents(metadata:XMLList,
+
+	private function addBindabilityEvents(members:Array,
 										  eventListObj:Object):void
 	{
-		addChangeEvents(metadata.(@name == BINDABLE), eventListObj, true);
-		addChangeEvents(metadata.(@name == CHANGE_EVENT), eventListObj, true);
-		addChangeEvents(metadata.(@name == NON_COMMITTING_CHANGE_EVENT),
-						eventListObj, false);
+		var metaNames:Array = [BINDABLE];
+		var changeEvents:Array = filterForMetaTags(members, metaNames);
+
+		addChangeEvents(changeEvents, eventListObj );
 	}
 
 	/**
@@ -244,20 +311,40 @@ public class BindabilityInfo
 	 *  to an event list object.
 	 *  Note: metadata's first arg value is assumed to be change event name.
 	 */
-	private function addChangeEvents(metadata:XMLList, eventListObj:Object, isCommit:Boolean):void
+
+	private function addChangeEvents(members:Array, eventListObj:Object):void
 	{
-		for each (var md:XML in metadata)
+		for each (var md:DefinitionWithMetaData in members)
 		{
-			var arg:XMLList = md.arg;
-			if (arg.length() > 0)
-			{
-				var eventName:String = arg[0].@value;
-				eventListObj[eventName] = isCommit;
-			}
-			else
-			{
-				trace("warning: unconverted Bindable metadata in class '" +
-					  typeDescription.@name + "'");
+			var metaNames:Array = [BINDABLE];
+
+			for each(var meta:String in metaNames) {
+				var metaItems:Array = md.retrieveMetaDataByName(meta);
+				if (metaItems.length) {
+					//if there is no arg, then it is valueChange
+					for each(var metaItem:MetaDataDefinition in metaItems) {
+						if (metaItem.args.length) {
+							//check for no key
+							var eventTypeArgs:Array = metaItem.getArgsByKey('');
+							if (!eventTypeArgs.length) {
+								//check for 'event' key
+								eventTypeArgs = metaItem.getArgsByKey('event');
+							}
+							if (eventTypeArgs.length) {
+								eventListObj[MetaDataArgDefinition(eventTypeArgs[0]).value] = true;
+							}
+						} else {
+							if (meta == BINDABLE) {
+								eventListObj[ValueChangeEvent.VALUE_CHANGE] = true;
+							}
+							else {
+								trace("warning: unconverted change events metadata in class '" +
+										typeDefinition.name + "'", metaItem);
+							}
+
+						}
+					}
+				}
 			}
 		}
 	}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/binding/utils/ChangeWatcher.as b/frameworks/projects/MXRoyale/src/main/royale/mx/binding/utils/ChangeWatcher.as
index addd3aa..713af62 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/binding/utils/ChangeWatcher.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/binding/utils/ChangeWatcher.as
@@ -26,10 +26,10 @@ package mx.binding.utils
 import org.apache.royale.events.IEventDispatcher;
 import org.apache.royale.events.Event;
 
-import mx.core.EventPriority;
+//import mx.core.EventPriority;
 import mx.binding.BindabilityInfo;
 import mx.events.PropertyChangeEvent;
-// import mx.utils.DescribeTypeCache;
+import org.apache.royale.events.ValueChangeEvent;
 
 /**
  *  The ChangeWatcher class defines utility methods
@@ -140,9 +140,7 @@ public class ChangeWatcher
      *  @productversion Flex 3
      */
     public static function watch(host:Object, chain:Object,
-                                 handler:Function,
-                                 commitOnly:Boolean = false,
-                                 useWeakReference:Boolean = false):ChangeWatcher
+                                 handler:Function):ChangeWatcher
     {
         if (!(chain is Array))
             chain = [ chain ];
@@ -150,9 +148,8 @@ public class ChangeWatcher
         if (chain.length > 0)
         {
             var w:ChangeWatcher =
-                new ChangeWatcher(chain[0], handler, commitOnly,
-                    watch(null, chain.slice(1), handler, commitOnly));
-            w.useWeakReference = useWeakReference;
+                new ChangeWatcher(chain[0], handler,
+                    watch(null, chain.slice(1), handler));
             w.reset(host);
             return w;
         }
@@ -187,10 +184,9 @@ public class ChangeWatcher
      *  @playerversion AIR 1.1
      *  @productversion Flex 3
      */
-    public static function canWatch(host:Object, name:String,
-                                    commitOnly:Boolean = false):Boolean
+    public static function canWatch(host:Object, name:String):Boolean
     {
-        return !isEmpty(getEvents(host, name, commitOnly));
+        return !isEmpty(getEvents(host, name));
     }
 
     /**
@@ -213,16 +209,14 @@ public class ChangeWatcher
      *  @playerversion AIR 1.1
      *  @productversion Flex 3
      */
-    public static function getEvents(host:Object, name:String,
-                                     commitOnly:Boolean = false):Object
+    public static function getEvents(host:Object, name:String):Object
     {
         if (host is IEventDispatcher)
         {
             // Get { eventName: isCommitting, ... } for all change events
             // defined by host's class on prop <name>
-            /*var allEvents:Object = DescribeTypeCache.describeType(host).
-                                   bindabilityInfo.getChangeEvents(name);
-            if (commitOnly)
+            var allEvents:Object = BindabilityInfo.getCachedInfo(host).getChangeEvents(name);
+            /*if (commitOnly)
             {
                 // Filter out non-committing events.
                 var commitOnlyEvents:Object = {};
@@ -234,7 +228,9 @@ public class ChangeWatcher
             else
             {
                 return allEvents;
-            }*/return {};
+            }return {};*/
+
+            return allEvents;
         }
         else
         {
@@ -285,7 +281,6 @@ public class ChangeWatcher
      *  @productversion Flex 3
      */
     public function ChangeWatcher(access:Object, handler:Function,
-                                  commitOnly:Boolean = false,
                                   next:ChangeWatcher = null)
     {
         super();
@@ -294,10 +289,10 @@ public class ChangeWatcher
         name = access is String ? access as String : access.name;
         getter = access is String ? null : access.getter;
         this.handler = handler;
-        this.commitOnly = commitOnly;
+   //     this.commitOnly = commitOnly;
         this.next = next;
         events = {};
-        useWeakReference = false;
+     //   useWeakReference = false;
         isExecuting = false;
     }
 
@@ -361,7 +356,7 @@ public class ChangeWatcher
      *  @playerversion AIR 1.1
      *  @productversion Flex 3
      */
-    private var commitOnly:Boolean;
+  //  private var commitOnly:Boolean;
 
     /**
      *  If watching a chain, this is a watcher on the next property
@@ -418,7 +413,7 @@ public class ChangeWatcher
      * 
      *  @royalesuppresspublicvarwarning
      */
-    public var useWeakReference:Boolean;
+   // public var useWeakReference:Boolean;
 
     //--------------------------------------------------------------------------
     //
@@ -527,18 +522,18 @@ public class ChangeWatcher
             {
                 host.removeEventListener(p, wrapHandler);
             }
-            events = {};
+            if (newHost == null) events = {};
         }
 
         host = newHost;
 
         if (host != null)
         {
-            events = getEvents(host, name, commitOnly);
+            events = getEvents(host, name);
             for (p in events)
             {
-                host.addEventListener(p, wrapHandler, false,
-                    EventPriority.BINDING, useWeakReference);
+                host.addEventListener(p, wrapHandler, false/*,
+                    EventPriority.BINDING, useWeakReference*/);
             }
         }
 
@@ -561,6 +556,7 @@ public class ChangeWatcher
      *  @private
      *  Listener for change events.
      *  Resets chained watchers and calls user-supplied handler.
+     *
      */
     private function wrapHandler(event:Event):void
     {
@@ -573,10 +569,14 @@ public class ChangeWatcher
                 if (next)
                     next.reset(getHostPropertyValue());
 
-                if (event is PropertyChangeEvent)
+                if (event is ValueChangeEvent){
+                    if ((event as ValueChangeEvent).propertyName == name)
+                        handler(event);
+                }
+                else if (event is PropertyChangeEvent)
                 {
                     if ((event as PropertyChangeEvent).property == name)
-                        handler(event as PropertyChangeEvent);
+                        handler(event);
                 }
                 else
                 {


[royale-asjs] 02/06: Fix for XMLList top level function should return the original when passed an XMLList instance

Posted by gr...@apache.org.
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 5f10eb72c26b288cbcaeaa5db2e9f1cd184d83f4
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Apr 24 17:49:34 2020 +1200

    Fix for XMLList top level function should return the original when passed an XMLList instance
---
 frameworks/projects/XML/src/main/royale/XMLList.as | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/XML/src/main/royale/XMLList.as b/frameworks/projects/XML/src/main/royale/XMLList.as
index b2f9206..ea88105 100644
--- a/frameworks/projects/XML/src/main/royale/XMLList.as
+++ b/frameworks/projects/XML/src/main/royale/XMLList.as
@@ -34,9 +34,11 @@ package
 		 *  mimics the top-level XMLList function (supports 'this' correctly)
 		 *
 		 *  @royalesuppressexport
+		 *  @royaleignorecoercion XMLList
 		 */
 		public static function conversion(val:* = null):XMLList{
-			return new XMLList(val);
+			if (val && val.constructor == XMLList) return val as XMLList;
+			else return new XMLList(val);
 		}
 		
 		public function XMLList(expression:Object = null)


[royale-asjs] 06/06: Small change in Crux to cover both default (empty string key) and named ('event') argument for Bindable tags

Posted by gr...@apache.org.
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 c7c7c6df965682bfa1fc087566104cd4b491e5a8
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Apr 24 18:26:11 2020 +1200

    Small change in Crux to cover both default (empty string key) and named ('event') argument for Bindable tags
---
 .../royale/org/apache/royale/crux/binding/BindabilityInfo.as  | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/binding/BindabilityInfo.as b/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/binding/BindabilityInfo.as
index f66319b..43cf71e 100644
--- a/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/binding/BindabilityInfo.as
+++ b/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/binding/BindabilityInfo.as
@@ -218,8 +218,15 @@ public class BindabilityInfo
 					//if there is no arg, then it is valueChange
 					for each(var metaItem:MetaDataDefinition in metaItems) {
 						if (metaItem.args.length) {
-							//assume first arg is the eventName
-							eventListObj[MetaDataArgDefinition(metaItem.args[0]).value] = true;
+							//check for no key
+							var eventTypeArgs:Array = metaItem.getArgsByKey('');
+							if (!eventTypeArgs.length) {
+								//check for 'event' key
+								eventTypeArgs = metaItem.getArgsByKey('event');
+							}
+							if (eventTypeArgs.length) {
+								eventListObj[MetaDataArgDefinition(eventTypeArgs[0]).value] = true;
+							}
 						} else {
 							if (meta == BINDABLE) {
 								eventListObj[ValueChangeEvent.VALUE_CHANGE] = true;


[royale-asjs] 04/06: Add test for XML literal interpolation

Posted by gr...@apache.org.
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 6898a43cf12c4f856fc494d4140f09a3200e70b0
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Apr 24 18:20:50 2020 +1200

    Add test for XML literal interpolation
---
 .../XML/src/test/royale/flexUnitTests/XMLTester.as |   2 +
 .../royale/flexUnitTests/xml/XMLLiteralTest.as     | 127 +++++++++++++++++++++
 2 files changed, 129 insertions(+)

diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/XMLTester.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/XMLTester.as
index 17b01f1..8fa925c 100644
--- a/frameworks/projects/XML/src/test/royale/flexUnitTests/XMLTester.as
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/XMLTester.as
@@ -49,6 +49,8 @@ package flexUnitTests
         public var xmlNamespaceQueries:XMLTesterNamespaceQueries;
 
         public var xmllistInterationTests:XMLListTesterIterationlTest;
+
+        public var xmlLiteralTest:XMLLiteralTest;
         
     }
 }
diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLLiteralTest.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLLiteralTest.as
new file mode 100644
index 0000000..c5bbd65
--- /dev/null
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLLiteralTest.as
@@ -0,0 +1,127 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.xml
+{
+    
+    
+    import org.apache.royale.test.asserts.*;
+
+    
+    /**
+     * @royalesuppresspublicvarwarning
+     */
+    public class XMLLiteralTest
+    {
+        public static var isJS:Boolean = COMPILE::JS;
+        
+
+        private var settings:Object;
+
+        
+        [Before]
+        public function setUp():void
+        {
+            settings = XML.settings();
+        }
+        
+        [After]
+        public function tearDown():void
+        {
+            XML.setSettings(settings);
+        }
+        
+        [BeforeClass]
+        public static function setUpBeforeClass():void
+        {
+
+        }
+        
+        [AfterClass]
+        public static function tearDownAfterClass():void
+        {
+
+        }
+        
+        
+        [Test]
+        public function testSimpleLiteral():void
+        {
+            var xml1:XML = <foo baz="true"/>;
+
+            assertEquals( xml1.toXMLString(),'<foo baz="true"/>', 'unexpected result from simple XML literal roundtripping');
+        }
+        
+       
+        
+        
+        [Test]
+        public function testLocalVarInsertion():void
+        {
+            var test:String='testVal';
+
+            var xml1:XML =  <foo baz="true">
+                                <testVar>{test}</testVar>
+                            </foo>;
+            
+            assertEquals( xml1.testVar.toString() , "testVal", 'toString value should be "testVal" ');
+            
+        }
+
+        [Test]
+        public function testComplexInsertion():void
+        {
+            var contentSource:ExternalSource = new ExternalSource();
+
+            var xml:XML = <outer xmlns='http://something' other="test" strange='"test"' another="'test'">
+                <inner>
+                    <something>anything</something>
+                    <contentString att='someAttributeVal'>{contentSource.stringVal + ' with appended literal string'}</contentString>
+                    <contentBoolVal att='someAttributeVal'>{String(contentSource.boolVal)}</contentBoolVal>
+                    <contentNumVal att='someAttributeVal'>{contentSource.numVal}</contentNumVal>
+                    <someExternalStaticValue att='someAttributeVal'>{ExternalSource.getAValue()}</someExternalStaticValue>
+                </inner>
+            </outer>;
+
+            assertEquals( xml.toXMLString() , '<outer other="test" strange="&quot;test&quot;" another="\'test\'" xmlns="http://something">\n' +
+                    '  <inner>\n' +
+                    '    <something>anything</something>\n' +
+                    '    <contentString att="someAttributeVal">stringVal with appended literal string</contentString>\n' +
+                    '    <contentBoolVal att="someAttributeVal">true</contentBoolVal>\n' +
+                    '    <contentNumVal att="someAttributeVal">10</contentNumVal>\n' +
+                    '    <someExternalStaticValue att="someAttributeVal">ExternalSource.gotValue</someExternalStaticValue>\n' +
+                    '  </inner>\n' +
+                    '</outer>', 'unexpected result from XML literal complex insertion at construction');
+
+        }
+    }
+}
+
+class ExternalSource{
+
+    public static function getAValue():String{
+        return 'ExternalSource.gotValue';
+    }
+
+    public var stringVal:String = 'stringVal';
+    public function get boolVal():Boolean{
+        return true;
+    }
+
+    public var numVal:Number = 10;
+}


[royale-asjs] 05/06: Merge branch 'develop' of https://github.com/apache/royale-asjs into develop

Posted by gr...@apache.org.
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 030377a16aef3c92198ae7a6904b871717cac627
Merge: 6898a43 f445b4d
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Apr 24 18:22:38 2020 +1200

    Merge branch 'develop' of https://github.com/apache/royale-asjs into develop

 .../jewel/beads/controllers/ComboBoxController.as   | 14 +++++++++++++-
 .../ListSingleSelectionMouseController.as           | 21 +++++++++++----------
 .../org/apache/royale/jewel/beads/views/ListView.as | 11 +++++++++++
 3 files changed, 35 insertions(+), 11 deletions(-)