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 <[email protected]>
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;
+}

Reply via email to