Skip to content

Commit

Permalink
tests: Test XML.prototype.child with attributes and wildcards
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpie committed Nov 2, 2024
1 parent c7c4fd8 commit ff386d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/tests/swfs/avm2/xml_child/Test.as
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ var xml: XML = new XML("<x><foo>foo1</foo><bar>bar1</bar><foo>foo2</foo></x>")
trace('child("foo") length: ' + xml.child("foo").length());
trace('child("bar") length: ' + xml.child("bar").length());
trace('child("XXXXX") length: ' + xml.child("XXX").length());
trace('child("*") length: ' + xml.child("*").length());

for each (var child in xml.child("foo")) {
trace('child("foo") toString: ' + child.toString());
}
for each (var child in xml.child("bar")) {
trace('child("bar") toString: ' + child.toString());
}
for each (var child in xml.child("*")) {
trace('child("*") toString: ' + child.toString());
}

var nested: XML = new XML("<x><a b='c'><b>bbb</b></a></x>")
trace('child("a").length: ' + nested.child("a").length());
Expand Down Expand Up @@ -45,3 +49,9 @@ trace('xml_list.child("unknown").length():', xml_list.child("unknown").length())
trace('xml_list.child("b"):', xml_list.child("b"));
trace('xml_list.child("c"):', xml_list.child("c"));
trace('xml_list.child("unknown"):', xml_list.child("unknown"));

var attrs: XML = <xml hello="world" foo="bar" />;
trace('attrs.child("@unknown"):', attrs.child("@unknown"))
trace('attrs.child("@hello"):', attrs.child("@hello"))
trace('attrs.child("@foo"):', attrs.child("@foo"))
trace('attrs.child("@*"):', attrs.child("@*"))
8 changes: 8 additions & 0 deletions tests/tests/swfs/avm2/xml_child/output.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
child("foo") length: 2
child("bar") length: 1
child("XXXXX") length: 0
child("*") length: 3
child("foo") toString: foo1
child("foo") toString: foo2
child("bar") toString: bar1
child("*") toString: foo1
child("*") toString: bar1
child("*") toString: foo2
child("a").length: 1
child("b").length: 0
child("a").@b: c
Expand All @@ -15,3 +19,7 @@ xml_list.child("b"): <b>a1-b1</b>
<b>a2-b</b>
xml_list.child("c"): a2-c
xml_list.child("unknown"):
attrs.child("@unknown"):
attrs.child("@hello"): world
attrs.child("@foo"): bar
attrs.child("@*"): worldbar
Binary file modified tests/tests/swfs/avm2/xml_child/test.swf
Binary file not shown.

0 comments on commit ff386d8

Please sign in to comment.