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 2019/08/12 06:16:12 UTC
[royale-asjs] branch develop updated: Restoring XML to passing
tests (removed [Ignore]s). Fixes #93. Added new tests for children() length
tests under various combinations of parsing flags
(ignoreComments/whitespace/processing instructions).
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 87721bc Restoring XML to passing tests (removed [Ignore]s). Fixes #93. Added new tests for children() length tests under various combinations of parsing flags (ignoreComments/whitespace/processing instructions).
87721bc is described below
commit 87721bcf2c0a991ee24ab33d63ab08ab291dfd7c
Author: greg-dove <gr...@gmail.com>
AuthorDate: Mon Aug 12 18:14:33 2019 +1200
Restoring XML to passing tests (removed [Ignore]s). Fixes #93. Added new tests for children() length tests under various combinations of parsing flags (ignoreComments/whitespace/processing instructions).
---
frameworks/projects/XML/src/main/royale/XML.as | 19 +--
.../flexUnitTests/xml/XMLTesterGeneralTest.as | 185 ++++++++++-----------
.../flexUnitTests/xml/XMLTesterGeneralTest.as | 174 +++++++++----------
3 files changed, 187 insertions(+), 191 deletions(-)
diff --git a/frameworks/projects/XML/src/main/royale/XML.as b/frameworks/projects/XML/src/main/royale/XML.as
index 65e466d..844d7d2 100644
--- a/frameworks/projects/XML/src/main/royale/XML.as
+++ b/frameworks/projects/XML/src/main/royale/XML.as
@@ -20,7 +20,7 @@ package
{
COMPILE::JS
/**
- * @royaleignorepublicvarwarning
+ * @royalesuppresspublicvarwarning
*/
public class XML
{
@@ -228,7 +228,9 @@ package
for(i=0;i<len;i++)
{
var nativeNode:Node = childNodes[i];
- if (nativeNode.nodeType == 7 && XML.ignoreProcessingInstructions) {
+ const nodeType:Number = nativeNode.nodeType;
+ if ((nodeType == 7 && XML.ignoreProcessingInstructions) ||
+ (nodeType == 8 && XML.ignoreComments)) {
continue;
}
var child:XML = fromNode(nativeNode);
@@ -625,13 +627,7 @@ package
child.setParent(this);
if(child.nodeKind() =="attribute")
getAttributes().push(child);
- else if (child.nodeKind() == "comment" && XML.ignoreComments)
- {
- // don't add child
- }
- else
- getChildren().push(child);
-
+ else getChildren().push(child);
}
private function getChildren():Array
@@ -730,7 +726,7 @@ package
var childType:String = typeof child;
if(childType != "object") {
- var last:uint = childrenLength();
+ const last:uint = childrenLength();
const lastChild:XML = last ? _children[last-1] : null;
if (lastChild && lastChild.nodeKind() == 'element') {
@@ -903,8 +899,7 @@ package
var len:int = childrenLength();
for(i=0;i<len;i++)
{
- if(_children[i].nodeKind() == "element")
- list.append(_children[i]);
+ list.append(_children[i]);
}
list.targetObject = this;
diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
index 48bbd99..05ca072 100644
--- a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
@@ -157,7 +157,6 @@ package flexUnitTests.xml
- [Ignore]
[Test]
public function testSimpleXMLList():void
{
@@ -571,8 +570,7 @@ package flexUnitTests.xml
assertTrue( caughtError, 'Unexpected Error state with duplicate attribute declarations');
}
-
- [Ignore]
+
[Test]
public function testParsingWhitespaceSetting1():void{
var originalSetting:Boolean = XML.ignoreWhitespace;
@@ -694,8 +692,7 @@ package flexUnitTests.xml
XML.ignoreWhitespace = original;
XML.ignoreComments = originalComments;
}
-
- [Ignore]
+
[Test]
public function testIgnoreComments():void{
var original:Boolean = XML.ignoreWhitespace;
@@ -719,98 +716,12 @@ package flexUnitTests.xml
XML.ignoreWhitespace = original;
XML.ignoreComments = originalComments;
}
-
- [Ignore]
+
[Test]
[TestVariance(variance="JS",description="Some browsers can parse to a different order of attributes and namespace declarations (which affects stringified content comparisons)")]
public function testLargeComplex():void{
var xmlString:String = xml.toXMLString();
-
- /*var expected:String = '<catalog xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:dac="com.printui.view.components.DesignAreaComponents.*">\n' +
- ' bla bla\n' +
- ' <product description="Cardigan Sweater" product_image="cardigan.jpg">\n' +
- ' <fx:catalog_item gender="Men\'s" fx:foo="bah">\n' +
- ' <item_number>QWZ5671</item_number>\n' +
- ' <price>39.95</price>\n' +
- ' <size description="Medium">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Large">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' </fx:catalog_item>\n' +
- ' <script><![CDATA[private function onStylesLoaded(ev:Event):void {currentState = "normal";facade = ApplicationFacade.getInstance();facade.notifyObservers(new Notification(ApplicationFacade.CMD_STARTUP, this));} ]]></script>\n' +
- ' <catalog_item gender="Women\'s">\n' +
- ' <item_number>RRX9856</item_number>\n' +
- ' <price>42.50</price>\n' +
- ' <size description="Small">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Medium">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Large">\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Extra Large">\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' </catalog_item>\n' +
- ' </product>\n' +
- '</catalog>';
-
- var alternate:String = '<catalog xmlns:dac="com.printui.view.components.DesignAreaComponents.*" xmlns:fx="http://ns.adobe.com/mxml/2009">\n' +
- ' bla bla\n' +
- ' <product product_image="cardigan.jpg" description="Cardigan Sweater">\n' +
- ' <fx:catalog_item fx:foo="bah" gender="Men\'s">\n' +
- ' <item_number>QWZ5671</item_number>\n' +
- ' <price>39.95</price>\n' +
- ' <size description="Medium">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Large">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' </fx:catalog_item>\n' +
- ' <script><![CDATA[private function onStylesLoaded(ev:Event):void {currentState = "normal";facade = ApplicationFacade.getInstance();facade.notifyObservers(new Notification(ApplicationFacade.CMD_STARTUP, this));} ]]></script>\n' +
- ' <catalog_item gender="Women\'s">\n' +
- ' <item_number>RRX9856</item_number>\n' +
- ' <price>42.50</price>\n' +
- ' <size description="Small">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Medium">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Large">\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Extra Large">\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' </catalog_item>\n' +
- ' </product>\n' +
- '</catalog>';*/
-
- //RoyaleUnitTestRunner.consoleOut('testLargeComplex is alternate:\n' + (xmlString == alternate));
+
//IE and MS Edge: inlcude alternate output check
//account for variation in output order of attributes and namespace declarations (from native DOMParser)
@@ -1081,5 +992,93 @@ package flexUnitTests.xml
assertTrue( localXml == sizes[0], 'XML content was unexpected');
}
+
+ [Test]
+ public function testChildren():void{
+ XML.setSettings(XML.defaultSettings());
+ var xml:XML = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ assertEquals(xml.children().length(),3 , 'unexpected default parsing children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' <test/>\n' +
+ ' Something\n' +
+ ' surrounded With Whitespace\n' +
+ '</root>' , 'unexpected default parsing string output');
+
+ XML.ignoreComments = false;
+ xml = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ assertEquals(xml.children().length(),4 , 'unexpected parsing with ignoreComments = false children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' <test/>\n' +
+ ' Something\n' +
+ ' <!-- comment -->\n' +
+ ' surrounded With Whitespace\n' +
+ '</root>' , 'unexpected parsing with ignoreComments = false string output');
+ XML.ignoreProcessingInstructions= false;
+ xml = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ assertEquals(xml.children().length(),5 , 'unexpected parsing with ignoreComments = false and ignoreProcessingInstructions= false children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' <test/>\n' +
+ ' <?foo bar?>\n' +
+ ' Something\n' +
+ ' <!-- comment -->\n' +
+ ' surrounded With Whitespace\n' +
+ '</root>' , 'unexpected parsing with ignoreComments = false and ignoreProcessingInstructions= false string output');
+ XML.ignoreWhitespace= false;
+ xml = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ assertEquals(xml.children().length(),6 , 'unexpected parsing with ignoreComments = false and ignoreProcessingInstructions= false and ignoreWhitespace= false children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' \n' +
+ ' <test/>\n' +
+ ' <?foo bar?>\n' +
+ ' Something\n' +
+ ' <!-- comment -->\n' +
+ ' surrounded With Whitespace\n' +
+ '</root>' , 'unexpected parsing with ignoreComments = false and ignoreProcessingInstructions= false and ignoreWhitespace= false string output');
+
+ //try something different
+
+ XML.ignoreComments = true;
+ xml = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ //because ignoreComments is true, the following is parsed as an empty test node:
+ xml.appendChild(<!-- appended comment -->);
+ assertEquals(xml.children().length(),6 , 'unexpected parsing with ignoreComments = true and ignoreProcessingInstructions= false and ignoreWhitespace= false and appending comment... children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' \n' +
+ ' <test/>\n' +
+ ' <?foo bar?>\n' +
+ ' Something\n' +
+ ' surrounded With Whitespace\n' +
+ ' \n' +
+ '</root>' , 'unexpected parsing with ignoreComments = true and ignoreProcessingInstructions= false and ignoreWhitespace= false and appending comment... string output');
+
+ XML.ignoreComments = false;
+ var comment:XML = <xml><!-- appended comment --></xml>;
+ comment = comment.comments()[0];
+ assertEquals(comment.toXMLString(),'<!-- appended comment -->', 'unexpected toXMLString for comment');
+ XML.ignoreComments = true;
+ xml = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ //because ignoreComments is true, the following is parsed as an empty test node:
+ xml.appendChild(comment);
+
+ assertEquals(xml.children().length(),6 , 'unexpected parsing with ignoreComments = true and ignoreProcessingInstructions= false and ignoreWhitespace= false and appending comment... children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' \n' +
+ ' <test/>\n' +
+ ' <?foo bar?>\n' +
+ ' Something\n' +
+ ' surrounded With Whitespace\n' +
+ ' <!-- appended comment -->\n' +
+ '</root>' , 'unexpected parsing with ignoreComments = true and ignoreProcessingInstructions= false and ignoreWhitespace= false and appending comment... string output');
+
+
+
+ XML.setSettings(XML.defaultSettings());
+ }
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/xml/XMLTesterGeneralTest.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
index db92479..3863af6 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
@@ -722,93 +722,7 @@ package flexUnitTests.xml
[TestVariance(variance="JS",description="Some browsers can parse to a different order of attributes and namespace declarations (which affects stringified content comparisons)")]
public function testLargeComplex():void{
var xmlString:String = xml.toXMLString();
-
- /*var expected:String = '<catalog xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:dac="com.printui.view.components.DesignAreaComponents.*">\n' +
- ' bla bla\n' +
- ' <product description="Cardigan Sweater" product_image="cardigan.jpg">\n' +
- ' <fx:catalog_item gender="Men\'s" fx:foo="bah">\n' +
- ' <item_number>QWZ5671</item_number>\n' +
- ' <price>39.95</price>\n' +
- ' <size description="Medium">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Large">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' </fx:catalog_item>\n' +
- ' <script><![CDATA[private function onStylesLoaded(ev:Event):void {currentState = "normal";facade = ApplicationFacade.getInstance();facade.notifyObservers(new Notification(ApplicationFacade.CMD_STARTUP, this));} ]]></script>\n' +
- ' <catalog_item gender="Women\'s">\n' +
- ' <item_number>RRX9856</item_number>\n' +
- ' <price>42.50</price>\n' +
- ' <size description="Small">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Medium">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Large">\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Extra Large">\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' </catalog_item>\n' +
- ' </product>\n' +
- '</catalog>';
-
- var alternate:String = '<catalog xmlns:dac="com.printui.view.components.DesignAreaComponents.*" xmlns:fx="http://ns.adobe.com/mxml/2009">\n' +
- ' bla bla\n' +
- ' <product product_image="cardigan.jpg" description="Cardigan Sweater">\n' +
- ' <fx:catalog_item fx:foo="bah" gender="Men\'s">\n' +
- ' <item_number>QWZ5671</item_number>\n' +
- ' <price>39.95</price>\n' +
- ' <size description="Medium">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Large">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' </fx:catalog_item>\n' +
- ' <script><![CDATA[private function onStylesLoaded(ev:Event):void {currentState = "normal";facade = ApplicationFacade.getInstance();facade.notifyObservers(new Notification(ApplicationFacade.CMD_STARTUP, this));} ]]></script>\n' +
- ' <catalog_item gender="Women\'s">\n' +
- ' <item_number>RRX9856</item_number>\n' +
- ' <price>42.50</price>\n' +
- ' <size description="Small">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Medium">\n' +
- ' <color_swatch image="red_cardigan.jpg">Red</color_swatch>\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Large">\n' +
- ' <color_swatch image="navy_cardigan.jpg">Navy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' <size description="Extra Large">\n' +
- ' <color_swatch image="burgundy_cardigan.jpg">Burgundy</color_swatch>\n' +
- ' <color_swatch image="black_cardigan.jpg">Black</color_swatch>\n' +
- ' </size>\n' +
- ' </catalog_item>\n' +
- ' </product>\n' +
- '</catalog>';*/
- //RoyaleUnitTestRunner.consoleOut('testLargeComplex is alternate:\n' + (xmlString == alternate));
-
//IE and MS Edge: inlcude alternate output check
//account for variation in output order of attributes and namespace declarations (from native DOMParser)
assertTrue( xmlString.length == 2060, 'unexpected complex stringify results');
@@ -1078,5 +992,93 @@ package flexUnitTests.xml
assertTrue( localXml == sizes[0], 'XML content was unexpected');
}
+
+ [Test]
+ public function testChildren():void{
+ XML.setSettings(XML.defaultSettings());
+ var xml:XML = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ assertEquals(xml.children().length(),3 , 'unexpected default parsing children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' <test/>\n' +
+ ' Something\n' +
+ ' surrounded With Whitespace\n' +
+ '</root>' , 'unexpected default parsing string output');
+
+ XML.ignoreComments = false;
+ xml = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ assertEquals(xml.children().length(),4 , 'unexpected parsing with ignoreComments = false children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' <test/>\n' +
+ ' Something\n' +
+ ' <!-- comment -->\n' +
+ ' surrounded With Whitespace\n' +
+ '</root>' , 'unexpected parsing with ignoreComments = false string output');
+ XML.ignoreProcessingInstructions= false;
+ xml = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ assertEquals(xml.children().length(),5 , 'unexpected parsing with ignoreComments = false and ignoreProcessingInstructions= false children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' <test/>\n' +
+ ' <?foo bar?>\n' +
+ ' Something\n' +
+ ' <!-- comment -->\n' +
+ ' surrounded With Whitespace\n' +
+ '</root>' , 'unexpected parsing with ignoreComments = false and ignoreProcessingInstructions= false string output');
+ XML.ignoreWhitespace= false;
+ xml = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ assertEquals(xml.children().length(),6 , 'unexpected parsing with ignoreComments = false and ignoreProcessingInstructions= false and ignoreWhitespace= false children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' \n' +
+ ' <test/>\n' +
+ ' <?foo bar?>\n' +
+ ' Something\n' +
+ ' <!-- comment -->\n' +
+ ' surrounded With Whitespace\n' +
+ '</root>' , 'unexpected parsing with ignoreComments = false and ignoreProcessingInstructions= false and ignoreWhitespace= false string output');
+
+ //try something different
+
+ XML.ignoreComments = true;
+ xml = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ //because ignoreComments is true, the following is parsed as an empty test node:
+ xml.appendChild(<!-- appended comment -->);
+ assertEquals(xml.children().length(),6 , 'unexpected parsing with ignoreComments = true and ignoreProcessingInstructions= false and ignoreWhitespace= false and appending comment... children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' \n' +
+ ' <test/>\n' +
+ ' <?foo bar?>\n' +
+ ' Something\n' +
+ ' surrounded With Whitespace\n' +
+ ' \n' +
+ '</root>' , 'unexpected parsing with ignoreComments = true and ignoreProcessingInstructions= false and ignoreWhitespace= false and appending comment... string output');
+
+ XML.ignoreComments = false;
+ var comment:XML = <xml><!-- appended comment --></xml>;
+ comment = comment.comments()[0];
+ assertEquals(comment.toXMLString(),'<!-- appended comment -->', 'unexpected toXMLString for comment');
+ XML.ignoreComments = true;
+ xml = <root> <test/><?foo bar?>Something<!-- comment --> surrounded With Whitespace </root>;
+ //because ignoreComments is true, the following is parsed as an empty test node:
+ xml.appendChild(comment);
+
+ assertEquals(xml.children().length(),6 , 'unexpected parsing with ignoreComments = true and ignoreProcessingInstructions= false and ignoreWhitespace= false and appending comment... children length');
+ assertEquals(xml.toXMLString(),
+ '<root>\n' +
+ ' \n' +
+ ' <test/>\n' +
+ ' <?foo bar?>\n' +
+ ' Something\n' +
+ ' surrounded With Whitespace\n' +
+ ' <!-- appended comment -->\n' +
+ '</root>' , 'unexpected parsing with ignoreComments = true and ignoreProcessingInstructions= false and ignoreWhitespace= false and appending comment... string output');
+
+
+
+ XML.setSettings(XML.defaultSettings());
+ }
}
}