Skip to content

Commit

Permalink
tests: Improve the test for XML.namespace()
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpie committed Jun 6, 2024
1 parent c1ace7e commit 26f4126
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 6 deletions.
28 changes: 23 additions & 5 deletions tests/tests/swfs/avm2/xml_namespace/Test.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@ package {
public class Test extends Sprite { }
}

var xml = <foo>bar</foo>;
trace("xml.namespace(): " + xml.namespace());
testXML(<root />);
testXML(<root xmlns="http://example.org" />);
testXML(<root xmlns:other="http://other.com" />);
testXML(<root xmlns:other="http://other.com" xmlns="http://example.org" />);

var ns = xml.namespace();
trace("ns.prefix: " + ns.prefix);
trace("ns.uri: " + ns.uri);
function testXML(xml: XML) {
trace(xml.toXMLString());
trace("// namespace()");
dumpNS(xml.namespace());
trace('// namespace("")');
dumpNS(xml.namespace(""));
trace('// namespace("other")');
dumpNS(xml.namespace("other"));
trace("");
}

function dumpNS(ns: Namespace) {
if (ns) {
trace("ns.prefix: " + ns.prefix);
trace("ns.uri: " + ns.uri);
} else {
trace("ns is null");
}
}
39 changes: 38 additions & 1 deletion tests/tests/swfs/avm2/xml_namespace/output.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
xml.namespace():
<root/>
// namespace()
ns.prefix:
ns.uri:
// namespace("")
ns is null
// namespace("other")
ns is null

<root xmlns="http://example.org"/>
// namespace()
ns.prefix:
ns.uri: http://example.org
// namespace("")
ns.prefix:
ns.uri: http://example.org
// namespace("other")
ns is null

<root xmlns:other="http://other.com"/>
// namespace()
ns.prefix:
ns.uri:
// namespace("")
ns is null
// namespace("other")
ns.prefix: other
ns.uri: http://other.com

<root xmlns:other="http://other.com" xmlns="http://example.org"/>
// namespace()
ns.prefix:
ns.uri: http://example.org
// namespace("")
ns.prefix:
ns.uri: http://example.org
// namespace("other")
ns.prefix: other
ns.uri: http://other.com

Binary file modified tests/tests/swfs/avm2/xml_namespace/test.swf
Binary file not shown.

0 comments on commit 26f4126

Please sign in to comment.