tests: Update the XML abstract equality test

This commit is contained in:
Tom Schuster 2023-04-17 18:17:38 +02:00 committed by Aaron Hill
parent 886244478e
commit 8b3491fe53
3 changed files with 20 additions and 12 deletions

View File

@ -10,8 +10,9 @@ trace("simple:", simple.toXMLString());
trace("simple == simple:", simple == simple); trace("simple == simple:", simple == simple);
trace('simple == "abc":', simple == "abc"); trace('simple == "abc":', simple == "abc");
trace("simple == simple.children()[0] [text]:", simple == simple.children()[0]); trace("simple == simple.children()[0] [text]:", simple == simple.children()[0]);
// TODO trace("simple == <a>abc</a>", simple == <a>abc</a>);
// trace("simple == <xxx>abc</xxx>", simple == <xxx>abc</xxx>); trace('simple == <a hello="world">abc</a>', simple == <a hello="world">abc</a>);
trace("simple == <xxx>abc</xxx>", simple == <xxx>abc</xxx>);
var true_XML: XML = <a>true</a>; var true_XML: XML = <a>true</a>;
trace("true_XML:", true_XML.toXMLString()); trace("true_XML:", true_XML.toXMLString());
@ -23,37 +24,34 @@ trace("attr.@hello == attr.@hello:", attr.@hello == attr.@hello);
trace('attr.@hello == "world":', attr.@hello == "world"); trace('attr.@hello == "world":', attr.@hello == "world");
trace("attr.@hello == <x>world</x>:", attr.@hello == <x>world</x>); trace("attr.@hello == <x>world</x>:", attr.@hello == <x>world</x>);
trace('attr.@hello == "foobar":', attr.@hello == "foobar"); trace('attr.@hello == "foobar":', attr.@hello == "foobar");
// TODO trace("attr.@hello == <x><y>world</y></x>:", attr.@hello == <x><y>world</y></x>);
// trace("attr.@hello == <x><y>world</y></x>:", attr.@hello == <x><y>world</y></x>);
var xml: XML = <x><a>a</a><t>true</t><n>123</n><b>b1</b><b>b2</b></x>; var xml: XML = <x><a>a</a><t>true</t><n>123</n><b>b1</b><b>b2</b></x>;
trace("xml:", xml.toXMLString()); trace("xml:", xml.toXMLString());
trace("xml == xml:", xml == xml); trace("xml == xml:", xml == xml);
var xml_a: XMLList = xml.a; var xml_a: XMLList = xml.a;
trace("xml_a == xml_a:", xml_a == xml_a); trace("xml_a == xml_a:", xml_a == xml_a);
// TODO: (xml.a creates a new list every time so not supported currently) trace("xml.a == xml.a:", xml.a == xml.a);
// trace("xml.a == xml.a:", xml.a == xml.a);
trace('xml.a == "a":', xml.a == "a"); trace('xml.a == "a":', xml.a == "a");
trace('xml.t == true:', xml.t == true); trace('xml.t == true:', xml.t == true);
trace('xml.n == 123:', xml.n == 123); trace('xml.n == 123:', xml.n == 123);
trace('xml.n == "123":', xml.n == "123"); trace('xml.n == "123":', xml.n == "123");
trace('xml.n == 42:', xml.n == 42); trace('xml.n == 42:', xml.n == 42);
// TODO trace("xml.b == xml.b:", xml.b == xml.b);
// trace("xml.b == xml.b:", xml.b == xml.b);
trace('xml.b == xml.a:', xml.b == xml.a); trace('xml.b == xml.a:', xml.b == xml.a);
var other: XML = <xxx><y>b1</y><y>b2</y></xxx>; var other: XML = <xxx><y>b1</y><y>b2</y></xxx>;
trace("other:", other.toXMLString()); trace("other:", other.toXMLString());
// TODO trace("xml.b == other.y:", xml.b == other.y);
// trace("xml.b == other.y:", xml.b == other.y);
var other2: XML = <xxx><b>b1</b><b>b2</b></xxx> var other2: XML = <xxx><b>b1</b><b>b2</b></xxx>
trace("other2:", other2.toXMLString()); trace("other2:", other2.toXMLString());
// TODO trace("xml.b == other2.b:", xml.b == other2.b)
// trace("xml.b == other2.b:", xml.b == other2.b)
var attrs: XML = <x a="b1" b="b2" />; var attrs: XML = <x a="b1" b="b2" />;
trace("attrs:", attrs.toXMLString()); trace("attrs:", attrs.toXMLString());
trace('attrs == <x a="x1" b="x2" />', attrs == <x a="x1" b="x2" />);
trace('attrs == <x b="b2" a="b1" />', attrs == <x b="b2" a="b1" />);
trace("xml.b == attrs.attributes():", xml.b == attrs.attributes()); trace("xml.b == attrs.attributes():", xml.b == attrs.attributes());
trace('xml.child("unknown") == undefined:', xml.child("unknown") == undefined); trace('xml.child("unknown") == undefined:', xml.child("unknown") == undefined);

View File

@ -2,6 +2,9 @@ simple: <a>abc</a>
simple == simple: true simple == simple: true
simple == "abc": true simple == "abc": true
simple == simple.children()[0] [text]: true simple == simple.children()[0] [text]: true
simple == <a>abc</a> true
simple == <a hello="world">abc</a> false
simple == <xxx>abc</xxx> false
true_XML: <a>true</a> true_XML: <a>true</a>
true_XML == true: true true_XML == true: true
attr: <a hello="world"/> attr: <a hello="world"/>
@ -9,18 +12,25 @@ attr.@hello == attr.@hello: true
attr.@hello == "world": true attr.@hello == "world": true
attr.@hello == <x>world</x>: true attr.@hello == <x>world</x>: true
attr.@hello == "foobar": false attr.@hello == "foobar": false
attr.@hello == <x><y>world</y></x>: false
xml: <x><a>a</a><t>true</t><n>123</n><b>b1</b><b>b2</b></x> xml: <x><a>a</a><t>true</t><n>123</n><b>b1</b><b>b2</b></x>
xml == xml: true xml == xml: true
xml_a == xml_a: true xml_a == xml_a: true
xml.a == xml.a: true
xml.a == "a": true xml.a == "a": true
xml.t == true: true xml.t == true: true
xml.n == 123: true xml.n == 123: true
xml.n == "123": true xml.n == "123": true
xml.n == 42: false xml.n == 42: false
xml.b == xml.b: true
xml.b == xml.a: false xml.b == xml.a: false
other: <xxx><y>b1</y><y>b2</y></xxx> other: <xxx><y>b1</y><y>b2</y></xxx>
xml.b == other.y: false
other2: <xxx><b>b1</b><b>b2</b></xxx> other2: <xxx><b>b1</b><b>b2</b></xxx>
xml.b == other2.b: true
attrs: <x a="b1" b="b2"/> attrs: <x a="b1" b="b2"/>
attrs == <x a="x1" b="x2" /> false
attrs == <x b="b2" a="b1" /> true
xml.b == attrs.attributes(): true xml.b == attrs.attributes(): true
xml.child("unknown") == undefined: true xml.child("unknown") == undefined: true
xml.child("unknown") == "": false xml.child("unknown") == "": false