Test suite for E4X from AgileDelta Inc, http://agiledelta.com/ : see bug 251113

This commit is contained in:
igor%mir2.org 2004-10-13 21:35:32 +00:00
Родитель 0055b6207b
Коммит 7abc4eb855
127 изменённых файлов: 9784 добавлений и 11 удалений

Просмотреть файл

@ -0,0 +1,78 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("11.1.1 - Attribute Identifiers");
x =
<alpha>
<bravo attr1="value1" ns:attr1="value3" xmlns:ns="http://someuri">
<charlie attr1="value2" ns:attr1="value4"/>
</bravo>
</alpha>
TEST_XML(1, "value1", x.bravo.@attr1);
TEST_XML(2, "value2", x.bravo.charlie.@attr1);
correct = new XMLList();
correct += new XML("value1");
correct += new XML("value2");
TEST(3, correct, x..@attr1);
n = new Namespace("http://someuri");
TEST_XML(4, "value3", x.bravo.@n::attr1);
TEST_XML(5, "value4", x.bravo.charlie.@n::attr1);
correct = new XMLList();
correct += new XML("value3");
correct += new XML("value4");
TEST(6, correct, x..@n::attr1);
q = new QName(n, "attr1");
TEST(7, correct, x..@[q]);
correct = new XMLList();
correct += new XML("value1");
correct += new XML("value3");
correct += new XML("value2");
correct += new XML("value4");
TEST(8, correct, x..@*::attr1);
TEST_XML(9, "value1", x.bravo.@["attr1"]);
TEST_XML(10, "value3", x.bravo.@n::["attr1"]);
TEST_XML(11, "value3", x.bravo.@[q]);
END();

Просмотреть файл

@ -0,0 +1,79 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("11.1.2 - Qualified Identifiers");
x =
<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 = x.@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 = x.soap::Body;
TEST_XML(2, correct.toXMLString(), body);
body = x.soap::["Body"];
TEST_XML(3, correct.toXMLString(), body);
q = new QName(soap, "Body");
body = x[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>;
x.soap::Body.stock::getLastTradePrice.symbol = "MYCO";
TEST_XML(5, correct.toXMLString(), x.soap::Body.stock::getLastTradePrice.symbol);
END();

Просмотреть файл

@ -0,0 +1,49 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("11.1.3 - Wildcard Identifiers");
x =
<alpha>
<bravo>one</bravo>
<charlie>two</charlie>
</alpha>
correct = <><bravo>one</bravo><charlie>two</charlie></>;
TEST(1, correct, x.*);
END();

Просмотреть файл

@ -0,0 +1,133 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("11.1.4 - XML Initializer");
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";
x = <{tagName} {attributeName}={attributeValue}>{content}</{tagName}>;
TEST(14, "<name id=\"5\">Fred</name>", x.toXMLString());
// Test {} on XML and XMLList types
x =
<rectangle>
<length>30</length>
<width>50</width>
</rectangle>;
correct =
<rectangle>
<width>50</width>
<length>30</length>
</rectangle>;
x = <rectangle>{x.width}{x.length}</rectangle>;
TEST(15, correct, x);
var content = "<foo name=\"value\">bar</foo>";
x = <x><a>{content}</a></x>;
correct = <x/>;
correct.a = content;
TEST(16, correct, x);
x = <x a={content}/>;
correct = <x/>;
correct.@a = content;
TEST(17, correct, x);
a = 5;
b = 3;
c = "x";
x = <{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>", x.toXMLString());
x = <{c} a={a + " > " + b + " is " + (a > b)}>{a + " > " + b + " is " + (a > b)}</{c}>;
TEST(19, "<x a=\"5 > 3 is true\">5 > 3 is true</x>", x.toXMLString());
END();

Просмотреть файл

@ -0,0 +1,55 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("11.1.5 - XMLList Initializer");
docfrag = <><name>Phil</name><age>35</age><hobby>skiing</hobby></>;
TEST(1, "xml", typeof(docfrag));
correct = <name>Phil</name>;
TEST(2, correct, docfrag[0]);
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);
END();

Просмотреть файл

@ -0,0 +1,166 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("11.2.1 - Property Accessors");
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]);
END();

Просмотреть файл

@ -0,0 +1,99 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("11.2.2 - Function Calls");
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);
// Test method name/element name conflicts
x =
<alpha>
<name>Foo</name>
<length>Bar</length>
</alpha>;
TEST(10, <name>Foo</name>, x.name);
TEST(11, QName("alpha"), x.name());
TEST(12, <length>Bar</length>, x.length);
TEST(13, 1, x.length());
TEST(14, x, x.(name == "Foo"));
x.name = "foobar";
TEST(15, <name>foobar</name>, x.name);
TEST(16, QName("alpha"), x.name());
END();

Просмотреть файл

@ -0,0 +1,54 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("11.2.3 - XML Descendant Accessor");
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);
END();

Просмотреть файл

@ -0,0 +1,110 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("11.2.4 - XML Filtering Predicate Operator");
e = <employees>
<employee id="0"><name>John</name><age>20</age></employee>
<employee id="1"><name>Sue</name><age>30</age></employee>
</employees>;
correct = <employee id="0"><name>John</name><age>20</age></employee>;
john = e.employee.(name == "John");
TEST(1, correct, john);
john = e.employee.(name == "John");
TEST(2, correct, john);
correct =
<employee id="0"><name>John</name><age>20</age></employee> +
<employee id="1"><name>Sue</name><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 (var p in e..employee)
{
if (p.@id == 0 || p.@id == 1)
{
twoEmployees += p;
}
}
TEST(5, correct, twoEmployees);
i = 0;
twoEmployees = new XMLList();
for each (var 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"><name>John</name><age>20</age></employee>
<employee id="1"><name>Sue</name><age>30</age></employee>
</employees>;
correct =
<employee id="0"><name>John</name><age>20</age></employee> +
<employee id="1"><name>Sue</name><age>30</age></employee>;
i = 0;
twoEmployees = new XMLList();
for each (var p in e..employee)
{
with (p)
{
if (@id == 0 || @id == 1)
{
twoEmployees[i++] = p;
}
}
}
TEST(7, correct, twoEmployees);
END();

Просмотреть файл

@ -0,0 +1,265 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
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);
default xml namespace = "http://someuri";
x = <x/>;
x.a.b = "foo";
delete x.a.b;
TEST_XML(10, "", x.a.b);
var ns = new Namespace("");
x.a.b = <b xmlns="">foo</b>;
delete x.a.b;
TEST(11, "foo", x.a.ns::b.toString());
delete x.a.ns::b;
TEST_XML(12, "", x.a.ns::b);
END();

Просмотреть файл

@ -0,0 +1,45 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("11.3.2 - Typeof Operator");
x = new XML();
TEST(1, "xml", typeof(x));
x = new XMLList();
TEST(2, "xml", typeof(x));
END();

Просмотреть файл

@ -0,0 +1,132 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
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 = Number(order.item[1].price) + Number(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);
END();

Просмотреть файл

@ -0,0 +1,94 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("11.5.1 - Equality Operators");
x = <alpha>one</alpha>;
y = <alpha>one</alpha>;
TEST(1, true, (x == y) && (y == x));
// Should return false if comparison is not XML
y = "<alpha>one</alpha>";
TEST(2, false, (x == y) || (y == x));
y = undefined
TEST(3, false, (x == y) || (y == x));
y = null
TEST(4, false, (x == y) || (y == x));
// Should check logical equiv.
x = <alpha attr1="value1">one<bravo attr2="value2">two</bravo></alpha>;
y = <alpha attr1="value1">one<bravo attr2="value2">two</bravo></alpha>;
TEST(5, true, (x == y) && (y == x));
y = <alpha attr1="new value">one<bravo attr2="value2">two</bravo></alpha>;
TEST(6, false, (x == y) || (y == x));
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);
END();

Просмотреть файл

@ -0,0 +1,422 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
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, 1234, 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>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);
END();

Просмотреть файл

@ -0,0 +1,319 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
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);
END();

Просмотреть файл

@ -0,0 +1,112 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
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);
END();

Просмотреть файл

@ -0,0 +1,61 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.2.1 - Namespace Constructor as Function");
n = Namespace();
m = new Namespace();
TEST(1, typeof(m), typeof(n));
TEST(2, m.prefix, n.prefix);
TEST(3, m.uri, n.uri);
n = Namespace("http://foobar/");
m = new Namespace("http://foobar/");
TEST(4, typeof(m), typeof(n));
TEST(5, m.prefix, n.prefix);
TEST(6, m.uri, n.uri);
n = Namespace("foobar", "http://foobar/");
m = new Namespace("foobar", "http://foobar/");
TEST(7, typeof(m), typeof(n));
TEST(8, m.prefix, n.prefix);
TEST(9, m.uri, n.uri);
n = Namespace(m);
TEST(10, m, n);
END();

Просмотреть файл

@ -0,0 +1,79 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.2.2 - Namespace Constructor");
n = new Namespace();
TEST(1, "object", typeof(n));
TEST(2, "", n.prefix);
TEST(3, "", n.uri);
n = new Namespace("");
TEST(4, "object", typeof(n));
TEST(5, "", n.prefix);
TEST(6, "", n.uri);
n = new Namespace("http://foobar/");
TEST(7, "object", typeof(n));
TEST(8, "undefined", typeof(n.prefix));
TEST(9, "http://foobar/", n.uri);
// Check if the undefined prefix is getting set properly
m = new Namespace(n);
TEST(10, typeof(n), typeof(m));
TEST(11, n.prefix, m.prefix);
TEST(12, n.uri, m.uri);
n = new Namespace("foobar", "http://foobar/");
TEST(13, "object", typeof(n));
TEST(14, "foobar", n.prefix);
TEST(15, "http://foobar/", n.uri);
// Check if all the properties are getting copied
m = new Namespace(n);
TEST(16, typeof(n), typeof(m));
TEST(17, n.prefix, m.prefix);
TEST(18, n.uri, m.uri);
try {
n = new Namespace("ns", "");
SHOULD_THROW(19);
} catch(ex) {
TEST(19, "TypeError", ex.name);
}
END();

Просмотреть файл

@ -0,0 +1,60 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.2.5 - Properties of Namespace Instances");
n = new Namespace("ns", "http://someuri");
TEST(1, true, n.hasOwnProperty("prefix"));
TEST(2, true, n.hasOwnProperty("uri"));
TEST(3, true, n.propertyIsEnumerable("prefix"));
TEST(4, true, n.propertyIsEnumerable("uri"));
var prefixCount = 0;
var uriCount = 0;
var p;
for(p in n)
{
if(p == "prefix") prefixCount++;
if(p == "uri") uriCount++;
}
TEST(5, 1, prefixCount);
TEST(6, 1, uriCount);
TEST(7, "ns", n.prefix);
TEST(8, "http://someuri", n.uri);
END();

Просмотреть файл

@ -0,0 +1,68 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.3.1 - QName Constructor as a Function");
q = QName("foobar");
p = new QName("foobar");
TEST(1, typeof(p), typeof(q));
TEST(2, p.localName, q.localName);
TEST(3, p.uri, q.uri);
q = QName("http://foobar/", "foobar");
p = new QName("http://foobar/", "foobar");
TEST(4, typeof(p), typeof(q));
TEST(5, p.localName, q.localName);
TEST(6, p.uri, q.uri);
p1 = QName(q);
p2 = new QName(q);
TEST(7, typeof(p2), typeof(p1));
TEST(8, p2.localName, p1.localName);
TEST(9, p2.uri, p1.uri);
n = new Namespace("http://foobar/");
q = QName(n, "foobar");
p = QName(n, "foobar");
TEST(10, typeof(p), typeof(q));
TEST(11, p.localName, q.localName);
TEST(12, p.uri, q.uri);
p = QName(q);
TEST(13, p, q);
END();

Просмотреть файл

@ -0,0 +1,80 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.3.2 - QName Constructor");
q = new QName("*");
TEST(1, "object", typeof(q));
TEST(2, "*", q.localName);
TEST(3, null, q.uri);
TEST(4, "*::*", q.toString());
// Default namespace
q = new QName("foobar");
TEST(5, "object", typeof(q));
TEST(6, "foobar", q.localName);
TEST(7, "", q.uri);
TEST(8, "foobar", q.toString());
q = new QName("http://foobar/", "foobar");
TEST(9, "object", typeof(q));
TEST(10, "foobar", q.localName);
TEST(11, "http://foobar/", q.uri);
TEST(12, "http://foobar/::foobar", q.toString());
p = new QName(q);
TEST(13, typeof(p), typeof(q));
TEST(14, q.localName, p.localName);
TEST(15, q.uri, p.uri);
n = new Namespace("http://foobar/");
q = new QName(n, "foobar");
TEST(16, "object", typeof(q));
q = new QName(null);
TEST(17, "object", typeof(q));
TEST(18, "null", q.localName);
TEST(19, "", q.uri);
TEST(20, "null", q.toString());
q = new QName(null, null);
TEST(21, "object", typeof(q));
TEST(22, "null", q.localName);
TEST(23, null, q.uri);
TEST(24, "*::null", q.toString());
END();

Просмотреть файл

@ -0,0 +1,60 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.3.5 - Properties of QName Instances");
q = new QName("http://someuri", "foo");
TEST(1, true, q.hasOwnProperty("localName"));
TEST(2, true, q.hasOwnProperty("uri"));
TEST(3, true, q.propertyIsEnumerable("localName"));
TEST(4, true, q.propertyIsEnumerable("uri"));
var localNameCount = 0;
var uriCount = 0;
var p;
for(p in q)
{
if(p == "localName") localNameCount++;
if(p == "uri") uriCount++;
}
TEST(5, 1, localNameCount);
TEST(6, 1, uriCount);
TEST(7, "http://someuri", q.uri);
TEST(8, "foo", q.localName);
END();

Просмотреть файл

@ -0,0 +1,127 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("12.1 - Default XML Namespace");
// Declare some namespaces ad a default namespace for the current block
var soap = new Namespace("http://schemas.xmlsoap.org/soap/envelope/");
var stock = new Namespace("http://mycompany.com/stocks");
default xml namespace = soap;
// Create an XML initializer in the default (i.e., soap) namespace
message =
<Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<Body>
<stock:GetLastTradePrice xmlns:stock="http://mycompany.com/stocks">
<stock:symbol>DIS</stock:symbol>
</stock:GetLastTradePrice>
</Body>
</Envelope>;
// Extract the soap encoding style using a QualifiedIdentifier
encodingStyle = message.@soap::encodingStyle;
TEST_XML(1, "http://schemas.xmlsoap.org/soap/encoding/", encodingStyle);
// Extract the body from the soap message using the default namespace
correct =
<Body
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<stock:GetLastTradePrice xmlns:stock="http://mycompany.com/stocks">
<stock:symbol>DIS</stock:symbol>
</stock:GetLastTradePrice>
</Body>;
body = message.Body;
TEST_XML(2, correct.toXMLString(), body);
// Change the stock symbol using the default namespace and qualified names
correct =
<Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<Body>
<stock:GetLastTradePrice xmlns:stock="http://mycompany.com/stocks">
<stock:symbol>MYCO</stock:symbol>
</stock:GetLastTradePrice>
</Body>
</Envelope>;
message.Body.stock::GetLastTradePrice.stock::symbol = "MYCO";
TEST(3, correct, message);
function scopeTest()
{
var x = <a/>;
TEST(4, soap.uri, x.namespace().uri);
default xml namespace = "http://" + "someuri.org";
x = <a/>;
TEST(5, "http://someuri.org", x.namespace().uri);
}
scopeTest();
x = <a><b><c xmlns="">foo</c></b></a>;
TEST(6, soap.uri, x.namespace().uri);
TEST(7, soap.uri, x.b.namespace().uri);
ns = new Namespace("");
TEST(8, "foo", x.b.ns::c.toString());
x = <a foo="bar"/>;
TEST(9, soap.uri, x.namespace().uri);
TEST(10, "", x.@foo.namespace().uri);
TEST_XML(11, "bar", x.@foo);
default xml namespace = "";
x = <x/>;
ns = new Namespace("http://someuri");
default xml namespace = ns;
x.a = "foo";
TEST(12, "foo", x["a"].toString());
q = new QName("a");
TEST(13, "foo", x[q].toString());
default xml namespace = "";
x[q] = "bar";
TEST(14, "bar", x.ns::a.toString());
END();

Просмотреть файл

@ -0,0 +1,97 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("12.2 - For-in statement");
// All the employee names
e =
<employees>
<employee id="1">
<name>Joe</name>
<age>20</age>
</employee>
<employee id="2">
<name>Sue</name>
<age>30</age>
</employee>
</employees>;
correct = new Array("Joe", "Sue", "Big Screen Television", "1299.99");
i = 0;
for (var n in e..name)
{
TEST("1."+i, String(i), n);
i++;
}
TEST("1.count", 2, i);
// Each child of the first item
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>;
i = 0;
for (var child in order.item)
{
TEST("2."+i, String(i), child);
i++
}
TEST("2.count", 2, i);
i = 0;
for (var child in order.item[0].*)
{
TEST("3."+i, String(i), child);
i++
}
TEST("3.count", 2, i);
END();

Просмотреть файл

@ -0,0 +1,63 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("10.1.1 - XML.toString");
order =
<order>
<customer>
<firstname>John</firstname>
<lastname>Doe</lastname>
</customer>
<item>
<description>Big Screen Television</description>
<price>1299.99</price>
<quantity>1</quantity>
</item>
</order>;
name = order.customer.firstname + " " + order.customer.lastname;
TEST(1, "John Doe", name);
total = order.item.price * order.item.quantity;
TEST(2, 1299.99, total);
END();

Просмотреть файл

@ -0,0 +1,41 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("10.1.2 - XMLList.toString");
END();

Просмотреть файл

@ -0,0 +1,41 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("10.2.1 - XML.toXMLString");
END();

Просмотреть файл

@ -0,0 +1,53 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("10.3.1 - toXML applied to String type");
john = "<employee><name>John</name><age>25</age></employee>";
sue = "<employee><name>Sue</name><age>32</age></employee>";
tagName = "employees";
employees = new XML("<" + tagName + ">" + john + sue + "</" + tagName + ">");
correct =
<employees>
<employee><name>John</name><age>25</age></employee>
<employee><name>Sue</name><age>32</age></employee>
</employees>;
TEST(1, correct, employees);
END();

Просмотреть файл

@ -0,0 +1,70 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("10.3 - toXML");
var x;
// boolean
x = new Boolean(true);
TEST_XML(1, "true", new XML(x));
// number
x = new Number(123);
TEST_XML(2, "123", new XML(x));
// String
x = new String("<alpha><bravo>one</bravo></alpha>");
TEST(3, <alpha><bravo>one</bravo></alpha>, new XML(x));
// XML
x = new XML(<alpha><bravo>one</bravo></alpha>);
TEST(4, <alpha><bravo>one</bravo></alpha>, new XML(x));
// XMLList
x = new XMLList(<alpha><bravo>one</bravo></alpha>);
TEST(5, <alpha><bravo>one</bravo></alpha>, new XML(x));
try {
x = new XMLList(<alpha>one</alpha> + <bravo>two</bravo>);
new XML(x);
SHOULD_THROW(6);
} catch (ex) {
TEST(6, "TypeError", ex.name);
}
END();

Просмотреть файл

@ -0,0 +1,88 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("10.4.1 - toXMLList Applied to String type");
var x, y, correct;
x =
<>
<alpha>one</alpha>
<bravo>two</bravo>
</>;
TEST(1, "xml", typeof(x));
TEST(2, "<alpha>one</alpha>" + NL() + "<bravo>two</bravo>", x.toXMLString());
// Load from another XMLList
// Make sure it is copied if it's an XMLList
y = new XMLList(x);
x += <charlie>three</charlie>;
TEST(3, "<alpha>one</alpha>" + NL() + "<bravo>two</bravo>", y.toXMLString());
// Load from one XML type
x = new XMLList(<alpha>one</alpha>);
TEST(4, "<alpha>one</alpha>", x.toXMLString());
// Load from Anonymous
x = new XMLList(<><alpha>one</alpha><bravo>two</bravo></>);
TEST(5, "<alpha>one</alpha>" + NL() + "<bravo>two</bravo>", x.toXMLString());
// Load from Anonymous as string
x = new XMLList("<alpha>one</alpha><bravo>two</bravo>");
TEST(6, "<alpha>one</alpha>" + NL() + "<bravo>two</bravo>", x.toXMLString());
// Load from illegal type
//x = new XMLList("foobar");
//ADD(7, "", x);
John = "<employee><name>John</name><age>25</age></employee>";
Sue = "<employee><name>Sue</name><age>32</age></employee>";
correct =
<>
<employee><name>John</name><age>25</age></employee>
<employee><name>Sue</name><age>32</age></employee>
</>;
var1 = new XMLList(John + Sue);
TEST(8, correct, var1);
END();

Просмотреть файл

@ -0,0 +1,78 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("10.4 - toXMLList");
var x;
// null
try {
x = null;
x.toString();
SHOULD_THROW(1);
} catch (ex) {
TEST(1, "TypeError", ex.name);
}
// number
x = new Number(123);
TEST(2, "123", new XMLList(x).toXMLString());
// String
x = new String("<alpha><bravo>one</bravo></alpha>");
TEST(3, <alpha><bravo>one</bravo></alpha>, new XMLList(x));
x = new String("<alpha>one</alpha><charlie>two</charlie>");
TEST(4, "<alpha>one</alpha>" + NL() + "<charlie>two</charlie>",
new XMLList(x).toXMLString());
// XML
x = new XML(<alpha><bravo>one</bravo></alpha>);
TEST(5, <alpha><bravo>one</bravo></alpha>, new XMLList(x));
x = new XML(<root><alpha><bravo>one</bravo></alpha><charlie>two</charlie></root>);
TEST(6, <alpha><bravo>one</bravo></alpha>, new XMLList(x.alpha));
// XMLList
x = new XMLList(<alpha><bravo>one</bravo></alpha>);
TEST(7, <alpha><bravo>one</bravo></alpha>, new XMLList(x));
x = new XMLList(<><alpha>one</alpha><bravo>two</bravo></>);
TEST(8, "<alpha>one</alpha>" + NL() + "<bravo>two</bravo>",
new XMLList(x).toXMLString());
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("10.5.1 - ToAttributeName applied to the String type");
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("10.5 ToAttributeName");
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("10.6.1 - ToXMLName applied to the String type");
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("10.6 - ToXMLName");
END();

Просмотреть файл

@ -0,0 +1,297 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START('9.1.1.1 XML [[Get]]');
var x =
<alpha attr1="value1" attr2="value2">
<bravo>
one
<charlie>two</charlie>
</bravo>
</alpha>;
// .
TEST(1, <bravo>one<charlie>two</charlie></bravo>, x.bravo);
TEST(2, <charlie>two</charlie>, x.bravo.charlie);
TEST(3, <charlie>two</charlie>, x.bravo.charlie.parent().charlie);
// .*
var correct = <>one<charlie>two</charlie></>;
TEST(4, correct, x.bravo.*);
TEST_XML(5, "two", x.bravo.charlie.*);
TEST(6, <bravo>one<charlie>two</charlie></bravo>, x.*[0]);
// .@
TEST_XML(7, "value1", x.@attr1);
TEST_XML(8, "value2", x.@attr2);
// ..
TEST(9, <bravo>one<charlie>two</charlie></bravo>, x..bravo);
TEST(10, <charlie>two</charlie>, x..charlie);
// .@*
correct = new XMLList();
correct += new XML("value1");
correct += new XML("value2");
TEST(11, correct, x.@*);
x =
<alpha attr1="value1" attr2="value2">
<bravo>
one
<charlie>two</charlie>
</bravo>
</alpha>;
// ..*
XML.prettyPrinting = false;
correct = <><bravo>one<charlie>two</charlie></bravo>one<charlie>two</charlie>two</>;
TEST(12, correct, x..*);
XML.prettyPrinting = true;
x =
<alpha attr1="value1" attr2="value2">
<bravo attr3="value3">
one
<charlie attr3="value4">two</charlie>
</bravo>
</alpha>;
// ..@
correct = new XMLList();
correct += new XML("value3");
correct += new XML("value4");
TEST(13, correct, x..@attr3)
// ..@*
correct = new XMLList();
correct += new XML("value1");
correct += new XML("value2");
correct += new XML("value3");
correct += new XML("value4");
TEST(14, correct, x..@*);
// Check reserved words
x =
<alpha>
<prototype>one</prototype>
</alpha>;
TEST(15, <prototype>one</prototype>, x.prototype);
// Check method names
x =
<alpha>
<name>one</name>
<toString>two</toString>
</alpha>;
TEST(16, <name>one</name>, x.name);
TEST(17, QName("alpha"), x.name());
TEST(18, <toString>two</toString>, x.toString);
TEST(19, x.toXMLString(), x.toString());
// Test super-expandos
x =
<alpha>
<bravo>one</bravo>
</alpha>;
correct =
<alpha>
<bravo>
one
<charlie>
<delta>two</delta>
</charlie>
</bravo>
</alpha>;
x.bravo.charlie.delta = <delta>two</delta>;
TEST(20, correct, x);
x =
<alpha>
<bravo>one</bravo>
</alpha>;
correct =
<alpha>
<bravo>
one
<charlie>
<delta>two</delta>
</charlie>
</bravo>
</alpha>;
x.bravo.charlie.delta = "two";
TEST(21, correct, x);
x =
<alpha>
<bravo>one</bravo>
</alpha>;
correct =
<alpha>
<bravo>
one
<charlie>
<echo>two</echo>
</charlie>
</bravo>
</alpha>;
x.bravo.charlie.delta = <echo>two</echo>;
TEST(22, correct, x);
// Also ADD with *, children() and child()
x =
<alpha>
<bravo>one</bravo>
</alpha>;
correct =
<alpha>
<bravo>
one
<charlie>
<delta>two</delta>
</charlie>
</bravo>
</alpha>;
x.*.charlie.delta = <delta>two</delta>;
TEST(23, correct, x);
x =
<alpha>
<bravo>one</bravo>
</alpha>;
correct =
<alpha>
<bravo>
one
<charlie>
<delta>two</delta>
</charlie>
</bravo>
</alpha>;
x.children().charlie.delta = <delta>two</delta>;
TEST(24, correct, x);
x =
<alpha>
<bravo>one</bravo>
</alpha>;
correct =
<alpha>
<bravo>
one
<charlie>
<delta>two</delta>
</charlie>
</bravo>
</alpha>;
x.child("bravo").charlie.delta = <delta>two</delta>;
TEST(25, correct, x);
x =
<alpha>
<bravo>one</bravo>
</alpha>;
correct =
<alpha>
<bravo>one</bravo>
<newChild>
<charlie>
<delta>two</delta>
</charlie>
</newChild>
</alpha>;
x.child("newChild").charlie.delta = <delta>two</delta>;
TEST(26, correct, x);
// These should fail because the XMLList is size > 1
x =
<alpha>
<bravo>one</bravo>
<bravo>two</bravo>
</alpha>;
try {
x.*.charlie.delta = "more";
SHOULD_THROW(27);
} catch (ex) {
TEST(27, "TypeError", ex.name);
}
x =
<alpha>
<bravo>one</bravo>
<bravo>two</bravo>
</alpha>;
try {
x.children().charlie.delta = "more";
SHOULD_THROW(28);
} catch (ex) {
TEST(28, "TypeError", ex.name);
}
x =
<alpha>
<bravo>one</bravo>
<bravo>two</bravo>
</alpha>;
try {
x.child("bravo").charlie.delta = "more";
SHOULD_THROW(29);
} catch (ex) {
TEST(29, "TypeError", ex.name);
}
END();

Просмотреть файл

@ -0,0 +1,43 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.1.1.10 - XML [[ResolveValue]]");
// !FIX
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.1.1.11 - XML [[Insert]]");
END();

Просмотреть файл

@ -0,0 +1,40 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.1.1.12 - XML [[Replace]]");
END();

Просмотреть файл

@ -0,0 +1,41 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.1.1.13 - XML Type [[AddInScopeNamespace]]");
END();

Просмотреть файл

@ -0,0 +1,63 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START('9.1.1.2 - XML [[Put]]');
// .
var x =
<alpha attr1="value1" attr2="value2">
<bravo>
one
<charlie>two</charlie>
</bravo>
</alpha>;
var correct =
<charlie>new</charlie>;
x.bravo.charlie = "new"
TEST(1, correct, x.bravo.charlie)
x.bravo = <delta>three</delta>
TEST(2, "three", x.delta.toString())
// .@
x = <alpha attr1="value1" attr2="value2"><bravo>one<charlie>two</charlie></bravo></alpha>
x.@attr1 = "newValue"
TEST_XML(3, "newValue", x.@attr1)
END();

Просмотреть файл

@ -0,0 +1,91 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.1.1.3 - XML [[Delete]]");
// .@
x =
<alpha attr1="value1">one</alpha>;
delete x.@attr1;
TEST_XML(1, "", x.@attr1);
TEST(2, <alpha>one</alpha>, x);
// ..@
x =
<alpha attr1="value1">
one
<bravo attr2="value2">
two
<charlie attr3="value3">three</charlie>
</bravo>
</alpha>;
correct =
<alpha attr1="value1">
one
<bravo attr2="value2">
two
<charlie>three</charlie>
</bravo>
</alpha>;
delete x..@attr3;
TEST(3, correct, x);
// ..@*
x =
<alpha attr1="value1">
one
<bravo attr2="value2">
two
<charlie attr3="value3">three</charlie>
</bravo>
</alpha>;
correct =
<alpha>
one
<bravo>
two
<charlie>three</charlie>
</bravo>
</alpha>;
delete x..@*;
TEST(4, correct, x);
END();

Просмотреть файл

@ -0,0 +1,38 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.1.1.4 - XML [[DeleteByIndex]]");
END();

Просмотреть файл

@ -0,0 +1,41 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
// XML Type [[Default Value]]
START("9.1.1.5 - XML [[Default Value]]");
END();

Просмотреть файл

@ -0,0 +1,52 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.1.1.6 - XML [[HasProperty]]");
x = <alpha attr1="value1">one<bravo>two<charlie>three</charlie></bravo></alpha>;
TEST(1, true, "bravo" in x);
TEST(2, true, 0 in x);
TEST(3, true, "charlie" in x.bravo);
TEST(4, true, 0 in x.bravo);
TEST(5, false, 1 in x);
TEST(6, false, 1 in x.bravo);
TEST(7, false, 2 in x);
TEST(8, false, 2 in x.bravo);
TEST(9, false, "foobar" in x);
TEST(10, false, "foobar" in x.bravo);
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.1.1.7 - XML [[DeepCopy]]");
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
// XML Type [[Descendants]]
START("9.1.1.8 - XML [[Descendants]]");
END();

Просмотреть файл

@ -0,0 +1,127 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.1.1.9 - XML [[Equals]]");
x = <alpha>one</alpha>;
y = <alpha>one</alpha>;
TEST(1, true, (x == y) && (y == x));
// Should return false if comparison is not XML
y = "<alpha>one</alpha>";
TEST(2, false, (x == y) || (y == x));
y = undefined
TEST(3, false, (x == y) || (y == x));
y = null
TEST(4, false, (x == y) || (y == x));
y = new Object();
TEST(5, false, (x == y) || (y == x));
// Check with attributes
x = <alpha attr1="value1">one<bravo attr2="value2">two</bravo></alpha>;
y = <alpha attr1="value1">one<bravo attr2="value2">two</bravo></alpha>;
TEST(6, true, (x == y) && (y == x));
y = <alpha attr1="new value">one<bravo attr2="value2">two</bravo></alpha>;
TEST(7, false, (x == y) || (y == x));
// Logical equality
// Attribute order.
x = <alpha attr1="value1" attr2="value2">one<bravo attr3="value3" attr4="value4">two</bravo></alpha>;
y = <alpha attr2="value2" attr1="value1">one<bravo attr4="value4" attr3="value3">two</bravo></alpha>;
TEST(8, true, (x == y) && (y == x));
// Skips empty text nodes
XML.ignoreWhitespace = false;
x = <alpha> <bravo>one</bravo> </alpha>;
y = <alpha><bravo>one</bravo></alpha>;
TEST(9, true, (x == y) && (y == x));
// Doesn't trim text nodes.
x = <alpha><bravo> one </bravo></alpha>;
y = <alpha><bravo>one</bravo></alpha>;
TEST(10, false, (x == y) || (y == x));
// Compare comments
XML.ignoreComments = false;
x = <alpha><!-- comment1 --><bravo><!-- comment2 -->one</bravo></alpha>;
y = <alpha><!-- comment2 --><bravo><!-- comment1 -->one</bravo></alpha>;
TEST(11, false, (x == y) || (y == x));
one = x.*[0];
two = y.*[0];
TEST(12, false, (one == two) || (two == one));
one = x.*[0];
two = y.bravo.*[0];
TEST(13, true, (one == two) && (two == one));
// Compare processing instructions
XML.ignoreProcessingInstructions = false;
x = <alpha><?one foo="bar" ?><bravo><?two bar="foo" ?>one</bravo></alpha>;
y = <alpha><?two bar="foo" ?><bravo><?one foo="bar" ?>one</bravo></alpha>;
TEST(14, false, (x == y) || (y == x));
one = x.*[0];
two = y.*[0];
TEST(15, false, (one == two) || (two == one));
one = x.*[0];
two = y.bravo.*[0];
TEST(16, true, (one == two) && (two == one));
// Namepaces
x = <ns1:alpha xmlns:ns1="http://foo/"><ns1:bravo>one</ns1:bravo></ns1:alpha>;
y = <ns2:alpha xmlns:ns2="http://foo/"><ns2:bravo>one</ns2:bravo></ns2:alpha>;
TEST(17, true, (x == y) && (y == x));
y = <ns2:alpha xmlns:ns2="http://foo"><ns2:bravo>one</ns2:bravo></ns2:alpha>;
TEST(18, false, (x == y) || (y == x));
// Default namespace
default xml namespace = "http://foo/";
x = <alpha xmlns="http://foo/">one</alpha>;
y = <alpha>one</alpha>;
TEST(19, true, (x == y) && (y == x));
END();

Просмотреть файл

@ -0,0 +1,157 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.2.1.1 XMLList [[Get]]");
var x =
<>
<alpha attr1="value1">
<bravo attr2="value2">
one
<charlie>two</charlie>
</bravo>
</alpha>
<alpha attr1="value3">
<bravo attr2="value4">
three
<charlie>four</charlie>
</bravo>
</alpha>
</>;
// .
correct =
<>
<bravo attr2="value2">
one
<charlie>two</charlie>
</bravo>
<bravo attr2="value4">
three
<charlie>four</charlie>
</bravo>
</>;
TEST(1, correct, x.bravo);
correct =
<>
<charlie>two</charlie>
<charlie>four</charlie>
</>;
TEST(2, correct, x.bravo.charlie);
// .@
correct = new XMLList();
correct += new XML("value1");
correct += new XML("value3");
TEST(3, correct, x.@attr1);
correct = new XMLList();
correct += new XML("value2");
correct += new XML("value4");
TEST(4, correct, x.bravo.@attr2);
// ..
correct =
<>
<bravo attr2="value2">
one
<charlie>two</charlie>
</bravo>
<bravo attr2="value4">
three
<charlie>four</charlie>
</bravo>
</>;
TEST(5, correct, x..bravo);
correct =
<>
<charlie>two</charlie>
<charlie>four</charlie>
</>;
TEST(6, correct, x..charlie);
// .@*
correct = new XMLList();
correct += new XML("value1");
correct += new XML("value3");
TEST(7, correct, x.@*);
x =
<alpha attr1="value1" attr2="value2">
<bravo>
one
<charlie>two</charlie>
</bravo>
</alpha>;
// ..*
correct = <><bravo>one<charlie>two</charlie></bravo>one<charlie>two</charlie>two</>;
XML.prettyPrinting = false;
TEST(8, correct, x..*);
XML.prettyPrinting = true;
x =
<alpha attr1="value1" attr2="value2">
<bravo attr2="value3">
one
<charlie attr3="value4">two</charlie>
</bravo>
</alpha>;
// ..@
correct = new XMLList();
correct += new XML("value2");
correct += new XML("value3");
TEST(9, correct, x..@attr2)
// ..@*
correct = new XMLList();
correct += new XML("value1");
correct += new XML("value2");
correct += new XML("value3");
correct += new XML("value4");
TEST(10, correct, x..@*);
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.2.1.10 XMLList [[ResolveValue]]");
END();

Просмотреть файл

@ -0,0 +1,57 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.2.1.2 - XMLList [[Put]]");
var x =
<>
<alpha>one</alpha>
<bravo>two</bravo>
</>;
TEST(1, "<alpha>one</alpha>" + NL() + "<bravo>two</bravo>",
x.toXMLString());
x[0] = <charlie>three</charlie>;
TEST(2, "<charlie>three</charlie>" + NL() + "<bravo>two</bravo>",
x.toXMLString());
x[0] = <delta>four</delta> + <echo>five</echo>;
TEST(3, "<delta>four</delta>" + NL() + "<echo>five</echo>" + NL() + "<bravo>two</bravo>",
x.toXMLString());
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.2.1.3 XMLList [[Delete]]");
END();

Просмотреть файл

@ -0,0 +1,41 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.2.1.4 XMLList [[DefaultValue]]");
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.2.1.5 XMLList [[HasProperty]]");
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.2.1.6 XMLList [[Append]]");
END();

Просмотреть файл

@ -0,0 +1,43 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.2.1.7 XMLList [[DeepCopy]]");
END();

Просмотреть файл

@ -0,0 +1,49 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.2.1.8 XMLList [[Descendants]]");
x =
<>
<alpha><bravo>one</bravo></alpha>
<charlie><delta><bravo>two</bravo></delta></charlie>
</>;
correct = <><bravo>one</bravo><bravo>two</bravo></>;
TEST(1, correct, x..bravo);
END();

Просмотреть файл

@ -0,0 +1,74 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("9.2.1.9 XMLList [[Equals]]");
// Empty list should equal undefined
TEST(1, true, (new XMLList() == undefined) && (undefined == new XMLList()));
// Compare two lists if all are equal
x = <alpha>one</alpha> + <bravo>two</bravo>;
y = <alpha>one</alpha> + <bravo>two</bravo>;
TEST(2, true, (x == y) && (y == x));
y = <alpha>one</alpha> + <bravo>two</bravo> + <charlie>three</charlie>;
TEST(3, false, (x == y) || (y == x));
y = <alpha>one</alpha> + <bravo>not</bravo>;
TEST(4, false, (x == y) || (y == x));
// If XMLList has one argument should compare with just the 0th element.
x = new XMLList(<alpha>one</alpha>);
y = <alpha>one</alpha>;
TEST(5, true, (x == y) && (y == x));
y = "one";
TEST(6, true, (x == y) && (y == x));
// Should return false even if list contains element equal to comparison
x = <alpha>one</alpha> + <bravo>two</bravo>;
y = <alpha>one</alpha>;
TEST(7, false, (x == y) && (y == x));
y = "<alpha>one</alpha>";
TEST(8, false, (x == y) || (y == x));
// Try other types - should return false
y = null;
TEST(9, false, (x == y) || (y == x));
y = new Object();
TEST(10, false, (x == y) || (y == x));
END();

106
js/tests/e4x/XML/13.4.1.js Normal file
Просмотреть файл

@ -0,0 +1,106 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.1 - XML Constructor as Function");
x = XML();
TEST(1, "xml", typeof(x));
TEST(2, true, x instanceof XML);
correct =
<Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:stock="http://mycompany.com/stocks"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<Body>
<stock:GetLastTradePrice>
<stock:symbol>DIS</stock:symbol>
</stock:GetLastTradePrice>
</Body>
</Envelope>;
x = XML(correct);
TEST(3, correct, x);
text =
"<Envelope" +
" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
" xmlns:stock=\"http://mycompany.com/stocks\"" +
" soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" +
" <Body>" +
" <stock:GetLastTradePrice>" +
" <stock:symbol>DIS</stock:symbol>" +
" </stock:GetLastTradePrice>" +
" </Body>" +
"</Envelope>";
x = XML(text);
TEST(4, correct, x);
// Make sure it's not copied if it's XML
x =
<alpha>
<bravo>two</bravo>
</alpha>;
y = XML(x);
x.bravo = "three";
correct =
<alpha>
<bravo>three</bravo>
</alpha>;
TEST(5, correct, y);
// Make text node
x = XML("4");
TEST_XML(6, 4, x);
x = XML(4);
TEST_XML(7, 4, x);
// Undefined and null should behave like ""
x = XML(null);
TEST_XML(8, "", x);
x = XML(undefined);
TEST_XML(9, "", x);
END();

105
js/tests/e4x/XML/13.4.2.js Normal file
Просмотреть файл

@ -0,0 +1,105 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.2 - XML Constructor");
x = new XML();
TEST(1, "xml", typeof(x));
TEST(2, true, x instanceof XML);
correct =
<Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:stock="http://mycompany.com/stocks"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<Body>
<stock:GetLastTradePrice>
<stock:symbol>DIS</stock:symbol>
</stock:GetLastTradePrice>
</Body>
</Envelope>;
x = new XML(correct);
TEST_XML(3, correct.toXMLString(), x);
text =
"<Envelope" +
" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
" xmlns:stock=\"http://mycompany.com/stocks\"" +
" soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" +
" <Body>" +
" <stock:GetLastTradePrice>" +
" <stock:symbol>DIS</stock:symbol>" +
" </stock:GetLastTradePrice>" +
" </Body>" +
"</Envelope>";
x = new XML(text);
TEST(4, correct, x);
// Make sure it's a copy
x =
<alpha>
<bravo>one</bravo>
</alpha>;
y = new XML(x);
x.bravo.prependChild(<charlie>two</charlie>);
correct =
<alpha>
<bravo>one</bravo>
</alpha>;
TEST(5, correct, y);
// Make text node
x = new XML("4");
TEST_XML(6, "4", x);
x = new XML(4);
TEST_XML(7, "4", x);
// Undefined and null should behave like ""
x = new XML(null);
TEST_XML(8, "", x);
x = new XML(undefined);
TEST_XML(9, "", x);
END();

220
js/tests/e4x/XML/13.4.3.js Normal file
Просмотреть файл

@ -0,0 +1,220 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.3 - XML Properties");
// Test defaults
TEST(1, true, XML.ignoreComments);
TEST(2, true, XML.ignoreProcessingInstructions);
TEST(3, true, XML.ignoreWhitespace);
TEST(4, true, XML.prettyPrinting);
TEST(5, 2, XML.prettyIndent);
// ignoreComments
x = <alpha><!-- comment --><bravo>one</bravo></alpha>;
correct = <alpha><bravo>one</bravo></alpha>;
TEST(6, correct, x);
XML.ignoreComments = false;
x = <alpha><!-- comment --><bravo>one</bravo></alpha>;
correct =
"<alpha>" + NL() +
" <!-- comment -->" + NL() +
" <bravo>one</bravo>" + NL() +
"</alpha>";
TEST_XML(7, correct, x);
// ignoreProcessingInstructions
XML.defaultSettings();
x =
<>
<alpha>
<?foo version="1.0" encoding="utf-8"?>
<bravo>one</bravo>
</alpha>
</>;
correct =
<alpha>
<bravo>one</bravo>
</alpha>;
TEST(8, correct, x);
XML.ignoreProcessingInstructions = false;
x =
<>
<alpha>
<?foo version="1.0" encoding="utf-8"?>
<bravo>one</bravo>
</alpha>
</>;
correct =
"<alpha>" + NL() +
" <?foo version=\"1.0\" encoding=\"utf-8\"?>" + NL() +
" <bravo>one</bravo>" + NL() +
"</alpha>";
TEST_XML(9, correct, x);
// ignoreWhitespace
XML.defaultSettings();
x = new XML("<alpha> \t\r\n\r\n<bravo> \t\r\n\r\none</bravo> \t\r\n\r\n</alpha>");
correct =
"<alpha>" + NL() +
" <bravo>one</bravo>" + NL() +
"</alpha>";
TEST_XML(10, correct, x);
XML.ignoreWhitespace = false;
XML.prettyPrinting = false;
correct = "<alpha> \n\n<bravo> \n\none</bravo> \n\n</alpha>";
x = new XML(correct);
TEST_XML(11, correct, x);
// prettyPrinting
XML.defaultSettings();
x =
<alpha>
one
<bravo>two</bravo>
<charlie/>
<delta>
three
<echo>four</echo>
</delta>
</alpha>;
correct = "<alpha>" + NL() +
" one" + NL() +
" <bravo>two</bravo>" + NL() +
" <charlie/>" + NL() +
" <delta>" + NL() +
" three" + NL() +
" <echo>four</echo>" + NL() +
" </delta>" + NL() +
"</alpha>";
TEST(12, correct, x.toString());
TEST(13, correct, x.toXMLString());
XML.prettyPrinting = false;
correct = "<alpha>one<bravo>two</bravo><charlie/><delta>three<echo>four</echo></delta></alpha>";
TEST(14, correct, x.toString());
TEST(15, correct, x.toXMLString());
// prettyIndent
XML.prettyPrinting = true;
XML.prettyIndent = 3;
correct = "<alpha>" + NL() +
" one" + NL() +
" <bravo>two</bravo>" + NL() +
" <charlie/>" + NL() +
" <delta>" + NL() +
" three" + NL() +
" <echo>four</echo>" + NL() +
" </delta>" + NL() +
"</alpha>";
TEST(16, correct, x.toString());
TEST(17, correct, x.toXMLString());
XML.prettyIndent = 0;
correct = "<alpha>" + NL() +
"one" + NL() +
"<bravo>two</bravo>" + NL() +
"<charlie/>" + NL() +
"<delta>" + NL() +
"three" + NL() +
"<echo>four</echo>" + NL() +
"</delta>" + NL() +
"</alpha>";
TEST(18, correct, x.toString());
TEST(19, correct, x.toXMLString());
// settings()
XML.defaultSettings();
o = XML.settings();
TEST(20, true, o.ignoreComments);
TEST(21, true, o.ignoreProcessingInstructions);
TEST(22, true, o.ignoreWhitespace);
TEST(23, true, o.prettyPrinting);
TEST(24, 2, o.prettyIndent);
// setSettings()
o = XML.settings();
o.ignoreComments = false;
o.ignoreProcessingInstructions = false;
o.ignoreWhitespace = false;
o.prettyPrinting = false;
o.prettyIndent = 7;
XML.setSettings(o);
o = XML.settings();
TEST(25, false, o.ignoreComments);
TEST(26, false, o.ignoreProcessingInstructions);
TEST(27, false, o.ignoreWhitespace);
TEST(28, false, o.prettyPrinting);
TEST(29, 7, o.prettyIndent);
// defaultSettings()
XML.defaultSettings();
o = XML.settings();
TEST(30, true, o.ignoreComments);
TEST(31, true, o.ignoreProcessingInstructions);
TEST(32, true, o.ignoreWhitespace);
TEST(33, true, o.prettyPrinting);
TEST(34, 2, o.prettyIndent);
END();

Просмотреть файл

@ -0,0 +1,40 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.1 - XML Constructor");
END();

Просмотреть файл

@ -0,0 +1,51 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.10 - XML contains()");
TEST(1, true, XML.prototype.hasOwnProperty("contains"));
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
TEST(2, true, emps.contains(emps));
END();

Просмотреть файл

@ -0,0 +1,84 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.11 - XML copy()");
TEST(1, true, XML.prototype.hasOwnProperty("copy"));
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
correct =
<employee id="0"><name>Jim</name><age>25</age></employee>;
x = emps.employee[0].copy();
TEST(2, undefined, x.parent());
TEST(3, correct, x);
// Make sure we're getting a copy, not a ref to orig.
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
correct =
<employee id="0"><name>Jim</name><age>25</age></employee>
empCopy = emps.employee[0].copy();
emps.employee[0].name[0] = "Sally";
TEST(4, correct, empCopy);
// Try copying whole XML twice
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
empCopy = emps.copy();
x = empCopy.copy();
TEST(5, x, emps);
END();

Просмотреть файл

@ -0,0 +1,62 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.12 - XML descendants");
TEST(1, true, XML.prototype.hasOwnProperty("descendants"));
x =
<alpha>
<bravo>one</bravo>
<charlie>
two
<bravo>three</bravo>
</charlie>
</alpha>;
TEST(2, <bravo>three</bravo>, x.charlie.descendants("bravo"));
TEST(3, <><bravo>one</bravo><bravo>three</bravo></>, x.descendants("bravo"));
// Test *
correct = <><bravo>one</bravo>one<charlie>two<bravo>three</bravo></charlie>two<bravo>three</bravo>three</>;
XML.prettyPrinting = false;
TEST(4, correct, x.descendants("*"));
TEST(5, correct, x.descendants());
XML.prettyPrinting = true;
END();

Просмотреть файл

@ -0,0 +1,42 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.14 - XML elements()");
TEST(1, true, XML.prototype.hasOwnProperty("elements"));
END();

Просмотреть файл

@ -0,0 +1,62 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.14 - XML hasOwnProperty()");
TEST(1, true, XML.prototype.hasOwnProperty("hasOwnProperty"));
x =
<alpha attr1="value1">
<bravo>one</bravo>
<charlie>
two
three
<echo>four</echo>
</charlie>
<delta />
</alpha>;
// Returns true for elements/attributes
TEST(2, true, x.hasOwnProperty("bravo"));
TEST(3, true, x.hasOwnProperty("@attr1"));
TEST(4, false, x.hasOwnProperty("foobar"));
// Test for XML Prototype Object - returns true for XML methods.
TEST(5, true, XML.prototype.hasOwnProperty("toString"));
TEST(6, false, XML.prototype.hasOwnProperty("foobar"));
END();

Просмотреть файл

@ -0,0 +1,72 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.15 - hasComplexContent()");
TEST(1, true, XML.prototype.hasOwnProperty("hasComplexContent"));
x =
<alpha attr1="value1">
<bravo>one</bravo>
<charlie>
two
three
<echo>four</echo>
</charlie>
<delta />
<foxtrot attr2="value2">five</foxtrot>
<golf attr3="value3" />
<hotel>
six
seven
</hotel>
<india><juliet /></india>
</alpha>;
TEST(2, true, x.hasComplexContent());
TEST(3, false, x.bravo.hasComplexContent());
TEST(4, true, x.charlie.hasComplexContent());
TEST(5, false, x.delta.hasComplexContent());
TEST(6, false, x.foxtrot.hasComplexContent());
TEST(7, false, x.golf.hasComplexContent());
TEST(8, false, x.hotel.hasComplexContent());
TEST(9, false, x.@attr1.hasComplexContent());
TEST(10, false, x.bravo.child(0).hasComplexContent());
TEST(11, true, x.india.hasComplexContent());
END();

Просмотреть файл

@ -0,0 +1,71 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.16 - XML hasSimpleContent()");
TEST(1, true, XML.prototype.hasOwnProperty("hasSimpleContent"));
x =
<alpha attr1="value1">
<bravo>one</bravo>
<charlie>
two
three
<echo>four</echo>
</charlie>
<delta />
<foxtrot attr2="value2">five</foxtrot>
<golf attr3="value3" />
<hotel>
six
seven
</hotel>
<india><juliet /></india>
</alpha>;
TEST(2, false, x.hasSimpleContent());
TEST(3, true, x.bravo.hasSimpleContent());
TEST(4, false, x.charlie.hasSimpleContent());
TEST(5, true, x.delta.hasSimpleContent());
TEST(6, true, x.foxtrot.hasSimpleContent());
TEST(7, true, x.golf.hasSimpleContent());
TEST(8, true, x.hotel.hasSimpleContent());
TEST(9, true, x.@attr1.hasSimpleContent());
TEST(10, true, x.bravo.child(0).hasSimpleContent());
TEST(11, false, x.india.hasSimpleContent());
END();

Просмотреть файл

@ -0,0 +1,57 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.17 - XML inScopeNamespaces()");
TEST(1, true, XML.prototype.hasOwnProperty("inScopeNamespaces"));
x =
<alpha xmlns:foo="http://foo/" xmlns:bar="http://bar/">
<bravo>one</bravo>
</alpha>;
namespaces = x.bravo.inScopeNamespaces();
TEST(2, "foo", namespaces[0].prefix);
TEST(3, "http://foo/", namespaces[0].uri);
TEST(4, "bar", namespaces[1].prefix);
TEST(5, "http://bar/", namespaces[1].uri);
TEST(6, "", namespaces[2].prefix);
TEST(7, "", namespaces[2].uri);
TEST(8, 3, namespaces.length);
END();

Просмотреть файл

@ -0,0 +1,77 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.18 - XML insertChildAfter()");
TEST(1, true, XML.prototype.hasOwnProperty("insertChildAfter"));
x =
<alpha>
<bravo>one</bravo>
<charlie>two</charlie>
</alpha>;
correct =
<alpha>
<bravo>one</bravo>
<delta>three</delta>
<charlie>two</charlie>
</alpha>;
x.insertChildAfter(x.bravo[0], <delta>three</delta>);
TEST(2, correct, x);
x =
<alpha>
<bravo>one</bravo>
<charlie>two</charlie>
</alpha>;
correct =
<alpha>
<delta>three</delta>
<bravo>one</bravo>
<charlie>two</charlie>
</alpha>;
x.insertChildAfter(null, <delta>three</delta>);
TEST(3, correct, x);
END();

Просмотреть файл

@ -0,0 +1,77 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.19 - insertChildBefore()");
TEST(1, true, XML.prototype.hasOwnProperty("insertChildBefore"));
x =
<alpha>
<bravo>one</bravo>
<charlie>two</charlie>
</alpha>;
correct =
<alpha>
<delta>three</delta>
<bravo>one</bravo>
<charlie>two</charlie>
</alpha>;
x.insertChildBefore(x.bravo[0], <delta>three</delta>);
TEST(2, correct, x);
x =
<alpha>
<bravo>one</bravo>
<charlie>two</charlie>
</alpha>;
correct =
<alpha>
<bravo>one</bravo>
<charlie>two</charlie>
<delta>three</delta>
</alpha>;
x.insertChildBefore(null, <delta>three</delta>);
TEST(3, correct, x);
END();

Просмотреть файл

@ -0,0 +1,62 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.2 - XML addNamespace()");
TEST(1, true, XML.prototype.hasOwnProperty("addNamespace"));
e =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
n = "http://foobar/";
e.addNamespace(n);
n = new Namespace();
e.addNamespace(n);
n = new Namespace("http://foobar/");
e.addNamespace(n);
x = <a/>;
n = new Namespace("ns", "uri");
x.addNamespace(n);
TEST(2, "<a xmlns:ns=\"uri\"/>", x.toXMLString());
END();

Просмотреть файл

@ -0,0 +1,58 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.20 - XML length()");
TEST(1, true, XML.prototype.hasOwnProperty("length"));
x =
<alpha attr1="value1">
<bravo>one</bravo>
<charlie>
two
three
<echo>four</echo>
</charlie>
<delta />
</alpha>;
TEST(2, 1, x.length());
TEST(3, 1, x.bravo.length());
TEST(4, 1, x.charlie.length());
TEST(5, 1, x.delta.length());
END();

Просмотреть файл

@ -0,0 +1,74 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.21 - XML localName()");
TEST(1, true, XML.prototype.hasOwnProperty("localName"));
x =
<alpha>
<bravo>one</bravo>
<charlie>
<bravo>two</bravo>
</charlie>
</alpha>;
y = x.bravo.localName();
TEST(2, "string", typeof(y));
TEST(3, "bravo", y);
y = x.bravo.localName();
x.bravo.setNamespace("http://someuri");
TEST(4, "bravo", y);
x =
<foo:alpha xmlns:foo="http://foo/">
<foo:bravo name="bar" foo:value="one">one</foo:bravo>
</foo:alpha>;
ns = new Namespace("http://foo/");
y = x.ns::bravo.localName();
TEST(5, "string", typeof(y));
TEST(6, "bravo", y);
y = x.ns::bravo.@name.localName();
TEST(7, "name", y);
y = x.ns::bravo.@ns::value.localName();
TEST(8, "value", y);
END();

Просмотреть файл

@ -0,0 +1,74 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.22 - XML name()");
TEST(1, true, XML.prototype.hasOwnProperty("name"));
x =
<alpha>
<bravo>one</bravo>
<charlie>
<bravo>two</bravo>
</charlie>
</alpha>;
y = x.bravo.name();
TEST(2, "object", typeof(y));
TEST(3, QName("bravo"), y);
x =
<foo:alpha xmlns:foo="http://foo/">
<foo:bravo name="one" foo:value="two">one</foo:bravo>
</foo:alpha>;
ns = new Namespace("http://foo/");
y = x.ns::bravo.name();
TEST(4, "object", typeof(y));
TEST(5, QName("http://foo/", "bravo"), y);
y = x.ns::bravo.@name.name();
TEST(6, QName("name"), y);
y = x.ns::bravo.@ns::value.name();
TEST(7, "http://foo/", y.uri);
TEST(8, "value", y.localName);
TEST(9, QName("http://foo/", "value"), y);
END();

Просмотреть файл

@ -0,0 +1,86 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.23 - XML namespace()");
TEST(1, true, XML.prototype.hasOwnProperty("namespace"));
// Prefix case
x =
<foo:alpha xmlns:foo="http://foo/" xmlns:bar="http://bar/">
<foo:bravo>one</foo:bravo>
</foo:alpha>;
y = x.namespace();
TEST(2, "object", typeof(y));
TEST(3, Namespace("http://foo/"), y);
y = x.namespace("bar");
TEST(4, "object", typeof(y));
TEST(5, Namespace("http://bar/"), y);
// No Prefix Case
x =
<alpha xmlns="http://foobar/">
<bravo>one</bravo>
</alpha>;
y = x.namespace();
TEST(6, "object", typeof(y));
TEST(7, Namespace("http://foobar/"), y);
// No Namespace case
x =
<alpha>
<bravo>one</bravo>
</alpha>;
TEST(8, Namespace(""), x.namespace());
// Namespaces of attributes
x =
<alpha xmlns="http://foo/">
<ns:bravo xmlns:ns="http://bar" name="two" ns:value="three">one</ns:bravo>
</alpha>;
var ns = new Namespace("http://bar");
y = x.ns::bravo.@name.namespace();
TEST(9, Namespace(""), y);
y = x.ns::bravo.@ns::value.namespace();
TEST(10, ns.toString(), y.toString());
END();

Просмотреть файл

@ -0,0 +1,57 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.24 - XML namespaceDeclarations()");
TEST(1, true, XML.prototype.hasOwnProperty("namespaceDeclarations"));
x =
<foo:alpha xmlns:foo="http://foo/" xmlns:bar="http://bar/">
<foo:bravo>one</foo:bravo>
</foo:alpha>;
y = x.namespaceDeclarations();
TEST(2, 2, y.length);
TEST(3, "object", typeof(y[0]));
TEST(4, "object", typeof(y[1]));
TEST(5, "foo", y[0].prefix);
TEST(6, Namespace("http://foo/"), y[0]);
TEST(7, "bar", y[1].prefix);
TEST(8, Namespace("http://bar/"), y[1]);
END();

Просмотреть файл

@ -0,0 +1,55 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.25 - XML nodeKind()");
TEST(1, true, XML.prototype.hasOwnProperty("nodeKind"));
x =
<alpha attr1="value1">
<bravo>one</bravo>
</alpha>;
TEST(2, "element", x.bravo.nodeKind());
TEST(3, "attribute", x.@attr1.nodeKind());
// Non-existant node type is text
x = new XML();
TEST(4, "text", x.nodeKind());
TEST(5, "text", XML.prototype.nodeKind());
END();

Просмотреть файл

@ -0,0 +1,60 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.26 - XML normalize()");
TEST(1, true, XML.prototype.hasOwnProperty("normalize"));
XML.ignoreWhitespace = false;
XML.prettyPrinting = false;
x =
<alpha> <bravo> one </bravo> </alpha>;
TEST_XML(2, "<alpha> <bravo> one </bravo> </alpha>", x);
x.normalize();
TEST_XML(3, "<alpha><bravo> one </bravo></alpha>", x);
x =
<alpha>
<bravo> one </bravo>
</alpha>;
x.normalize();
TEST_XML(5, "<alpha><bravo> one </bravo></alpha>", x);
END();

Просмотреть файл

@ -0,0 +1,56 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.27 - XML parent()");
TEST(1, true, XML.prototype.hasOwnProperty("parent"));
x =
<alpha>
<bravo>one</bravo>
<charlie>
<bravo>two</bravo>
</charlie>
</alpha>;
y = x.bravo;
TEST(2, x, y.parent());
TEST(3, undefined, x.parent());
END();

Просмотреть файл

@ -0,0 +1,66 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.28 - processingInsructions()");
TEST(1, true, XML.prototype.hasOwnProperty("processingInstructions"));
XML.ignoreProcessingInstructions = false;
// test generic PI
x = <alpha><?xyz abc="123" michael="wierd"?><?another name="value" ?><bravo>one</bravo></alpha>;
correct = <><?xyz abc="123" michael="wierd"?><?another name="value" ?></>;
TEST(2, correct, x.processingInstructions());
TEST(3, correct, x.processingInstructions("*"));
correct = "<?xyz abc=\"123\" michael=\"wierd\"?>";
TEST_XML(4, correct, x.processingInstructions("xyz"));
// test XML-decl
// Un-comment these tests when we can read in doc starting with PI.
//x = new XML("<?xml version=\"1.0\" ?><alpha><bravo>one</bravo></alpha>");
//correct = new XMLList(<?xml version="1.0" encoding="utf-8"?>);
//test(5, correct, x.processingInstructions());
//test(6, correct, x.processingInstructions("*"));
//test(7, correct, x.processingInstructions("xml"));
END();

Просмотреть файл

@ -0,0 +1,86 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.29 - XML prependChild()");
TEST(1, true, XML.prototype.hasOwnProperty("prependChild"));
x =
<alpha>
<bravo>
<charlie>one</charlie>
</bravo>
</alpha>;
correct =
<alpha>
<bravo>
<foo>bar</foo>
<charlie>one</charlie>
</bravo>
</alpha>;
x.bravo.prependChild(<foo>bar</foo>);
TEST(2, correct, x);
emps =
<employees>
<employee>
<name>John</name>
</employee>
<employee>
<name>Sue</name>
</employee>
</employees>
correct =
<employees>
<employee>
<prefix>Mr.</prefix>
<name>John</name>
</employee>
<employee>
<name>Sue</name>
</employee>
</employees>
emps.employee.(name == "John").prependChild(<prefix>Mr.</prefix>);
TEST(3, correct, emps);
END();

Просмотреть файл

@ -0,0 +1,77 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.3 - XML appendChild()");
TEST(1, true, XML.prototype.hasOwnProperty("appendChild"));
// Add new employee to list
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
correct =
<employees>
<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>
</employees>;
newEmp = <employee id="2"><name>Sue</name><age>30</age></employee>;
emps.appendChild(newEmp);
TEST(2, correct, emps);
// Add a new child element to the end of Jim's employee element
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
correct =
<employees>
<employee id="0"><name>Jim</name><age>25</age><hobby>snorkeling</hobby></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
emps.employee.(name == "Jim").appendChild(<hobby>snorkeling</hobby>);
TEST(3, correct, emps);
END();

Просмотреть файл

@ -0,0 +1,55 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.30 - propertyIsEnumerable()");
TEST(1, true, XML.prototype.hasOwnProperty("propertyIsEnumerable"));
// All properties accessible by Get are enumerable
x =
<alpha>
<bravo>one</bravo>
</alpha>;
TEST(2, true, x.propertyIsEnumerable("0"));
TEST(3, true, x.propertyIsEnumerable(0));
TEST(5, false, x.propertyIsEnumerable("bravo"));
TEST(6, false, x.propertyIsEnumerable());
TEST(7, false, x.propertyIsEnumerable(undefined));
TEST(8, false, x.propertyIsEnumerable(null));
END();

Просмотреть файл

@ -0,0 +1,71 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.31 - XML removeNamespace()");
TEST(1, true, XML.prototype.hasOwnProperty("removeNamespace"));
x =
<alpha xmlns:foo="http://foo/">
<bravo>one</bravo>
</alpha>;
correct =
<alpha>
<bravo>one</bravo>
</alpha>;
x.removeNamespace("http://foo/");
TEST(2, correct, x);
// Shouldn't remove namespace if referenced
x =
<foo:alpha xmlns:foo="http://foo/">
<bravo>one</bravo>
</foo:alpha>;
correct =
<foo:alpha xmlns:foo="http://foo/">
<bravo>one</bravo>
</foo:alpha>;
x.removeNamespace("http://foo/");
TEST(3, correct, x);
END();

Просмотреть файл

@ -0,0 +1,93 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.32 - XML replace()");
TEST(1, true, XML.prototype.hasOwnProperty("replace"));
// Replace the first employee record with an open staff requisition
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
correct =
<employees>
<requisition status="open" />
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
emps.replace(0, <requisition status="open" />);
TEST(2, correct, emps);
// Replace all children with open staff requisition
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
correct =
<employees>
<requisition status="open" />
</employees>;
emps.replace("*", <requisition status="open" />);
TEST(3, correct, emps);
// Replace all employee elements with open staff requisition
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
correct =
<employees>
<requisition status="open" />
</employees>;
emps.replace("employee", <requisition status="open" />);
TEST(4, correct, emps);
END();

Просмотреть файл

@ -0,0 +1,73 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.33 - XML setChildren()");
TEST(1, true, XML.prototype.hasOwnProperty("setChildren"));
x =
<alpha>
<bravo>one</bravo>
</alpha>;
correct =
<alpha>
<charlie>two</charlie>
</alpha>;
x.setChildren(<charlie>two</charlie>);
TEST(2, correct, x);
// Replace the entire contents of Jim's employee element
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
correct =
<employees>
<employee id="0"><name>John</name><age>35</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
emps.employee.(name == "Jim").setChildren(<name>John</name> + <age>35</age>);
TEST(3, correct, emps);
END();

Просмотреть файл

@ -0,0 +1,70 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.34 - XML setLocalName()");
TEST(1, true, XML.prototype.hasOwnProperty("setLocalName"));
x =
<alpha>
<bravo>one</bravo>
</alpha>;
correct =
<charlie>
<bravo>one</bravo>
</charlie>;
x.setLocalName("charlie");
TEST(2, correct, x);
x =
<ns:alpha xmlns:ns="http://foobar/">
<ns:bravo>one</ns:bravo>
</ns:alpha>;
correct =
<ns:charlie xmlns:ns="http://foobar/">
<ns:bravo>one</ns:bravo>
</ns:charlie>;
x.setLocalName("charlie");
TEST(3, correct, x);
END();

Просмотреть файл

@ -0,0 +1,84 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.35 - setName");
TEST(1, true, XML.prototype.hasOwnProperty("setName"));
x =
<alpha>
<bravo>one</bravo>
</alpha>;
correct =
<charlie>
<bravo>one</bravo>
</charlie>;
x.setName("charlie");
TEST(2, correct, x);
x =
<ns:alpha xmlns:ns="http://foobar/">
<ns:bravo>one</ns:bravo>
</ns:alpha>;
correct =
<charlie xmlns:ns="http://foobar/">
<ns:bravo>one</ns:bravo>
</charlie>;
x.setName("charlie");
TEST(3, correct, x);
x =
<ns:alpha xmlns:ns="http://foobar/">
<ns:bravo>one</ns:bravo>
</ns:alpha>;
correct =
<ns:charlie xmlns:ns="http://foobar/">
<ns:bravo>one</ns:bravo>
</ns:charlie>;
x.setName(new QName("http://foobar/", "charlie"));
TEST(4, correct, x);
END();

Просмотреть файл

@ -0,0 +1,56 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.36 - setNamespace");
TEST(1, true, XML.prototype.hasOwnProperty("setNamespace"));
x =
<foo:alpha xmlns:foo="http://foo/" xmlns:bar="http://bar/">
<foo:bravo>one</foo:bravo>
</foo:alpha>;
correct =
<bar:alpha xmlns:foo="http://foo/" xmlns:bar="http://bar/">
<foo:bravo>one</foo:bravo>
</bar:alpha>;
x.setNamespace("http://bar/");
TEST(2, correct, x);
END();

Просмотреть файл

@ -0,0 +1,60 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.37 - XML text()");
TEST(1, true, XML.prototype.hasOwnProperty("text"));
x =
<alpha>
<bravo>one</bravo>
<charlie>
<bravo>two</bravo>
</charlie>
</alpha>;
TEST_XML(2, "one", x.bravo.text());
correct = new XMLList();
correct += new XML("one");
correct += new XML("two");
TEST(3, correct, x..bravo.text());
TEST_XML(4, "", x.charlie.text());
TEST_XML(5, "", x.foobar.text());
TEST_XML(6, "one", x.*.text());
END();

Просмотреть файл

@ -0,0 +1,100 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.38 - XML toString()");
TEST(1, true, XML.prototype.hasOwnProperty("toString"));
XML.prettyPrinting = false;
x =
<alpha>
<bravo>one</bravo>
<charlie>
<bravo>two</bravo>
</charlie>
</alpha>;
TEST(2, "one", x.bravo.toString());
TEST(3, "<bravo>one</bravo>" + NL() + "<bravo>two</bravo>", x..bravo.toString());
x =
<alpha>
<bravo>one</bravo>
<charlie/>
</alpha>;
TEST(4, "", x.charlie.toString());
x =
<alpha>
<bravo>one</bravo>
<charlie>
<bravo>two</bravo>
</charlie>
</alpha>;
TEST(5, "<charlie><bravo>two</bravo></charlie>", x.charlie.toString());
x =
<alpha>
<bravo>one</bravo>
<charlie>
two
<bravo/>
</charlie>
</alpha>;
TEST(5, "<charlie>two<bravo/></charlie>", x.charlie.toString());
x =
<alpha>
<bravo></bravo>
<bravo/>
</alpha>;
TEST(6, "<bravo/>" + NL() + "<bravo/>", x.bravo.toString());
x =
<alpha>
<bravo>one<charlie/></bravo>
<bravo>two<charlie/></bravo>
</alpha>;
TEST(7, "<bravo>one<charlie/></bravo>" + NL() + "<bravo>two<charlie/></bravo>", x.bravo.toString());
END();

Просмотреть файл

@ -0,0 +1,122 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.39 - XML toXMLString");
TEST(1, true, XML.prototype.hasOwnProperty("toXMLString"));
XML.prettyPrinting = false;
x =
<alpha>
<bravo>one</bravo>
<charlie>
<bravo>two</bravo>
</charlie>
</alpha>;
TEST(2, "<bravo>one</bravo>", x.bravo.toXMLString());
TEST(3, "<bravo>one</bravo>" + NL() + "<bravo>two</bravo>", x..bravo.toXMLString());
x =
<alpha>
<bravo>one</bravo>
<charlie/>
</alpha>;
TEST(4, "<charlie/>", x.charlie.toXMLString());
x =
<alpha>
<bravo>one</bravo>
<charlie>
<bravo>two</bravo>
</charlie>
</alpha>;
TEST(5, "<charlie><bravo>two</bravo></charlie>", x.charlie.toXMLString());
x =
<alpha>
<bravo>one</bravo>
<charlie>
two
<bravo/>
</charlie>
</alpha>;
TEST(6, "<charlie>two<bravo/></charlie>", x.charlie.toXMLString());
x =
<alpha>
<bravo></bravo>
<bravo/>
</alpha>;
TEST(7, "<bravo/>" + NL() + "<bravo/>", x.bravo.toXMLString());
x =
<alpha>
<bravo>one<charlie/></bravo>
<bravo>two<charlie/></bravo>
</alpha>;
TEST(8, "<bravo>one<charlie/></bravo>" + NL() + "<bravo>two<charlie/></bravo>", x.bravo.toXMLString());
XML.prettyPrinting = true;
x =
<alpha>
<bravo>one</bravo>
<charlie>two</charlie>
</alpha>;
copy = x.bravo.copy();
TEST(9, "<bravo>one</bravo>", copy.toXMLString());
x =
<alpha>
<bravo>one</bravo>
<charlie>
<bravo>two</bravo>
</charlie>
</alpha>;
TEST(10, "String contains value one from bravo", "String contains value " + x.bravo + " from bravo");
END();

Просмотреть файл

@ -0,0 +1,69 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.4 - XML attribute()");
TEST(1, true, XML.prototype.hasOwnProperty("attribute"));
// Get count of employees
emps =
<employees count="2">
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
TEST_XML(2, 2, emps.attribute("count"));
// Get the id of the employee age 25
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
TEST_XML(3, 0, emps.employee.(age == "25").attribute("id"));
// Get the id of the employee named Jim
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
TEST_XML(4, 0, emps.employee.(name == "Jim").attribute("id"));
END();

Просмотреть файл

@ -0,0 +1,62 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.40 - valueOf");
TEST(1, true, XML.prototype.hasOwnProperty("valueOf"));
x =
<alpha>
<bravo>one</bravo>
</alpha>;
TEST(2, x, x.valueOf());
// Make sure they're the same and not copies
x =
<alpha>
<bravo>one</bravo>
</alpha>;
y = x.valueOf();
x.bravo = "two";
TEST(3, x, y);
END();

Просмотреть файл

@ -0,0 +1,64 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.5 - XML attributes()");
TEST(1, true, XML.prototype.hasOwnProperty("attributes"));
x =
<alpha attr1="value1" attr2="value2" attr3="value3">
<bravo>one</bravo>
</alpha>;
TEST(2, "xml", typeof(x.attributes()));
// Iterate through the attributes of an XML value
x =
<alpha attr1="value1" attr2="value2" attr3="value3">
<bravo>one</bravo>
</alpha>;
correct = new Array("value1", "value2", "value3");
i = 0;
for each (var a in x.attributes())
{
TEST_XML(i + 3, correct[i], a);
i++;
}
END();

Просмотреть файл

@ -0,0 +1,61 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.6 - XML child()");
TEST(1, true, XML.prototype.hasOwnProperty("child"));
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
correct =
<employee id="0"><name>Jim</name><age>25</age></employee> +
<employee id="1"><name>Joe</name><age>20</age></employee>;
TEST(2, correct, emps.child("employee"));
TEST(3, <name>Joe</name>, emps.employee[1].child("name"));
correct = <employee id="1"><name>Joe</name><age>20</age></employee>;
TEST(4, correct, emps.child(1));
END();

Просмотреть файл

@ -0,0 +1,55 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.7 - XML childIndex()");
TEST(1, true, XML.prototype.hasOwnProperty("childIndex"));
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
TEST(2, 0, emps.employee[0].childIndex());
// Get the ordinal index of the employee named Joe
TEST(3, 1, emps.employee.(age == "20").childIndex());
TEST(4, 1, emps.employee.(name == "Joe").childIndex());
END();

Просмотреть файл

@ -0,0 +1,62 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Igor Bukanov
* Ethan Hugg
* Milen Nankov
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
START("13.4.4.8 - XML children()");
TEST(1, true, XML.prototype.hasOwnProperty("children"));
emps =
<employees>
<employee id="0"><name>Jim</name><age>25</age></employee>
<employee id="1"><name>Joe</name><age>20</age></employee>
</employees>;
correct = new XMLList();
correct += <employee id="0"><name>Jim</name><age>25</age></employee>;
correct += <employee id="1"><name>Joe</name><age>20</age></employee>;
TEST(2, "xml", typeof(emps.children()));
TEST(3, correct, emps.children());
// Get the child elements of the first employee
correct = new XMLList();
correct += <name>Jim</name>,
correct += <age>25</age>;
TEST(4, correct, emps.employee[0].children());
END();

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше