tests: Port avmplus e4x Expression tests

This commit is contained in:
Nathan Adams 2023-07-27 12:54:58 +02:00
parent 4f315ef6a9
commit 28dfcab8ff
85 changed files with 5193 additions and 0 deletions

View File

@ -0,0 +1,245 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
import com.adobe.test.Utils;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.1.1 - Attribute Identifiers");
x1 =
<alpha>
<bravo attr1="value1" ns:attr1="value3" xmlns:ns="http://someuri">
<charlie attr1="value2" ns:attr1="value4"/>
</bravo>
</alpha>
TEST_XML(1, "value1", x1.bravo.@attr1);
TEST_XML(2, "value2", x1.bravo.charlie.@attr1);
correct = new XMLList();
correct += new XML("value1");
correct += new XML("value2");
TEST(3, correct, x1..@attr1);
n = new Namespace("http://someuri");
TEST_XML(4, "value3", x1.bravo.@n::attr1);
TEST_XML(5, "value4", x1.bravo.charlie.@n::attr1);
correct = new XMLList();
correct += new XML("value3");
correct += new XML("value4");
TEST(6, correct, x1..@n::attr1);
q = new QName("attr1");
q2 = new QName(q, "attr1");
TEST(7.3, "attr1", q.toString());
TEST(7.4, "attr1", q2.toString());
q = new QName(n, "attr1");
q2 = new QName(q, "attr1");
TEST(7, correct, x1..@[q]);
TEST(7.1, "http://someuri::attr1", q.toString());
TEST(7.2, "http://someuri::attr1", q2.toString());
correct = new XMLList();
correct += new XML("value1");
correct += new XML("value3");
correct += new XML("value2");
correct += new XML("value4");
TEST(8, correct, x1..@*::attr1);
TEST_XML(9, "value1", x1.bravo.@["attr1"]);
TEST_XML(10, "value3", x1.bravo.@n::["attr1"]);
TEST_XML(11, "value3", x1.bravo.@[q]);
TEST_XML(12, "value3", x1.bravo.@[q2]);
y = <ns:attr1 xmlns:ns="http://someuri"/>
q3 = y.name();
Assert.expectEq("q3 = y.name()", "http://someuri::attr1", q3.toString());
Assert.expectEq("x1.bravo.@[q3]", "|"+new XML("value3")+"|", "|"+x1.bravo.@[q3]+"|");
var xml1 = "<c><color c='1'>pink</color><color c='2'>purple</color><color c='3'>orange</color></c>";
var xml2 = "<animals><a a='dog'>Spot</a><a a='fish'>Marcel</a><a a='giraffe'>Virginia</a></animals>";
var xml3 = "<flowers><flower type='tulip' attr-with-hyphen='got it'><color>yellow</color></flower></flowers>";
var xml4 = "<ns1:a xmlns:ns1=\"http://yo-raps.tv\"><ns1:b attr=\"something\">rainbow</ns1:b></ns1:a>";
try {
var xml5 = <x><myTag myAttrib="has an apostrophe' in it"/></x>;
var res = "no exception";
Assert.expectEq("Attribute with apostrophe in it", "has an apostrophe' in it", xml5.myTag.@myAttrib.toString());
} catch (e1) {
var res = "exception";
} finally {
// Needs to be fixed when bug 133471 is fixed
Assert.expectEq("Attribute with apostrophe in it", "no exception", res);
}
var placeHolder = "c";
var ns1 = new Namespace('yo', 'http://yo-raps.tv');
var ns2 = new Namespace('mo', 'http://maureen.name');
Assert.expectEq("x1.node1[i].@attr", "1",
( x1 = new XML(xml1), x1.color[0].@c.toString()));
Assert.expectEq("x1.node1[i].@attr = \"new value\"", "5",
( x1 = new XML(xml1), x1.color[0].@c = "5", x1.color[0].@c.toString()));
Assert.expectEq("x1.node1[i].@[placeHolder]", "1",
( x1 = new XML(xml1), x1.color[0].@[placeHolder].toString()));
Assert.expectEq("x1.node1[i].@[placeHolder] = \"new value\"", "5",
( x1 = new XML(xml1), x1.color[0].@[placeHolder] = "5", x1.color[0].@[placeHolder].toString()));
Assert.expectEq("x1.node1[i].@attr", "giraffe",
( x1 = new XML(xml2), x1.a[2].@a.toString()));
Assert.expectEq("x1.node1[i].@attr = \"new value\"", "hippopotamus",
( x1 = new XML(xml2), x1.a[2].@a = "hippopotamus", x1.a[2].@a.toString()));
Assert.expectEq("x1.node1.@[attr-with-hyphen]", "got it",
( x1 = new XML(xml3), x1.flower.@["attr-with-hyphen"].toString()));
Assert.expectEq("x1.node1.@[attr-with-hyphen] = \"new value\"", "still got it",
( x1 = new XML(xml3), x1.flower.@["attr-with-hyphen"] = "still got it", x1.flower.@["attr-with-hyphen"].toString()));
Assert.expectEq("x1.namespace1::node1.@attr", "something",
( x1 = new XML(xml4), x1.ns1::b.@attr.toString()));
Assert.expectEq("x1.namespace1::node1.@attr = \"new value\"", "something else",
( x1 = new XML(xml4), x1.ns1::b.@attr = "something else", x1.ns1::b.@attr.toString()));
var ns = new Namespace("foo");
var y1 = <y xmlns:ns="foo" a="10" b="20" ns:c="30" ns:d="40"/>;
var an = 'a';
Assert.expectEq("y1.@a", "10", y1.@a.toString());
Assert.expectEq("y1.@[an]", "10", y1.@[an].toString());
Assert.expectEq("y1.@*", "10203040", y1.@*.toString()); // Rhino bug: doesn't include qualified attributes
Assert.expectEq("y1.@ns::*", 2, y1.@ns::*.length());
var z = <y xmlns:ns="foo" a="10" b="20" ns:c="30" ns:d="40"/>;
Assert.expectEq("y1.@b", "200", (z.@b = 200, z.@b.toString()));
Assert.expectEq("y1.@*", "103040", (delete y1.@b, y1.@*.toString()));
// Adding for bug 117159
var element:XML = new XML(<element function="foo"/>);
Assert.expectEq("Reserved keyword used as attribute name", "foo", element.@["function"].toString());
var xmlObj = new XML ();
xmlObj = XML ('<elem attr1="firstAttribute"></elem>');
try {
e = xmlObj.(@nonExistentAttribute == "nonExistent");
result = e;
} catch (e2) {
result = Utils.referenceError(e2.toString());
}
Assert.expectEq("Access non-existent attribute", "ReferenceError: Error #1065", result);
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,38 @@
1 PASSED!
2 PASSED!
3 PASSED!
4 PASSED!
5 PASSED!
6 PASSED!
7.3 PASSED!
7.4 PASSED!
7 PASSED!
7.1 PASSED!
7.2 PASSED!
8 PASSED!
9 PASSED!
10 PASSED!
11 PASSED!
12 PASSED!
q3 = y.name() PASSED!
x1.bravo.@[q3] PASSED!
Attribute with apostrophe in it PASSED!
Attribute with apostrophe in it PASSED!
x1.node1[i].@attr PASSED!
x1.node1[i].@attr = "new value" PASSED!
x1.node1[i].@[placeHolder] PASSED!
x1.node1[i].@[placeHolder] = "new value" PASSED!
x1.node1[i].@attr PASSED!
x1.node1[i].@attr = "new value" PASSED!
x1.node1.@[attr-with-hyphen] PASSED!
x1.node1.@[attr-with-hyphen] = "new value" PASSED!
x1.namespace1::node1.@attr PASSED!
x1.namespace1::node1.@attr = "new value" PASSED!
y1.@a PASSED!
y1.@[an] PASSED!
y1.@* PASSED!
y1.@ns::* PASSED!
y1.@b PASSED!
y1.@* PASSED!
Reserved keyword used as attribute name PASSED!
Access non-existent attribute PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,247 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.1.2 - Qualified Identifiers");
x1 =
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<m:getLastTradePrice xmlns:m="http://mycompany.com/stocks">
<symbol>DIS</symbol>
</m:getLastTradePrice>
</soap:Body>
</soap:Envelope>;
soap = new Namespace("http://schemas.xmlsoap.org/soap/envelope/");
stock = new Namespace("http://mycompany.com/stocks");
encodingStyle = x1.@soap::encodingStyle;
TEST_XML(1, "http://schemas.xmlsoap.org/soap/encoding/", encodingStyle);
correct =
<soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<m:getLastTradePrice xmlns:m="http://mycompany.com/stocks">
<symbol>DIS</symbol>
</m:getLastTradePrice>
</soap:Body>;
body = x1.soap::Body;
TEST_XML(2, correct.toXMLString(), body);
body = x1.soap::["Body"];
TEST_XML(3, correct.toXMLString(), body);
q = new QName(soap, "Body");
body = x1[q];
TEST_XML(4, correct.toXMLString(), body);
correct =
<symbol xmlns:m="http://mycompany.com/stocks" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">MYCO</symbol>;
x1.soap::Body.stock::getLastTradePrice.symbol = "MYCO";
TEST_XML(5, correct.toXMLString(), x1.soap::Body.stock::getLastTradePrice.symbol);
// SOAP messages
var msg1 = <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<m:GetLastTradePrice xmlns:m="http://mycompany.com/stocks/">
<symbol>DIS</symbol>
</m:GetLastTradePrice>
</s:Body>
</s:Envelope>
var msg2 = <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<m:GetLastTradePrice xmlns:m="http://mycompany.com/stocks/">
<symbol>MACR</symbol>
</m:GetLastTradePrice>
</s:Body>
</s:Envelope>
var msg3 = <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<m:GetLastTradePrice xmlns:m="http://mycompany.com/stocks/"
m:blah="http://www.hooping.org">
<symbol>MACR</symbol>
</m:GetLastTradePrice>
</s:Body>
</s:Envelope>
var msg4 = <soap>
<bakery>
<m:g xmlns:m="http://macromedia.com/software/central/"
pea="soup"
pill="box"
neck="lace"
m:blah="http://www.hooping.org">
<pill>box</pill>
<neck>lace</neck>
<pea>soup</pea>
</m:g>
</bakery>
</soap>
var msg5 = "soupboxlacehttp://www.hooping.org";
// declare namespaces
var ns1 = new Namespace("http://schemas.xmlsoap.org/soap/envelope/");
var ns2= new Namespace ("http://mycompany.com/stocks/");
var ns3= new Namespace ("http://macromedia.com/software/central/");
// extract the soap encoding style and body from the soap msg1
var encodingStyle = msg1.@ns1::encodingStyle;
var stockURL = msg1.ns1::Body.ns2::GetLastTradePrice.@ns2::blah;
var body = msg1.ns1::Body;
// change the stock symbol
body.ns2::GetLastTradePrice.symbol = "MACR";
Assert.expectEq("body.ns2::GetLastTradePrice.symbol = \"MACR\"", "MACR",
( body.ns2::GetLastTradePrice.symbol.toString()));
bodyQ = msg1[QName(ns1, "Body")];
Assert.expectEq("ms1.ns1::Body == msg1[QName(ns1, \"Body\")]", true, (bodyQ == body));
Assert.expectEq("msg1 == msg2", true,
( msg1 == msg2));
Assert.expectEq("msg1.@ns1::encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/",
( msg1.@ns1::encodingStyle.toString()));
Assert.expectEq("msg3.ns1::Body.ns2::GetLastTradePrice.@ns2", "http://www.hooping.org",
( msg3.ns1::Body.ns2::GetLastTradePrice.@ns2::blah.toString()));
// Rhino behaves differently:
Assert.expectEq("msg4.bakery.ns3::g.@*", msg5,
( msg4.bakery.ns3::g.@*.toString()));
var x1 = <x xmlns:ns="foo" ns:v='55'><ns:a>10</ns:a><b/><ns:c/></x>;
var ns = new Namespace("foo");
Assert.expectEq("x1.ns::*", new XMLList("<ns:a xmlns:ns=\"foo\">10</ns:a><ns:c xmlns:ns=\"foo\"/>").toString(), x1.ns::*.toString());
Assert.expectEq("x1.ns::a", "10", x1.ns::a.toString())
Assert.expectEq("x1.*::a", "10", x1.*::a.toString()); // issue: assert
Assert.expectEq("x1.ns::a", "20", (x1.ns::a = 20, x1.ns::a.toString()));
Assert.expectEq("x1.@ns::['v']", "55", x1.@ns::['v'].toString());
Assert.expectEq("x1.@ns::['v']", "555", (x1.@ns::['v'] = '555', x1.@ns::['v'].toString()));
var y1 = <y xmlns:ns="foo" a="10" b="20" ns:c="30" ns:d="40"/>
Assert.expectEq("y1.@ns::*.length()", 2, y1.@ns::*.length());
var z = new XMLList("<b xmlns:ns=\"foo\"/><ns:c xmlns:ns=\"foo\"/>");
Assert.expectEq("x1.*", z.toString(), (delete x1.ns::a, x1.*.toString()));
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,19 @@
1 PASSED!
2 PASSED!
3 PASSED!
4 PASSED!
5 PASSED!
body.ns2::GetLastTradePrice.symbol = "MACR" PASSED!
ms1.ns1::Body == msg1[QName(ns1, "Body")] PASSED!
msg1 == msg2 PASSED!
msg1.@ns1::encodingStyle PASSED!
msg3.ns1::Body.ns2::GetLastTradePrice.@ns2 PASSED!
msg4.bakery.ns3::g.@* PASSED!
x1.ns::* PASSED!
x1.ns::a PASSED!
x1.*::a PASSED!
x1.ns::a PASSED!
x1.@ns::['v'] PASSED!
x1.@ns::['v'] PASSED!
y1.@ns::*.length() PASSED!
x1.* PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,137 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.1.3 - Wildcard Identifiers");
var x1 =
<alpha>
<bravo>one</bravo>
<charlie>two</charlie>
</alpha>
var correct = new XMLList("<bravo>one</bravo><charlie>two</charlie>");
TEST(1, correct, x1.*);
XML.ignoreWhitespace = false;
var xml1 = "<p><a>1</a><a>2</a><a>3</a></p>";
var xml2 = "<a>1</a><a>2</a><a>3</a>";
var xml3 = "<a><e f='a'>hey</e><e f='b'> </e><e f='c'>there</e></a><a>2</a><a>3</a>";
var xml4 = "<p><a hi='a' he='v' ho='m'>hello</a></p>";
var ns1 = new Namespace('foobar', 'http://boo.org');
var ns2 = new Namespace('fooboo', 'http://foo.org');
var ns3 = new Namespace('booboo', 'http://goo.org');
Assert.expectEq("x.a.*", "123", (x1 = new XML(xml1), x1.a.*.toString()));
Assert.expectEq("xmllist.a.*", "123", (x1 = new XMLList(xml1), x1.a.*.toString()));
Assert.expectEq("xmllist.*", "123", (x1 = new XMLList(xml2), x1.*.toString()));
Assert.expectEq("xmllist[0].*", "1", (x1 = new XMLList(xml2), x1[0].*.toString()));
Assert.expectEq("xmllist[0].e.*", "hey there", (x1 = new XMLList(xml3), x1[0].e.*.toString()));
Assert.expectEq("xml.a.@*", "avm", (x1 = new XML(xml4), x1.a.@*.toString()));
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,7 @@
1 PASSED!
x.a.* PASSED!
xmllist.a.* PASSED!
xmllist.* PASSED!
xmllist[0].* PASSED!
xmllist[0].e.* PASSED!
xml.a.@* PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,295 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.1.4 - XML Initializer");
XML.ignoreWhitespace = true;
person = <person><name>John</name><age>25</age></person>;
TEST(1, <person><name>John</name><age>25</age></person>, person);
e = <employees>
<employee id = "1"><name>Joe</name><age>20</age></employee>
<employee id = "2"><name>Sue</name><age>30</age></employee>
</employees>;
TEST_XML(2, 1, e.employee[0].@id);
correct = <name>Sue</name>;
TEST(3, correct, e.employee[1].name);
names = new Array();
names[0] = "Alpha";
names[1] = "Bravo";
names[2] = "Charlie";
names[3] = "Delta";
names[4] = "Echo";
names[5] = "Golf";
names[6] = "Hotel";
names[7] = "India";
names[8] = "Juliet";
names[9] = "Kilo";
ages = new Array();
ages[0] = "20";
ages[1] = "21";
ages[2] = "22";
ages[3] = "23";
ages[4] = "24";
ages[5] = "25";
ages[6] = "26";
ages[7] = "27";
ages[8] = "28";
ages[9] = "29";
for (i = 0; i < 10; i++)
{
e.*[i] = <employee id={i}>
<name>{names[i].toUpperCase()}</name>
<age>{ages[i]}</age>
</employee>;
correct = new XML("<employee id=\"" + i + "\"><name>" + names[i].toUpperCase() + "</name><age>" + ages[i] + "</age></employee>");
TEST(4 + i, correct, e.*[i]);
}
tagName = "name";
attributeName = "id";
attributeValue = 5;
content = "Fred";
x1 = <{tagName} {attributeName}={attributeValue}>{content}</{tagName}>;
TEST(14, "<name id=\"5\">Fred</name>", x1.toXMLString());
// Test {} on XML and XMLList types
x1 =
<rectangle>
<length>30</length>
<width>50</width>
</rectangle>;
correct =
<rectangle>
<width>50</width>
<length>30</length>
</rectangle>;
x1 = <rectangle>{x1.width}{x1.length}</rectangle>;
TEST(15, correct, x1);
var content = "<foo name=\"value\">bar</foo>";
x1 = <x><a>{content}</a></x>;
correct = <x/>;
correct.a = content;
TEST(16, correct, x1);
x1 = <x a={content}/>;
correct = <x/>;
correct.@a = content;
TEST(17, correct, x1);
a = 5;
b = 3;
c = "x";
x1 = <{c} a={a + " < " + b + " is " + (a < b)}>{a + " < " + b + " is " + (a < b)}</{c}>;
TEST(18, "<x a=\"5 &lt; 3 is false\">5 &lt; 3 is false</x>", x1.toXMLString());
x1 = <{c} a={a + " > " + b + " is " + (a > b)}>{a + " > " + b + " is " + (a > b)}</{c}>;
TEST(19, "<x a=\"5 > 3 is true\">5 &gt; 3 is true</x>", x1.toXMLString());
var tagname = "name";
var attributename = "id";
var attributevalue = 5;
content = "Fred";
var xml1 = <{tagname} {attributename}={attributevalue}>{content}</{tagname}>;
Assert.expectEq( "x = <{tagname} {attributename}={attributevalue}>{content}</{tagname}>", true,
( x1 = new XML('<name id="5">Fred</name>'), (xml1 == x1)));
names = ["Alfred", "Allie", "Maryann", "Jason", "Amy", "Katja", "Antonio", "Melvin", "Stefan", "Amber"];
ages = [55, 21, 25, 23, 28, 30, 35, 26, 30, 30];
var xml2;
var xml2string = "<employees>";
var e = new Array();
for (i = 0; i < 10; i++) {
e[i] = <employee id={i}>
<name>{names[i].toUpperCase()}</name>
<age>{ages[i]}</age>
</employee>;
xml2string += "<employee id=\"" + i + "\"><name>" + names[i].toUpperCase() + "</name><age>" + ages[i] + "</age></employee>";
}
xml2 = <employees>{e[0]}{e[1]}{e[2]}{e[3]}{e[4]}{e[5]}{e[6]}{e[7]}{e[8]}{e[9]}</employees>;
xml2string += "</employees>";
Assert.expectEq( "Evaluating expressions in a for loop", true,
( x1 = new XML(xml2string), (xml2 == x1)));
var xml3 = <person><name>John</name><age>25</age></person>;
Assert.expectEq( "x = <person><name>John</name><age>25</age></person>", true,
( x1 = new XML(xml3.toString()), (xml3 == x1)));
var xml4 = new XML("<xml><![CDATA[<hey>]]></xml>");
Assert.expectEq( "<xml><![CDATA[<hey>]]></xml>", true,
( x1 = new XML("<xml><![CDATA[<hey>]]></xml>"), (xml4 == x1)));
xml5 = <xml><b>heh hey</b></xml>;
XML.ignoreWhitespace = true;
Assert.expectEq( "<xml><b>heh hey</b></xml>", true,
( x1 = new XML("<xml><b>heh hey</b></xml>"), (xml5 == x1)));
Assert.expectEq( "x = new XML(\"\"), xml = \"\", (xml == x)", true,
( x1 = new XML(""), xml = "", (xml == x1)));
var xx = new XML("<classRec><description><![CDATA[characteristics:<ul> <li>A</li> <li>B</li> </ul>]]></description></classRec>");
Assert.expectEq( "<xml><![CDATA[characteristics:<ul> <li>A</li> <li>B</li> </ul>]]></xml>, xml.toXMLString()",
"<classRec>" + NL() + " <description><![CDATA[characteristics:<ul> <li>A</li> <li>B</li> </ul>]]></description>" + NL() + "</classRec>",
xx.toXMLString());
Assert.expectEq( "<xml><![CDATA[characteristics:<ul> <li>A</li> <li>B</li> </ul>]]></xml>, xml.description.text()",
"characteristics:<ul> <li>A</li> <li>B</li> </ul>",
xx.description.text().toString());
Assert.expectEq( "<xml><![CDATA[characteristics:<ul> <li>A</li> <li>B</li> </ul>]]></xml>, xml.description.child(0)",
"characteristics:<ul> <li>A</li> <li>B</li> </ul>",
xx.description.child(0).toString());
Assert.expectEq( "<xml><![CDATA[characteristics:<ul> <li>A</li> <li>B</li> </ul>]]></xml>, xml.description.child(0).nodeKind()",
"text",
xx.description.child(0).nodeKind());
var desc = "this is the <i>text</i>";
x1 = <description>{"<![CDATA[" + desc + "]]>"}</description>;
Assert.expectEq("desc = \"this is the <i>text</i>\"; x = <description>{\"<![CDATA[\" + desc + \"]]>\"}</description>;",
"<![CDATA[this is the <i>text</i>]]>", x1.toString());
Assert.expectEq("desc = \"this is the <i>text</i>\"; x = <description>{\"<![CDATA[\" + desc + \"]]>\"}</description>;",
"<description>&lt;![CDATA[this is the &lt;i&gt;text&lt;/i&gt;]]&gt;</description>", x1.toXMLString());
// Testing for extra directives. See bug 94230.
var xx = <?xml version="1.0" encoding="UTF-8"?>
<?mso-infoPathSolution solutionVersion="1.0.0.26" productVersion="11.0.6250" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\Bob\BoB\Goodbye%20Doubt\Repository\CMS\Forms\PatternForm.xsn" name="urn:schemas-microsoft-com:office:infopath:PatternForm:urn-axiology-PatternDocument" language="en-us" ?>
<?mso-application progid="InfoPath.Document"?>;
Assert.expectEq("Testing for extra directives", "", xx.toString());
xx = new XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><?mso-infoPathSolution solutionVersion=\"1.0.0.26\" productVersion=\"11.0.6250\" PIVersion=\"1.0.0.0\" href=\"file:///C:\Documents%20and%20Settings\Bob\BoB\Goodbye%20Doubt\Repository\CMS\Forms\PatternForm.xsn\" name=\"urn:schemas-microsoft-com:office:infopath:PatternForm:urn-axiology-PatternDocument\" language=\"en-us\" ?><?mso-application progid=\"InfoPath.Document\"?>");
Assert.expectEq("Testing for extra directives", "", xx.toString());
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,33 @@
1 PASSED!
2 PASSED!
3 PASSED!
4 PASSED!
5 PASSED!
6 PASSED!
7 PASSED!
8 PASSED!
9 PASSED!
10 PASSED!
11 PASSED!
12 PASSED!
13 PASSED!
14 PASSED!
15 PASSED!
16 PASSED!
17 PASSED!
18 PASSED!
19 PASSED!
x = <{tagname} {attributename}={attributevalue}>{content}</{tagname}> PASSED!
Evaluating expressions in a for loop PASSED!
x = <person><name>John</name><age>25</age></person> PASSED!
<xml><![CDATA[<hey>]]></xml> PASSED!
<xml><b>heh hey</b></xml> PASSED!
x = new XML(""), xml = "", (xml == x) PASSED!
<xml><![CDATA[characteristics:<ul> <li>A</li> <li>B</li> </ul>]]></xml>, xml.toXMLString() PASSED!
<xml><![CDATA[characteristics:<ul> <li>A</li> <li>B</li> </ul>]]></xml>, xml.description.text() PASSED!
<xml><![CDATA[characteristics:<ul> <li>A</li> <li>B</li> </ul>]]></xml>, xml.description.child(0) PASSED!
<xml><![CDATA[characteristics:<ul> <li>A</li> <li>B</li> </ul>]]></xml>, xml.description.child(0).nodeKind() PASSED!
desc = "this is the <i>text</i>"; x = <description>{"<![CDATA[" + desc + "]]>"}</description>; PASSED!
desc = "this is the <i>text</i>"; x = <description>{"<![CDATA[" + desc + "]]>"}</description>; PASSED!
Testing for extra directives PASSED!
Testing for extra directives PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,180 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.1.5 - XMLList Initializer");
XML.ignoreWhitespace = true;
var docfrag = <><fName>Phil</fName><age>35</age><hobby>skiing</hobby></>;
TEST(1, "xml", typeof(docfrag));
var correct = <fName>Phil</fName>;
TEST(2, correct, docfrag[0]);
var emplist = <>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
<employee id="2"><name>Sue</name><age>30</age></employee>
</>;
TEST(3, "xml", typeof(emplist));
TEST_XML(4, 2, emplist[2].@id);
var myVar = "kitty";
var xml1 = <><a><b><c>1</c></b></a></>;
var xml2 = <>a</>;
var xml3 = <><a>b</a></>;
var xml4 = <><a b='1'><c>cat</c><d>walk</d></a><a b='2'><c>dog</c><d>run</d></a></>;
var xml5 = <></>;
var xml6 = <><{myVar}>hello</{myVar}></>;
var xml7 = <><c q='1'>"quotes"</c><c q='2'>&#x7B;curly brackets&#x7D;</c></>;
var xml8 = <><a>5 &gt; 4</a></>;
var empxml = <>
<employee id="0" ><name>Jim</name><age>25</age></employee>
<employee id="1" ><name>Joe</name><age>20</age></employee>
<employee id="2" ><name>Sue</name><age>30</age></employee>
</>;
emplist = "<employee id=\"0\" ><name>Jim</name><age>25</age></employee><employee id=\"1\" ><name>Joe</name><age>20</age></employee><employee id=\"2\" ><name>Sue</name><age>30</age></employee>";
Assert.expectEq( "<><a><b><c>1</c></b></a></> == new XMLList(\"<a><b><c>1</c></b></a>\")", true,
( x1 = new XMLList('<a><b><c>1</c></b></a>'), (xml1 == x1)));
Assert.expectEq( "<>a</> == new XMLList('a')", true,
( x1 = new XMLList('a'), (xml2 == x1)));
Assert.expectEq( "<><a>b</a></> == new XMLList('<a>b</a>')", true,
( x1 = new XMLList('<a>b</a>'), (xml3 == x1)));
Assert.expectEq( "<>[list]</> == new XMLList([list])", true,
( x1 = new XMLList('<a b="1"><c>cat</c><d>walk</d></a><a b="2"><c>dog</c><d>run</d></a>'), (xml4 == x1)));
Assert.expectEq( "<></> == new XMLList()", true,
( x1 = new XMLList(), (xml5 == x1)));
Assert.expectEq( "<></> == new XMLList(\"\")", true,
( x1 = new XMLList(""), (xml5 == x1)));
Assert.expectEq( "<><{myVar}>hello</{myVar}></> == new XMLList('<value>hello</value>')", true,
( x1 = new XMLList("<kitty>hello</kitty>"), (xml6 == x1)));
Assert.expectEq( "<><c>&#x7B; \\\"\\\" &#x7B;</c></> == new XMLList(<c>{ \"\" }</c>)", true,
( x1 = new XMLList("<c q='1'>\"quotes\"</c><c q='2'>{curly brackets}</c>"), (xml7 == x1)));
Assert.expectEq( "<><a>5 &gt; 4</a></> == new XMLList('<a>5 > 4</a>')", true,
( x1 = new XMLList("<a>5 > 4</a>"), (xml8 == x1)));
Assert.expectEq( "Multiline XML", true,
( x1 = new XMLList(emplist), (empxml == x1)));
// Testing for extra directives. See bug 94230.
var xl = <><?xml version="1.0" encoding="UTF-8"?>
<?mso-infoPathSolution solutionVersion="1.0.0.26" productVersion="11.0.6250" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\Bob\BoB\Goodbye%20Doubt\Repository\CMS\Forms\PatternForm.xsn" name="urn:schemas-microsoft-com:office:infopath:PatternForm:urn-axiology-PatternDocument" language="en-us" ?>
<?mso-application progid="InfoPath.Document"?><root><blah>a</blah></root></>;
Assert.expectEq("Testing for extra directives", (<><root><blah>a</blah></root></>).toString(), xl.toString());
xl = new XMLList("<?xml version=\"1.0\" encoding=\"UTF-8\"?><?mso-infoPathSolution solutionVersion=\"1.0.0.26\" productVersion=\"11.0.6250\" PIVersion=\"1.0.0.0\" href=\"file:///C:\Documents%20and%20Settings\Bob\BoB\Goodbye%20Doubt\Repository\CMS\Forms\PatternForm.xsn\" name=\"urn:schemas-microsoft-com:office:infopath:PatternForm:urn-axiology-PatternDocument\" language=\"en-us\" ?><?mso-application progid=\"InfoPath.Document\"?><root><blah>a</blah></root>");
Assert.expectEq("Testing for extra directives", (new XMLList("<root><blah>a</blah></root>")).toString(), xl.toString());
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,16 @@
1 PASSED!
2 PASSED!
3 PASSED!
4 PASSED!
<><a><b><c>1</c></b></a></> == new XMLList("<a><b><c>1</c></b></a>") PASSED!
<>a</> == new XMLList('a') PASSED!
<><a>b</a></> == new XMLList('<a>b</a>') PASSED!
<>[list]</> == new XMLList([list]) PASSED!
<></> == new XMLList() PASSED!
<></> == new XMLList("") PASSED!
<><{myVar}>hello</{myVar}></> == new XMLList('<value>hello</value>') PASSED!
<><c>&#x7B; \"\" &#x7B;</c></> == new XMLList(<c>{ "" }</c>) PASSED!
<><a>5 &gt; 4</a></> == new XMLList('<a>5 > 4</a>') PASSED!
Multiline XML PASSED!
Testing for extra directives PASSED!
Testing for extra directives PASSED!

View File

@ -0,0 +1 @@
num_ticks = 1

View File

@ -0,0 +1,332 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.2.1 - Property Accessors");
function convertToString(o:Object){
return o.toString();
}
order =
<order id="123456" timestamp="Mon Mar 10 2003 16:03:25 GMT-0800 (PST)">
<customer>
<firstname>John</firstname>
<lastname>Doe</lastname>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
</order>;
correct =
<customer>
<firstname>John</firstname>
<lastname>Doe</lastname>
</customer>;
TEST(1, correct, order.customer);
TEST_XML(2, 123456, order.@id);
correct =
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
TEST(3, correct, order.children()[1]);
correct =
<customer>
<firstname>John</firstname>
<lastname>Doe</lastname>
</customer> +
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>;
TEST(4, correct, order.*);
correct = new XMLList();
correct += new XML("123456");
correct += new XML("Mon Mar 10 2003 16:03:25 GMT-0800 (PST)");
TEST(5, correct, order.@*);
order = <order>
<customer>
<firstname>John</firstname>
<lastname>Doe</lastname>
</customer>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
correct =
<description>Big Screen Television</description> +
<description>DVD Player</description>;
TEST(6, correct, order.item.description);
correct = new XMLList();
correct += new XML("3456");
correct += new XML("56789");
TEST(7, correct, order.item.@id);
correct =
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
TEST(8, correct, order.item[1]);
correct =
<description>Big Screen Television</description> +
<price>1299.99</price> +
<quantity>1</quantity> +
<description>DVD Player</description> +
<price>399.99</price> +
<quantity>1</quantity>;
TEST(9, correct, order.item.*);
correct=
<price>1299.99</price>;
TEST(10, correct, order.item.*[1]);
// get the first (and only) order [treating single element as a list]
order = <order>
<customer>
<firstname>John</firstname>
<lastname>Doe</lastname>
</customer>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
TEST(11, order, order[0]);
// Any other index should return undefined
TEST(12, undefined, order[1]);
var xml = "<order id = \"123456\"><c><f>John</f><l>Doe</l></c><i><desc>B</desc><p>1299.99</p><q>1</q></i><i><desc>A</desc><p>12.99</p><q>1</q></i></order>";
// XML object test cases
Assert.expectEq("XML.c.f:", "John", (o = new XML(xml), o.c.f.toString()));
Assert.expectEq("XML.c['f']:", "John", (o = new XML(xml), o.c['f'].toString()));
Assert.expectEq("XML.c.f[0]:", "John", (o = new XML(xml), o.c.f[0].toString()));
Assert.expectEq("XML.i[1].p:", "12.99", (o = new XML(xml), o.i[1].p.toString()));
Assert.expectEq("XML.i[1]['p]'", "12.99", (o = new XML(xml), o.i[1]['p'].toString()));
// High ASCII test
var xmlHighASCII = "<f><fname>Sören Lehmenkühler</fname></f>";
Assert.expectEq("High ASCII node value:", "Sören Lehmenkühler", (o = new XML(xmlHighASCII), o.fname.toString()));
// XMLList object test cases
Assert.expectEq("XMLList.c.f:", "John", (ol = new XMLList(xml), ol.c.f.toString()));
Assert.expectEq("XMLList.c[\"f\"]:", "John", (ol = new XMLList(xml), ol.c["f"].toString()));
Assert.expectEq("XMLList.c.f[0]:", "John", (o = new XMLList(xml), o.c.f[0].toString()));
Assert.expectEq("XMLList.c.f[0] = \"Peter\":", "Peter", (o = new XMLList(xml), o.c.f[0] = "Peter", o.c.f[0].toString()));
Assert.expectEq("XMLList.i[1].p:", "12.99", (ol = new XMLList(xml), ol.i[1].p.toString()));
Assert.expectEq("XMLList.i[1][\"p\"]:", "12.99", (ol = new XMLList(xml), ol.i[1]["p"].toString()));
Assert.expectEq("XMLList[1] = <a>b</a>", "b", (ol = new XMLList(), ol[1] = <a>b</a>, ol.toString()));
Assert.expectEq("XMLList[1] = <a>b</a>; XMLList[0] = <c>d</c>", "d", (ol = new XMLList(), ol[1] = <a>b</a>, ol[0] = <c>d</c>, ol.toString()));
Assert.expectEq("XMLList[0] = <a>b</a>; XMLList[1] = <c>d</c>", convertToString(new XMLList("<a>b</a><c>d</c>")), (ol = new XMLList(), ol[0] = <a>b</a>, ol[1] = <c>d</c>, ol).toString());
var x1 = new XML("<x><fname>a</fname><fname>b</fname><fname>c</fname></x>");
var y1 = x1.fname;
Assert.expectEq("x1.f == x1.f[0] + x1.f[1] + x1.f[2]", convertToString(x1.fname[0] + x1.fname[1] + x1.fname[2]),
x1.fname.toString());
// comparing XML and XMLList equivalents
Assert.expectEq("XML[0].fname[1] == XMLList[1]:", true, (y1 = x1.fname, (x1[0].fname[1] == y1[1])));
Assert.expectEq("XML[0].fname[0] == XMLList.fname[0]:", true, (y1 = new XMLList(x1), (x1[0].fname[0] == y1.fname[0])));
var hyphenatedXML = new XML("<a><b-c a='1'>blue</b-c><b-c a='2'>orange</b-c><b-c a='3'>yellow</b-c></a>");
Assert.expectEq("hyphenatedXML.[\"b-c\"]:", "orange", (hyphenatedXML["b-c"][1].toString()));
Assert.expectEq("hyphenatedXML.[\"b-c\"][1] = \"new color\":", "pink", (hyphenatedXML["b-c"][1] = "pink", hyphenatedXML["b-c"][1].toString()));
xL = <x a="aatr" b="batr">y</x>;
Assert.expectEq("x['*']", "y", xL['*'].toString());
Assert.expectEq("x['@*']", "aatrbatr", xL['@*'].toString());
Assert.expectEq("x['@a']", "aatr", xL['@a'].toString());
xL = <x xmlns:ns1="foo" xmlns:ns2="bar" ns1:prop='prop1' ns2:prop='prop2' prop='prop3'>some text</x>;
Assert.expectEq("x1.@prop", "prop3", xL.@prop.toString());
function setNS1() {
use namespace foo;
Assert.expectEq("use namespace foo; x1.@prop", "prop1prop3", xL.@prop.toString());
}
function setNS2() {
namespace foo2 = "bar";
use namespace foo2;
Assert.expectEq("use namespace foo2; x1.@prop", "prop2prop3", xL.@prop.toString());
}
function setNS3() {
use namespace foo;
namespace foo2 = "bar";
use namespace foo2;
Assert.expectEq("use namespace foo2; x1.@prop", "prop1prop2prop3", xL.@prop.toString());
}
namespace foo = "foo";
setNS1();
setNS2();
setNS3();
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,39 @@
1 PASSED!
2 PASSED!
3 PASSED!
4 PASSED!
5 PASSED!
6 PASSED!
7 PASSED!
8 PASSED!
9 PASSED!
10 PASSED!
11 PASSED!
12 PASSED!
XML.c.f: PASSED!
XML.c['f']: PASSED!
XML.c.f[0]: PASSED!
XML.i[1].p: PASSED!
XML.i[1]['p]' PASSED!
High ASCII node value: PASSED!
XMLList.c.f: PASSED!
XMLList.c["f"]: PASSED!
XMLList.c.f[0]: PASSED!
XMLList.c.f[0] = "Peter": PASSED!
XMLList.i[1].p: PASSED!
XMLList.i[1]["p"]: PASSED!
XMLList[1] = <a>b</a> PASSED!
XMLList[1] = <a>b</a>; XMLList[0] = <c>d</c> PASSED!
XMLList[0] = <a>b</a>; XMLList[1] = <c>d</c> PASSED!
x1.f == x1.f[0] + x1.f[1] + x1.f[2] PASSED!
XML[0].fname[1] == XMLList[1]: PASSED!
XML[0].fname[0] == XMLList.fname[0]: PASSED!
hyphenatedXML.["b-c"]: PASSED!
hyphenatedXML.["b-c"][1] = "new color": PASSED!
x['*'] PASSED!
x['@*'] PASSED!
x['@a'] PASSED!
x1.@prop PASSED!
use namespace foo; x1.@prop PASSED!
use namespace foo2; x1.@prop PASSED!
use namespace foo2; x1.@prop PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,197 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.2.2 - Function Calls");
function convertToString(o:Object){
return o.toString();
}
rectangle = <rectangle>
<x>50</x>
<y>75</y>
<length>20</length>
<width>30</width>
</rectangle>;
TEST(1, 1, rectangle.length());
TEST(2, <length>20</length>, rectangle.length);
shipto = <shipto>
<name>Fred Jones</name>
<street>123 Foobar Ave.</street>
<citystatezip>Redmond, WA, 98008</citystatezip>
</shipto>;
upperName = shipto.name.toUpperCase();
TEST(3, "FRED JONES", upperName);
upperName = shipto.name.toString().toUpperCase();
TEST(4, "FRED JONES", upperName);
upperName = shipto.name.toUpperCase();
TEST(5, "FRED JONES", upperName);
citystatezip = shipto.citystatezip.split(", ");
state = citystatezip[1];
TEST(6, "WA", state);
zip = citystatezip[2];
TEST(7, "98008", zip);
citystatezip = shipto.citystatezip.toString().split(", ");
state = citystatezip[1];
TEST(8, "WA", state);
zip = citystatezip[2];
TEST(9, "98008", zip);
foo = <top><apple>hello</apple></top>;
var1 = foo.apple;
foo.apple = "moi";
TEST(10, <apple>moi</apple>, var1);
// Test method name/element name conflicts
x1 =
<alpha>
<name>Foo</name>
<length>Bar</length>
</alpha>;
TEST(11, QName("alpha"), x1.name());
TEST(12, <length>Bar</length>, x1.length);
TEST(13, 1, x1.length());
TEST(14, x1, x1.(length == "Bar"));
x1.name = "foobar";
TEST(15, <name>foobar</name>, (x1.name));
TEST(16, QName("alpha"), (x1.name()));
var xml = "<person><name>Bubba</name></person>";
Assert.expectEq("person.name:", "Bubba", (x1 = new XML(xml), x1.name.toString()));
Assert.expectEq("person.name():", "person", (x1 = new XML(xml), x1.name().toString()));
xml = "<i><length>5</length><width>30</width></i>";
Assert.expectEq("i.length:", "5", (x1 = new XML(xml), x1.length.toString()));
Assert.expectEq("i.length():", 1, (x1 = new XML(xml), x1.length()));
xml = "<xml><parent><i>a</i><i>b</i><i>c</i></parent></xml>";
var p = new XMLList(xml).parent;
Assert.expectEq("x.parent:", p.toString(), (x1 = new XML(xml), x1.parent).toString());
Assert.expectEq("x.parent():", undefined, (x1 = new XML(xml), x1.parent()));
Assert.expectEq("x.parent.parent():", x1.toString(), (x1 = new XML(xml), x1.parent.parent()).toString());
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,23 @@
1 PASSED!
2 PASSED!
3 PASSED!
4 PASSED!
5 PASSED!
6 PASSED!
7 PASSED!
8 PASSED!
9 PASSED!
10 PASSED!
11 PASSED!
12 PASSED!
13 PASSED!
14 PASSED!
15 PASSED!
16 PASSED!
person.name: PASSED!
person.name(): PASSED!
i.length: PASSED!
i.length(): PASSED!
x.parent: PASSED!
x.parent(): PASSED!
x.parent.parent(): PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,165 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.2.3 - XML Descendant Accessor");
function convertToString(o:Object){
return o.toString();
}
var e =
<employees>
<employee id="1"><name>Joe</name><age>20</age></employee>
<employee id="2"><name>Sue</name><age>30</age></employee>
</employees>
names = e..name;
correct =
<name>Joe</name> +
<name>Sue</name>;
TEST(1, correct, names);
e = "<employees><employee id=\"1\"><name>Joe</name><age>20</age></employee><employee id=\"2\"><name>Sue</name><age>30</age></employee></employees>";
Assert.expectEq("xml..validnode:", "Joe", (x1 = new XML(e), names = x1..name, names[0].toString()));
Assert.expectEq("xml..validnode length:", 2, (x1 = new XML(e), names = x1..name, names.length()));
Assert.expectEq("xml..invalidnode:", undefined, (x1 = new XML(e), names = x1..hood, names[0]));
Assert.expectEq("xmllist..validnode:", "Joe", (x1 = new XMLList(e), names = x1..name, names[0].toString()));
Assert.expectEq("xmllist..invalidnode:", undefined, (x1 = new XMLList(e), names = x1..hood, names[0]));
Assert.expectEq("xmllist..invalidnode length:", 0, (x1 = new XMLList(e), names = x1..hood, names.length()));
e =
<employees>
<employee id="1"><first_name>Joe</first_name><age>20</age></employee>
<employee id="2"><first_name>Sue</first_name><age>30</age></employee>
</employees>
correct =
<first_name>Joe</first_name> +
<first_name>Sue</first_name>;
names = e..first_name;
TEST(2, correct, names);
e =
<employees>
<employee id="1"><first-name>Joe</first-name><age>20</age></employee>
<employee id="2"><first-name>Sue</first-name><age>30</age></employee>
</employees>
e =
<company><staff>
<bug attr='1'><coat><bug>heart</bug></coat></bug>
<bug attr='2'><dirt><bug>part</bug></dirt></bug>
</staff></company>
es = <><bug attr='1'><coat><bug>heart</bug></coat></bug><bug>heart</bug><bug attr='2'><dirt><bug>part</bug></dirt></bug><bug>part</bug></>;
Assert.expectEq(3, es.toString(), convertToString(e..bug));
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,9 @@
1 PASSED!
xml..validnode: PASSED!
xml..validnode length: PASSED!
xml..invalidnode: PASSED!
xmllist..validnode: PASSED!
xmllist..invalidnode: PASSED!
xmllist..invalidnode length: PASSED!
2 PASSED!
3 PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,251 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.2.4 - XML Filtering Predicate Operator");
function convertToString(o:Object){
return o.toString();
}
var p;
e = <employees>
<employee id="0"><fname>John</fname><age>20</age></employee>
<employee id="1"><fname>Sue</fname><age>30</age></employee>
</employees>;
correct = <employee id="0"><fname>John</fname><age>20</age></employee>;
john = e.employee.(fname == "John");
TEST(1, correct, john);
john = e.employee.(fname == "John");
TEST(2, correct, john);
correct =
<employee id="0"><fname>John</fname><age>20</age></employee> +
<employee id="1"><fname>Sue</fname><age>30</age></employee>;
twoEmployees = e.employee.(@id == 0 || @id == 1);
TEST(3, correct, twoEmployees);
twoEmployees = e.employee.(@id == 0 || @id == 1);
TEST(4, correct, twoEmployees);
i = 0;
twoEmployees = new XMLList();
for each (p in e..employee)
{
if (p.@id == 0 || p.@id == 1)
{
twoEmployees += p;
}
}
TEST(5, correct, twoEmployees);
i = 0;
twoEmployees = new XMLList();
for each (p in e..employee)
{
if (p.@id == 0 || p.@id == 1)
{
twoEmployees[i++] = p;
}
}
TEST(6, correct, twoEmployees);
// test with syntax
e = <employees>
<employee id="0"><fname>John</fname><age>20</age></employee>
<employee id="1"><fname>Sue</fname><age>30</age></employee>
</employees>;
correct =
<employee id="0"><fname>John</fname><age>20</age></employee> +
<employee id="1"><fname>Sue</fname><age>30</age></employee>;
i = 0;
twoEmployees = new XMLList();
for each (p in e..employee)
{
with (p)
{
if (@id == 0 || @id == 1)
{
twoEmployees[i++] = p;
}
}
}
TEST(7, correct, twoEmployees);
var xml = "<employees><employee id=\"1\"><fname>Joe</fname><age>20</age></employee><employee id=\"2\"><fname>Sue</fname><age>Joe</age></employee></employees>";
var e = new XML(xml);
// get employee with fname Joe
Assert.expectEq("e.employee.(fname == \"Joe\")", 1, (joe = e.employee.(fname == "Joe"), joe.length()));
// employees with id's 0 & 1
Assert.expectEq("employees with id's 1 & 2", 2, (emps = e.employee.(@id == 1 || @id == 2), emps.length()));
// name of employee with id 1
Assert.expectEq("name of employee with id 1", "Joe", (emp = e.employee.(@id == 1).fname, emp.toString()));
// get the two employees with ids 0 and 1 using a predicate
var i = 0;
var twoEmployees = new XMLList();
for each (p in e..employee) {
with (p) {
if (@id == 1 || @id == 2) {
twoEmployees[i++] = p;
}
}
}
var twoEmployees = e..employee.(@id == 1 || @id == 2);
Assert.expectEq("Compare to equivalent XMLList", true, (emps = e..employee.(@id == 1 || @id == 2), emps == twoEmployees));
var employees:XML =
<employees>
<employee ssn="123-123-1234" id="1">
<name first="John" last="Doe"/>
<address>
<street>11 Main St.</street>
<city>San Francisco</city>
<state>CA</state>
<zip>98765</zip>
</address>
</employee>
<employee ssn="789-789-7890" id="2">
<name first="Mary" last="Roe"/>
<address>
<street>99 Broad St.</street>
<city>Newton</city>
<state>MA</state>
<zip>01234</zip>
</address>
</employee>
</employees>;
for each (var id:XML in employees.employee.@id) {
trace(id); // 123-123-1234
}
correct =
<employee ssn="789-789-7890" id="2">
<name first="Mary" last="Roe"/>
<address>
<street>99 Broad St.</street>
<city>Newton</city>
<state>MA</state>
<zip>01234</zip>
</address>
</employee>;
var idToFind:String = "2";
Assert.expectEq("employees.employee.(@id == idToFind)", correct.toString(), (employees.employee.(@id == idToFind)).toString());
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,14 @@
1 PASSED!
2 PASSED!
3 PASSED!
4 PASSED!
5 PASSED!
6 PASSED!
7 PASSED!
e.employee.(fname == "Joe") PASSED!
employees with id's 1 & 2 PASSED!
name of employee with id 1 PASSED!
Compare to equivalent XMLList PASSED!
1
2
employees.employee.(@id == idToFind) PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,551 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
import com.adobe.test.Utils;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.3.1 - Delete Operator");
order =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
// Delete the customer address
correct =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
delete order.customer.address;
TEST_XML(1, "", order.customer.address);
TEST(2, correct, order);
order =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
// delete the custmomer ID
correct =
<order id="123456">
<customer>
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
delete order.customer.@id;
TEST_XML(3, "", order.customer.@id);
TEST(4, correct, order);
order =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
// delete the first item price
correct =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<quantity>1</quantity>
</item>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
delete order.item.price[0];
TEST_XML(5, "", order.item[0].price);
TEST(6, <price>1299.99</price>, order.item.price[0]);
TEST(7, order, correct);
order =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
// delete all the items
correct =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
</order>;
delete order.item;
TEST_XML(8, "", order.item);
TEST(9, correct, order);
order =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
// delete all description tags with descendant operator
// is not supposed to do anything, see bug 149397
correct =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
delete order..description;
TEST(10, correct, order);
order =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<customer id="456">
<firstname>Mary</firstname>
<lastname>Jones</lastname>
<address>456 Foobar Ave.</address>
<city>Bel Air</city>
<state>CA</state>
</customer>
</order>;
try {
delete order.customer.(firstname == "John");
result = order;
} catch (e1) {
result = Utils.typeError(e1.toString());
}
Assert.expectEq("Delete an XMLList", "TypeError: Error #1119", result);
order =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
// delete all id attributes
correct =
<order id="123456">
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item>
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</order>;
delete order.item.@id;
TEST(11, correct, order);
order =
<order id="123456">
<blah>
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="3456">
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item id="56789">
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</blah>
</order>;
// delete all id attributes, using descendant operator
correct =
<order id="123456">
<blah>
<customer id="123">
<firstname>John</firstname>
<lastname>Doe</lastname>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
<item>
<description>DVD Player</description>
<price>399.99</price>
<quantity>1</quantity>
</item>
</blah>
</order>;
delete order..item.@id;
TEST(12, correct, order);
//default xml namespace = "http://someuri";
x1 = <x/>;
x1.a.b = "foo";
delete x1.a.b;
TEST_XML(10, "", x1.a.b);
var ns = new Namespace("");
x1.a.b = <b xmlns="">foo</b>;
TEST(11, "foo", x1.a.ns::b.toString());
delete x1.a.b;
TEST(12, "", x1.a.ns::b.toString());
delete x1.a.ns::b;
TEST_XML(13, "", x1.a.ns::b);
var y1;
x1 = new XML("<a><b><c>C</c><d>D</d></b></a>");
y1 = new XML("<a><b><c>C</c></b></a>");
Assert.expectEq("delete XML:", true, (delete x1.b.d, (x1 == y1)));
x1 = new XMLList("<d><a>A</a><b>B</b><c>C</c></d>");
y1 = new XMLList("<d><a>A</a><c>C</c></d>");
Assert.expectEq("delete XMLList:", true, (delete x1.b, (x1 == y1)));
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,19 @@
1 PASSED!
2 PASSED!
3 PASSED!
4 PASSED!
5 PASSED!
6 PASSED!
7 PASSED!
8 PASSED!
9 PASSED!
10 PASSED!
Delete an XMLList PASSED!
11 PASSED!
12 PASSED!
10 PASSED!
11 PASSED!
12 PASSED!
13 PASSED!
delete XML: PASSED!
delete XMLList: PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,124 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.3.2 - Typeof Operator");
x1 = new XML();
TEST(1, "xml", typeof(x1));
x1 = new XMLList();
TEST(2, "xml", typeof(x1));
x1 = new XML("<a><b><c>C</c><d>D</d></b></a>");
x_ = new XML("<b><e>E</e></b>");
Assert.expectEq( "typeof XML :", "xml", typeof(x1) );
Assert.expectEq( "typeof XML :", "xml", typeof(x1.a.b+x_) );
x1 = new XMLList("<a>A</a><b>B</b><c>C</c>");
x_ = new XMLList("<d>D</d>");
Assert.expectEq( "typeof XMLList :", "xml", typeof(x1) );
Assert.expectEq( "typeof XMLList :", "xml", typeof(x1+x_) );
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,6 @@
1 PASSED!
2 PASSED!
typeof XML : PASSED!
typeof XML : PASSED!
typeof XMLList : PASSED!
typeof XMLList : PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,231 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.4.1 - Addition Operator");
employeeData = <name>Fred</name> + <age>28</age> + <hobby>skiing</hobby>;
TEST(1, "xml", typeof(employeeData));
correct = <><name>Fred</name><age>28</age><hobby>skiing</hobby></>;
TEST(2, correct, employeeData);
order = <order>
<item>
<description>Big Screen Television</description>
</item>
<item>
<description>DVD Player</description>
</item>
<item>
<description>CD Player</description>
</item>
<item>
<description>8-Track Player</description>
</item>
</order>;
correct =
<item><description>Big Screen Television</description></item> +
<item><description>CD Player</description></item> +
<item><description>8-Track Player</description></item>;
myItems = order.item[0] + order.item[2] + order.item[3];
TEST(3, "xml", typeof(myItems));
TEST(4, correct, myItems);
correct =
<item><description>Big Screen Television</description></item> +
<item><description>DVD Player</description></item> +
<item><description>CD Player</description></item> +
<item><description>8-Track Player</description></item> +
<item><description>New Item</description></item>;
newItems = order.item + <item><description>New Item</description></item>;
TEST(5, "xml", typeof(newItems));
TEST(6, correct, newItems);
order =
<order>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item>
<description>DVD Player</description>
<price>399.99</price>
</item>
<item>
<description>CD Player</description>
<price>199.99</price>
</item>
<item>
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
totalPrice = +order.item[0].price + +order.item[1].price;
TEST(7, "number", typeof(totalPrice));
TEST(8, 1699.98, totalPrice);
totalPrice = +order.item[1].price + +order.item[3].price;
TEST(9, 469.98, totalPrice);
order =
<order>
<customer>
<address>
<street>123 Foobar Ave.</street>
<city>Bellevue</city>
<state>WA</state>
<zip>98008</zip>
</address>
</customer>
</order>;
streetCity = "" + order.customer.address.street + order.customer.address.city;
TEST(10, "string", typeof(streetCity));
TEST(11, "123 Foobar Ave.Bellevue", streetCity);
statezip = String(order.customer.address.state) + order.customer.address.zip;
TEST(12, "string", typeof(statezip));
TEST(13, "WA98008", statezip);
// XML + XML
var x1, y1, z1;
x1 = new XML("<a><b><c>A</c><d>B</d></b></a>");
y1 = new XML("<a><b><c>C</c><d>D</d></b></a>");
z1 = new XMLList("<a><b><c>A</c><d>B</d></b></a><a><b><c>C</c><d>D</d></b></a>");
Assert.expectEq( "XML + XML: ", true, ((x1+y1)==z1) );
// XML + XMLList
x1 = new XML("<a><b><c>A</c><d>B</d></b></a>");
y1 = new XMLList("<e>C</e><e>D</e><e>E</e>");
z1 = new XMLList("<a><b><c>A</c><d>B</d></b></a><e>C</e><e>D</e><e>E</e>");
Assert.expectEq( "XML + XMLList: ", true, ((x1+y1)==z1) );
// XMLList + XML
x1 = new XMLList("<e>C</e><e>D</e><e>E</e>");
y1 = new XML("<a><b><c>A</c><d>B</d></b></a>");
z1 = new XMLList("<e>C</e><e>D</e><e>E</e><a><b><c>A</c><d>B</d></b></a>");
Assert.expectEq( "XMLList + XML: ", true, ((x1+y1)==z1) );
// XMLList + XMLList
x1 = new XMLList("<a>A</a><a>B</a><a>C</a>");
y1 = new XMLList("<a>D</a><a>E</a><a>F</a>");
z1 = new XMLList("<a>A</a><a>B</a><a>C</a><a>D</a><a>E</a><a>F</a>");
Assert.expectEq( "XMLList + XMLList: ", true, ((x1+y1)==z1) );
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,17 @@
1 PASSED!
2 PASSED!
3 PASSED!
4 PASSED!
5 PASSED!
6 PASSED!
7 PASSED!
8 PASSED!
9 PASSED!
10 PASSED!
11 PASSED!
12 PASSED!
13 PASSED!
XML + XML: PASSED!
XML + XMLList: PASSED!
XMLList + XML: PASSED!
XMLList + XMLList: PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,259 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.5.1 - Equality Operators");
x1 = <alpha>one</alpha>;
y1 = <alpha>one</alpha>;
TEST(1, true, (x1 == y1) && (y1 == x1));
var myxml:XML = <a>foo</a>;
var str1:String = "foo";
TEST(17, true, myxml.hasSimpleContent());
TEST(18, true, myxml==str1);
// Should return false if comparison is not XML
y1 = "<alpha>one</alpha>";
TEST(2, false, (x1 == y1) || (y1 == x1));
y1 = undefined
TEST(3, false, (x1 == y1) || (y1 == x1));
y1 = null
TEST(4, false, (x1 == y1) || (y1 == x1));
// Should check logical equiv.
x1 = <alpha attr1="value1">one<bravo attr2="value2">two</bravo></alpha>;
y1 = <alpha attr1="value1">one<bravo attr2="value2">two</bravo></alpha>;
TEST(5, true, (x1 == y1) && (y1 == x1));
y1 = <alpha attr1="new value">one<bravo attr2="value2">two</bravo></alpha>;
TEST(6, false, (x1 == y1) || (y1 == x1));
m = new Namespace();
n = new Namespace();
TEST(7, true, m == n);
m = new Namespace("uri");
TEST(8, false, m == n);
n = new Namespace("ns", "uri");
TEST(9, true, m == n);
m = new Namespace(n);
TEST(10, true, m == n);
TEST(11, false, m == null);
TEST(12, false, null == m);
m = new Namespace("ns", "http://anotheruri");
TEST(13, false, m == n);
p = new QName("a");
q = new QName("b");
TEST(14, false, p == q);
q = new QName("a");
TEST(15, true, p == q);
q = new QName("http://someuri", "a");
TEST(16, false, p == q);
q = new QName(null, "a");
TEST(16, false, p == q);
var x1 = new XML("<aa><a>A</a><a>B</a><a>C</a></aa>");
var y0 = new XML("<a><b>A</b><c>B</c></a>");
var y1 = new XML("<aa><a>A</a><a>B</a><a>C</a></aa>");
var y2 = new XML("<bb><b>A</b><b>B</b><b>C</b></bb>");
var y3 = new XML("<aa><a>Dee</a><a>Eee</a><a>Fee</a></aa>");
Assert.expectEq( "x=XMLList, y=XML :", false, (x1==y0) );
Assert.expectEq( "x=XMLList, y=XMLList :", true, (x1==y1) );
Assert.expectEq( "x=XMLList, y=XMLList :", false, (x1==y2) );
Assert.expectEq( "x=XMLList, y=XMLList :", false, (x1==y3) );
var xt = new XML("<a><b>text</b></a>");
var xa = new XML("<a attr='ATTR'><b>attribute</b></a>");
var xh = new XML("<a>hasSimpleContent</a>");
var yt = new XML("<a><b>text</b></a>");
var ya = new XML("<a attr='ATTR'><b>attribute</b></a>");
var yh = new XML("<a>hasSimpleContent</a>");
Assert.expectEq( "x.[[Class]]='text, y.[[Class]]='text' :", true, (xt==yt) );
Assert.expectEq( "x.[[Class]]='text, y.[[Class]]='attribute' :", false, (xt==ya.@attr) );
Assert.expectEq( "x.[[Class]]='text, y.hasSimpleContent() :", false, (xt==yh) );
Assert.expectEq( "x.[[Class]]='attribute, y.[[Class]]='text' :", false, (xa.@attr==yt) );
Assert.expectEq( "x.[[Class]]='attribute, y.[[Class]]='attribute' :", true, (xa.@attr==ya.@attr) );
Assert.expectEq( "x.[[Class]]='attribute, y.hasSimpleContent() :", false, (xa.@attr==yh) );
Assert.expectEq( "x.hasSimpleContent(), y.[[Class]]='text' :", false, (xh==yt) );
Assert.expectEq( "x.hasSimpleContent(), y.[[Class]]='attribute' :", false, (xh==ya.@attr) );
Assert.expectEq( "x.hasSimpleContent(), y.hasSimpleContent() :", true, (xh==yh) );
var xqn0 = new QName("n0");
var xqn1 = new QName("ns1","n1");
var yqn00 = new QName("n0");
var yqn01 = new QName("nA");
var yqn10 = new QName("ns1", "n1" );
var yqn11 = new QName("ns1", "nB");
var yqn12 = new QName("nsB","n1" );
var yqn13 = new QName("nsB","nB");
Assert.expectEq( "QName('n0'), QName('n0') :", true, (xqn0==yqn00) );
Assert.expectEq( "QName('n0'), QName('nA') :", false, (xqn0==yqn01) );
Assert.expectEq( "QName('n0'), QName('ns1','n1') :", false, (xqn0==yqn10) );
Assert.expectEq( "QName('n0'), QName('ns1','nB') :", false, (xqn0==yqn11) );
Assert.expectEq( "QName('n0'), QName('nsB','n1') :", false, (xqn0==yqn12) );
Assert.expectEq( "QName('n0'), QName('naB','nB') :", false, (xqn0==yqn13) );
Assert.expectEq( "QName('ns1','n1'), QName('n0') :", false, (xqn1==yqn00) );
Assert.expectEq( "QName('ns1','n1'), QName('nA') :", false, (xqn1==yqn01) );
Assert.expectEq( "QName('ns1','n1'), QName('ns1','n1') :", true, (xqn1==yqn10) );
Assert.expectEq( "QName('ns1','n1'), QName('ns1','nB') :", false, (xqn1==yqn11) );
Assert.expectEq( "QName('ns1','n1'), QName('nsB','n1') :", false, (xqn1==yqn12) );
Assert.expectEq( "QName('ns1','n1'), QName('nsB','nB') :", false, (xqn1==yqn13) );
var xns0 = new Namespace();
var xns1 = new Namespace("uri1");
var xns2 = new Namespace("pre2","uri2");
var yns00 = new Namespace();
var yns10 = new Namespace("uri1");
var yns11 = new Namespace("uriB");
var yns20 = new Namespace("pre2","uri2");
var yns21 = new Namespace("pre2","uriC");
var yns22 = new Namespace("preC","uri2");
var yns23 = new Namespace("preC","uriC");
Assert.expectEq( "Namespace(), Namespace() :", true, (xns0==yns00) );
Assert.expectEq( "Namespace(), Namespace('uri1') :", false, (xns0==yns10) );
Assert.expectEq( "Namespace(), Namespace('uriB') :", false, (xns0==yns11) );
Assert.expectEq( "Namespace(), Namespace('pre2','uri2') :", false, (xns0==yns20) );
Assert.expectEq( "Namespace(), Namespace('pre2','uriC') :", false, (xns0==yns21) );
Assert.expectEq( "Namespace(), Namespace('preC','uri2') :", false, (xns0==yns22) );
Assert.expectEq( "Namespace(), Namespace('preC','uriC') :", false, (xns0==yns23) );
Assert.expectEq( "Namespace('uri1'), Namespace() :", false, (xns1==yns00) );
Assert.expectEq( "Namespace('uri1'), Namespace('uri1') :", true, (xns1==yns10) );
Assert.expectEq( "Namespace('uri1'), Namespace('uriB') :", false, (xns1==yns11) );
Assert.expectEq( "Namespace('uri1'), Namespace('pre2','uri2') :", false, (xns1==yns20) );
Assert.expectEq( "Namespace('uri1'), Namespace('pre2','uriC') :", false, (xns1==yns21) );
Assert.expectEq( "Namespace('uri1'), Namespace('preC','uri2') :", false, (xns1==yns22) );
Assert.expectEq( "Namespace('uri1'), Namespace('preC','uriC') :", false, (xns1==yns23) );
Assert.expectEq( "Namespace('pre2','uri2'), Namespace() :", false, (xns2==yns00) );
Assert.expectEq( "Namespace('pre2','uri2'), Namespace('uri1') :", false, (xns2==yns10) );
Assert.expectEq( "Namespace('pre2','uri2'), Namespace('uriB') :", false, (xns2==yns11) );
Assert.expectEq( "Namespace('pre2','uri2'), Namespace('pre2','uri2') :", true, (xns2==yns20) );
Assert.expectEq( "Namespace('pre2','uri2'), Namespace('pre2','uriC') :", false, (xns2==yns21) );
Assert.expectEq( "Namespace('pre2','uri2'), Namespace('preC','uri2') :", true, (xns2==yns22) );
Assert.expectEq( "Namespace('pre2','uri2'), Namespace('preC','uriC') :", false, (xns2==yns23) );
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,65 @@
1 PASSED!
17 PASSED!
18 PASSED!
2 PASSED!
3 PASSED!
4 PASSED!
5 PASSED!
6 PASSED!
7 PASSED!
8 PASSED!
9 PASSED!
10 PASSED!
11 PASSED!
12 PASSED!
13 PASSED!
14 PASSED!
15 PASSED!
16 PASSED!
16 PASSED!
x=XMLList, y=XML : PASSED!
x=XMLList, y=XMLList : PASSED!
x=XMLList, y=XMLList : PASSED!
x=XMLList, y=XMLList : PASSED!
x.[[Class]]='text, y.[[Class]]='text' : PASSED!
x.[[Class]]='text, y.[[Class]]='attribute' : PASSED!
x.[[Class]]='text, y.hasSimpleContent() : PASSED!
x.[[Class]]='attribute, y.[[Class]]='text' : PASSED!
x.[[Class]]='attribute, y.[[Class]]='attribute' : PASSED!
x.[[Class]]='attribute, y.hasSimpleContent() : PASSED!
x.hasSimpleContent(), y.[[Class]]='text' : PASSED!
x.hasSimpleContent(), y.[[Class]]='attribute' : PASSED!
x.hasSimpleContent(), y.hasSimpleContent() : PASSED!
QName('n0'), QName('n0') : PASSED!
QName('n0'), QName('nA') : PASSED!
QName('n0'), QName('ns1','n1') : PASSED!
QName('n0'), QName('ns1','nB') : PASSED!
QName('n0'), QName('nsB','n1') : PASSED!
QName('n0'), QName('naB','nB') : PASSED!
QName('ns1','n1'), QName('n0') : PASSED!
QName('ns1','n1'), QName('nA') : PASSED!
QName('ns1','n1'), QName('ns1','n1') : PASSED!
QName('ns1','n1'), QName('ns1','nB') : PASSED!
QName('ns1','n1'), QName('nsB','n1') : PASSED!
QName('ns1','n1'), QName('nsB','nB') : PASSED!
Namespace(), Namespace() : PASSED!
Namespace(), Namespace('uri1') : PASSED!
Namespace(), Namespace('uriB') : PASSED!
Namespace(), Namespace('pre2','uri2') : PASSED!
Namespace(), Namespace('pre2','uriC') : PASSED!
Namespace(), Namespace('preC','uri2') : PASSED!
Namespace(), Namespace('preC','uriC') : PASSED!
Namespace('uri1'), Namespace() : PASSED!
Namespace('uri1'), Namespace('uri1') : PASSED!
Namespace('uri1'), Namespace('uriB') : PASSED!
Namespace('uri1'), Namespace('pre2','uri2') : PASSED!
Namespace('uri1'), Namespace('pre2','uriC') : PASSED!
Namespace('uri1'), Namespace('preC','uri2') : PASSED!
Namespace('uri1'), Namespace('preC','uriC') : PASSED!
Namespace('pre2','uri2'), Namespace() : PASSED!
Namespace('pre2','uri2'), Namespace('uri1') : PASSED!
Namespace('pre2','uri2'), Namespace('uriB') : PASSED!
Namespace('pre2','uri2'), Namespace('pre2','uri2') : PASSED!
Namespace('pre2','uri2'), Namespace('pre2','uriC') : PASSED!
Namespace('pre2','uri2'), Namespace('preC','uri2') : PASSED!
Namespace('pre2','uri2'), Namespace('preC','uriC') : PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,556 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.6.1 - XML Assignment");
// Change the value of the id attribute on the second item
order =
<order>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
correct =
<order>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="1.23">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
order.item[1].@id = 1.23;
TEST(1, correct, order);
// Add a new attribute to the second item
order =
<order>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
correct =
<order>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2" newattr="new value">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
order.item[1].@newattr = "new value";
TEST(2, correct, order);
// Construct an attribute list containing all the ids in this order
order =
<order>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
order.@allids = order.item.@id;
TEST_XML(3, "1 2 3 4", order.@allids);
// Replace first child of the order element with an XML value
order =
<order>
<customer>
<name>John</name>
<address>948 Ranier Ave.</address>
<city>Portland</city>
<state>OR</state>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
order.*[0] =
<customer>
<name>Fred</name>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>;
correct =
<order>
<customer>
<name>Fred</name>
<address>123 Foobar Ave.</address>
<city>Bellevue</city>
<state>WA</state>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
TEST(4, correct, order);
// Replace the second child of the order element with a list of items
order =
<order>
<customer>
<name>John</name>
<address>948 Ranier Ave.</address>
<city>Portland</city>
<state>OR</state>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
correct =
<order>
<customer>
<name>John</name>
<address>948 Ranier Ave.</address>
<city>Portland</city>
<state>OR</state>
</customer>
<item>item one</item>
<item>item two</item>
<item>item three</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
order.item[0] = <item>item one</item> +
<item>item two</item> +
<item>item three</item>;
TEST(5, correct, order);
// Replace the third child of the order with a text node
order =
<order>
<customer>
<name>John</name>
<address>948 Ranier Ave.</address>
<city>Portland</city>
<state>OR</state>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
correct =
<order>
<customer>
<name>John</name>
<address>948 Ranier Ave.</address>
<city>Portland</city>
<state>OR</state>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">A Text Node</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
order.item[1] = "A Text Node";
TEST(6, correct, order);
// append a new item to the end of the order
order =
<order>
<customer>
<name>John</name>
<address>948 Ranier Ave.</address>
<city>Portland</city>
<state>OR</state>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
</order>;
correct =
<order>
<customer>
<name>John</name>
<address>948 Ranier Ave.</address>
<city>Portland</city>
<state>OR</state>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
<item id="3">
<description>CD Player</description>
<price>199.99</price>
</item>
<item id="4">
<description>8-Track Player</description>
<price>69.99</price>
</item>
<item>new item</item>
</order>;
order.*[order.*.length()] = <item>new item</item>;
TEST(7, correct, order);
// Change the price of the item
item =
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
correct =
<item>
<description>Big Screen Television</description>
<price>99.95</price>
</item>
item.price = 99.95;
TEST(8, item, correct);
// Change the description of the item
item =
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
correct =
<item>
<description>Mobile Phone</description>
<price>1299.99</price>
</item>
item.description = "Mobile Phone";
TEST(9, item, correct);
// property name begins with "@"
var xx = new XML("<a attr='A' />");
var xl = new XMLList("<a attr='X' /><a attr='Y' /><a attr='Z' />");
var x_ = new XML("<a attr='X Y Z' />");
xx.@attr = xl.@attr;
Assert.expectEq( "x.@attr=XMLList :", true, (xx==x_) );
xx = new XML("<a attr='A' />");
yy = new XML("<a attr='B' />");
xx.@attr = "B";
Assert.expectEq( "xx.@attr='B' :", "B", xx.@attr.toString() );
xx.@attr__ = "B";
Assert.expectEq( "xx.@attr__='B' :", true, (xx.@attr__=="B") );
// property name does NOT begin with "@" and is NOT array index
var x0 = new XML("<a><b>B</b><c>C</c><d>D</d></a>");
var x1 = new XML("<a><b>Z</b></a>");
var x0_ = new XML("<a><b>Z</b><c>C</c><d>D</d></a>");
x0.b = x1.b;
Assert.expectEq( "Replace XML Obj - XML :", true, (x0==x0_) );
var x2 = new XMLList("<b><c>Y</c><d>X</d></b>");
x0.b = x2;
x0_ = new XML("<a><b><c>Y</c><d>X</d></b><c>C</c><d>D</d></a>");
Assert.expectEq( "Replace XML Obj - XMLList :", true, (x0==x0_) );
x0 = new XML("<a><b>B</b><c>C</c><d>D</d></a>");
x0.e = new XML("<e>E</e>");
x0_ = new XML("<a><b>B</b><c>C</c><d>D</d><e>E</e></a>");
Assert.expectEq( "Append new XML property :", true, (x0==x0_) );
x0 = new XML("<a><b>B0</b><b>B1</b><b>B2</b></a>");
x1 = new XML("<a><b>BB</b></a>");
x0_ = new XML("<a><b>BB</b></a>");
x0 = x1;
Assert.expectEq( "Multiple XML objs with given name - XML :", true, (x0==x0_) );
x0 = new XML("<a><b>B0</b><b>B1</b><b>B2</b></a>");
x1 = new XML("<b>BB</b>");
x0_ = new XML("<a><b>BB</b></a>");
x0.b = x1;
Assert.expectEq( "Multiple XML objs with given name - XMLList :", true, (x0==x0_) );
x0 = new XML("<a><b>B</b><c>C</c></a>");
x0_ = new XML("<a><b>A</b><c>C</c></a>");
x0.b = "A";
Assert.expectEq( "x.b = 'A' :", true, (x0==x0_) );
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,18 @@
1 PASSED!
2 PASSED!
3 PASSED!
4 PASSED!
5 PASSED!
6 PASSED!
7 PASSED!
8 PASSED!
9 PASSED!
x.@attr=XMLList : PASSED!
xx.@attr='B' : PASSED!
xx.@attr__='B' : PASSED!
Replace XML Obj - XML : PASSED!
Replace XML Obj - XMLList : PASSED!
Append new XML property : PASSED!
Multiple XML objs with given name - XML : PASSED!
Multiple XML objs with given name - XMLList : PASSED!
x.b = 'A' : PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,467 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.6.2 - XMLList Assignment");
// Set the name of the only customer in the order to Fred Jones
order =
<order>
<customer>
<name>John Smith</name>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
</order>;
correct =
<order>
<customer>
<name>Fred Jones</name>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
</order>;
//order.customer.name = "Fred Jones";
//TEST(1, correct, order);
// Replace all the hobbies for the only customer in the order
order =
<order>
<customer>
<name>John Smith</name>
<hobby>Biking</hobby>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
</order>;
correct =
<order>
<customer>
<name>John Smith</name>
<hobby>shopping</hobby>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
</order>;
order.customer.hobby = "shopping"
TEST(2, correct, order);
// Attempt to set the sale date of the item. Throw an exception if more than 1 item exists.
order =
<order>
<customer>
<name>John Smith</name>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
<saledate>01-05-2002</saledate>
</item>
</order>;
correct =
<order>
<customer>
<name>John Smith</name>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
<saledate>05-07-2002</saledate>
</item>
</order>;
order.item.saledate = "05-07-2002"
TEST(3, correct, order);
order =
<order>
<customer>
<name>John Smith</name>
<hobby>Biking</hobby>
</customer>
<item id="1">
<description>Big Screen Television</description>
<price>1299.99</price>
</item>
<item id="2">
<description>DVD Player</description>
<price>399.99</price>
</item>
</order>;
try {
order.item.saledate = "05-07-2002";
SHOULD_THROW(4);
} catch (ex) {
TEST(4, "TypeError", ex.name);
}
// Replace all the employee's hobbies with their new favorite pastime
emps =
<employees>
<employee id = "1">
<name>John</name>
<age>20</age>
<hobby>skiing</hobby>
</employee>
<employee id = "2">
<name>Sue</name>
<age>30</age>
<hobby>running</hobby>
</employee>
<employee id = "3">
<name>Ted</name>
<age>35</age>
<hobby>Biking</hobby>
</employee>
</employees>;
correct =
<employees>
<employee id = "1">
<name>John</name>
<age>20</age>
<hobby>skiing</hobby>
</employee>
<employee id = "2">
<name>Sue</name>
<age>30</age>
<hobby>running</hobby>
</employee>
<employee id = "3">
<name>Ted</name>
<age>35</age>
<hobby>working</hobby>
</employee>
</employees>;
//emps.employee.(@id == 3).hobby = "working";
//TEST(5, correct, emps);
// Replace the first employee with George
emps =
<employees>
<employee id = "1">
<name>John</name>
<age>20</age>
</employee>
<employee id = "2">
<name>Sue</name>
<age>30</age>
</employee>
<employee id = "3">
<name>Ted</name>
<age>35</age>
</employee>
</employees>;
correct =
<employees>
<employee id = "4">
<name>George</name>
<age>27</age>
</employee>
<employee id = "2">
<name>Sue</name>
<age>30</age>
</employee>
<employee id = "3">
<name>Ted</name>
<age>35</age>
</employee>
</employees>;
emps.employee[0] = <employee id="4"><name>George</name><age>27</age></employee>;
TEST(6, emps, correct);
// Add a new employee to the end of the employee list
emps =
<employees>
<employee id = "1">
<name>John</name>
<age>20</age>
</employee>
<employee id = "2">
<name>Sue</name>
<age>30</age>
</employee>
<employee id = "3">
<name>Ted</name>
<age>35</age>
</employee>
</employees>;
correct =
<employees>
<employee id = "1">
<name>John</name>
<age>20</age>
</employee>
<employee id = "2">
<name>Sue</name>
<age>30</age>
</employee>
<employee id = "3">
<name>Ted</name>
<age>35</age>
</employee>
<employee id="4">
<name>Frank</name>
<age>39</age>
</employee>
</employees>;
emps.employee += <employee id="4"><name>Frank</name><age>39</age></employee>;
TEST(7, correct, emps);
// Add a new employee to the end of the employee list
emps =
<employees>
<employee id = "1">
<name>John</name>
<age>20</age>
</employee>
<employee id = "2">
<name>Sue</name>
<age>30</age>
</employee>
<employee id = "3">
<name>Ted</name>
<age>35</age>
</employee>
</employees>;
correct =
<employees>
<employee id = "1">
<name>John</name>
<age>20</age>
</employee>
<employee id = "2">
<name>Sue</name>
<age>30</age>
</employee>
<employee id = "3">
<name>Ted</name>
<age>35</age>
</employee>
<employee id="4">
<name>Frank</name>
<age>39</age>
</employee>
</employees>;
emps.employee[emps.employee.length()] = <employee id="4"><name>Frank</name><age>39</age></employee>;
TEST(7, correct, emps);
// property name is NOT array index
var x1 = new XML("<a><b><c>A</c><d>B</d></b></a>");
x1.b.d = "C";
var y1 = new XML("<a><b><c>A</c><d>C</d></b></a>");
Assert.expectEq( "property name is not array index :", true, (x1==y1) );
x1 = new XML("<a><b><c>A</c><d>B</d></b></a>");
x1.v.b.d = "C";
y1 = new XML("<a><b><c>A</c><d>B</d></b><v><b><d>C</d></b></v></a>");
Assert.expectEq("Adding new nested node at root: " , true, (x1 == y1));
// property name is array index
x1 = new XML("<a><b><c>A0</c><d>B0</d></b><b><c>A1</c><d>B1</d></b><b><c>A2</c><d>B2</d></b></a>");
x1.b[1] = new XML("<b><c>A3</c><d>B3</d></b>");
y1 = new XML("<a><b><c>A0</c><d>B0</d></b><b><c>A3</c><d>B3</d></b><b><c>A2</c><d>B2</d></b></a>");
Assert.expectEq( "property name exists in XMLList :", true, (x1==y1) );
// property name does NOT exist in XMLList
x1.b[3] = new XML("<b><c>A4</c><d>B4</d></b>");
y1 = new XML("<a><b><c>A0</c><d>B0</d></b><b><c>A3</c><d>B3</d></b><b><c>A2</c><d>B2</d></b><b><c>A4</c><d>B4</d></b></a>");
Assert.expectEq( "property name does NOT exist in XMLList :", true, (x1==y1) );
// property is XML with non-null parent
x1 = new XML("<a><b><c>A0</c><d>B0</d></b><b><c>A1</c><d>B1</d></b><b><c>A2</c><d>B2</d></b></a>");
x1.b = new XMLList("<b>A</b><c>B</c>");
y1 = new XML("<a><b>A</b><c>B</c></a>");
Assert.expectEq( "property is XML with non-null parent :", true, (x1==y1) );
// AssignmentExpression = XML value
x1 = new XML("<a><b><c>A0</c><d>B0</d></b><b><c>A1</c><d>B1</d></b><b><c>A2</c><d>B2</d></b></a>");
x1.b[0] = new XML("<b><c>A3</c><d>B3</d></b>");
y1 = new XML("<a><b><c>A3</c><d>B3</d></b><b><c>A1</c><d>B1</d></b><b><c>A2</c><d>B2</d></b></a>");
Assert.expectEq( "AssignmentExpression = XML value :", true, (x1==y1) );
// AssignmentExpression = XMLList object
x1 = new XML("<a><b><c>A0</c><d>B0</d></b><b><c>A1</c><d>B1</d></b><b><c>A2</c><d>B2</d></b></a>");
x1.b = new XMLList("<b>A</b><b>B</b><b>C</b>");
y1 = new XML("<a><b>A</b><b>B</b><b>C</b></a>");
Assert.expectEq( "AssignmentExpression = XMLList object :", true, (x1==y1) );
// AssignmentExpression != XML/XMLList
x1 = new XML("<a><b><c>A0</c><d>B0</d></b><b><c>A1</c><d>B1</d></b><b><c>A2</c><d>B2</d></b></a>");
x1.b = "Hello World";
y1 = new XML("<a><b>Hello World</b></a>");
Assert.expectEq( "AssignmentExpression != XML/XMLList :", true, (x1==y1) );
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,14 @@
2 PASSED!
3 PASSED!
4 PASSED!
6 PASSED!
7 PASSED!
7 PASSED!
property name is not array index : PASSED!
Adding new nested node at root: PASSED!
property name exists in XMLList : PASSED!
property name does NOT exist in XMLList : PASSED!
property is XML with non-null parent : PASSED!
AssignmentExpression = XML value : PASSED!
AssignmentExpression = XMLList object : PASSED!
AssignmentExpression != XML/XMLList : PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,207 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.6.3 - Compound Assignment");
// Insert employee 3 and 4 after the first employee
e =
<employees>
<employee id="1">
<name>Joe</name>
<age>20</age>
</employee>
<employee id="2">
<name>Sue</name>
<age>30</age>
</employee>
</employees>;
correct =
<employees>
<employee id="1">
<name>Joe</name>
<age>20</age>
</employee>
<employee id="3">
<name>Fred</name>
</employee>
<employee id="4">
<name>Carol</name>
</employee>
<employee id="2">
<name>Sue</name>
<age>30</age>
</employee>
</employees>;
e.employee[0] += <employee id="3"><name>Fred</name></employee> +
<employee id="4"><name>Carol</name></employee>;
TEST(1, correct, e);
// Append employees 3 and 4 to the end of the employee list
e =
<employees>
<employee id="1">
<name>Joe</name>
<age>20</age>
</employee>
<employee id="2">
<name>Sue</name>
<age>30</age>
</employee>
</employees>;
correct =
<employees>
<employee id="1">
<name>Joe</name>
<age>20</age>
</employee>
<employee id="2">
<name>Sue</name>
<age>30</age>
</employee>
<employee id="3">
<name>Fred</name>
</employee>
<employee id="4">
<name>Carol</name>
</employee>
</employees>;
e.employee[1] += <employee id="3"><name>Fred</name></employee> +
<employee id="4"><name>Carol</name></employee>;
TEST(2, correct, e);
// XML +=
var x1 = new XML("<a><b><c>A0</c><d>A1</d></b><b><c>B0</c><d>B1</d></b><b><c>C0</c><d>C1</d></b></a>");
x1.b[1] += new XML("<b><c>D0</c><d>D1</d></b>");
var y1 = new XML("<a><b><c>A0</c><d>A1</d></b><b><c>B0</c><d>B1</d></b><b><c>D0</c><d>D1</d></b><b><c>C0</c><d>C1</d></b></a>");
Assert.expectEq( "XML += :", true, (x1==y1) );
// XMLList +=
x1 = new XMLList("<a><b>A0</b><c>A1</c></a><a><b>B0</b><c>B1</c></a><a><b>C0</b><c>C1</c></a>");
x1 += new XML("<a><b>D0</b><c>D1</c></a>");
y1 = new XMLList("<a><b>A0</b><c>A1</c></a><a><b>B0</b><c>B1</c></a><a><b>C0</b><c>C1</c></a><a><b>D0</b><c>D1</c></a>");
Assert.expectEq( "XMLList += :", true, (x1==y1) );
// XMLList +=, last item in XMLList is XML object with non-null parent
x1 = new XML("<a><b><c>A0</c><d>A1</d></b><b><c>B0</c><d>B1</d></b><b><c>C0</c><d>C1</d></b></a>");
x1 += new XMLList("<b><c>D0</c></b><b><c>E0</c></b>");
y1 = new XMLList("<a><b><c>A0</c><d>A1</d></b><b><c>B0</c><d>B1</d></b><b><c>C0</c><d>C1</d></b></a><b><c>D0</c></b><b><c>E0</c></b>");
Assert.expectEq( "XMLList += :", true, (x1==y1) );
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,5 @@
1 PASSED!
2 PASSED!
XML += : PASSED!
XMLList += : PASSED!
XMLList += : PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

View File

@ -0,0 +1,149 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package {
public class Test {}
}
import com.adobe.test.Assert;
import com.adobe.test.Utils;
function START(summary)
{
// print out bugnumber
/*if ( BUGNUMBER ) {
writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
}*/
XML.setSettings (null);
testcases = new Array();
// text field for results
tc = 0;
/*this.addChild ( tf );
tf.x = 30;
tf.y = 50;
tf.width = 200;
tf.height = 400;*/
//_print(summary);
var summaryParts = summary.split(" ");
//_print("section: " + summaryParts[0] + "!");
//fileName = summaryParts[0];
}
function TEST(section, expected, actual)
{
AddTestCase(section, expected, actual);
}
function TEST_XML(section, expected, actual)
{
var actual_t = typeof actual;
var expected_t = typeof expected;
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure ("", 'Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string');
}
}
function reportFailure (section, msg)
{
trace("~FAILURE: " + section + " | " + msg);
}
function AddTestCase( description, expect, actual ) {
testcases[tc++] = Assert.expectEq(description, "|"+expect+"|", "|"+actual+"|" );
}
function myGetNamespace (obj, ns) {
if (ns != undefined) {
return obj.namespace(ns);
} else {
return obj.namespace();
}
}
function NL()
{
//return java.lang.System.getProperty("line.separator");
return "\n";
}
function BUG(arg){
// nothing here
}
function END()
{
//test();
}
START("11.1.2 Qualified Identifiers - XML bad QName error");
var expected, result, expectedStr;
expectedStr = "TypeError: Error #1084: Element or attribute (\":x\") do not match QName production: QName::=(NCName':')?NCName";
expected = "Error #1084";
result = "error, exception not thrown";
namespace ns="http://www.foo.com";
var x1 = new XML("<x xmlns='http://www.foo.com'><a>foo</a></x>");
try{
x1 = new XML("<:x>hi</x>");
throw "kXMLBadQname error not thrown";
} catch( e1 ){
result = Utils.grabError(e1, e1.toString());
}
Assert.expectEq("<:x>hi</x>", expected, result);
expectedStr = "TypeError: Error #1084: Element or attribute (\":ns\") do not match QName production: QName::=(NCName':')?NCName";
expected = "Error #1084";
try{
x1 = new XML("<x :ns='attr'>hi</x>");
throw "kXMLBadQname error not thrown";
} catch( e2 ){
result = Utils.grabError(e2, e2.toString());
}
Assert.expectEq("<x :ns='attr'>hi</x>", expected, result);
END();

View File

@ -0,0 +1,13 @@
<flex-config>
<compiler>
<source-path>
<path-element>.</path-element>
<path-element>../../../lib</path-element>
</source-path>
<debug>false</debug>
<omit-trace-statements>false</omit-trace-statements>
<show-actionscript-warnings>false</show-actionscript-warnings>
<strict>false</strict>
</compiler>
<output>test.swf</output>
</flex-config>

View File

@ -0,0 +1,4 @@
Asserting for TypeError PASSED!
<:x>hi</x> PASSED!
Asserting for TypeError PASSED!
<x :ns='attr'>hi</x> PASSED!

View File

@ -0,0 +1,2 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351