Debian Codegraph @

rhino/testsrc/tests/e4x/XMLList/13.5.4.2.js

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 gTestfile = '13.5.4.2.js';
8
9 START("13.5.4.2 - XMLList attribute()");
10
11 TEST(1, true, XMLList.prototype.hasOwnProperty("attribute"));
12
13 // Test with list of size 0
14 emps = new XMLList();
15 TEST(2, "xml", typeof(emps.attribute("id")));
16 TEST_XML(3, "", emps.attribute("id"));
17
18 // Test with list of size 1
19 emps += <employee id="0"><name>Jim</name><age>25</age></employee>;
20
21 TEST(4, "xml", typeof(emps.attribute("id")));
22 TEST_XML(5, 0, emps.attribute("id"));
23
24 // Test with list of size > 1
25 emps += <employee id="1"><name>Joe</name><age>20</age></employee>;
26 TEST(6, "xml", typeof(emps.attribute("id")));
27
28 correct = new XMLList();
29 correct += new XML("0");
30 correct += new XML("1");
31 TEST(7, correct, emps.attribute("id"));
32
33 // Test one that doesn't exist - should return empty XMLList
34 TEST(8, "xml", typeof(emps.attribute("foobar")));
35
36 // Test args of null and undefined
37 try {
38 emps.attribute(null);
39 SHOULD_THROW(9);
40 } catch (ex) {
41 TEST(9, "TypeError", ex.name);
42 }
43
44 try {
45 emps.attribute(undefined);
46 SHOULD_THROW(10);
47 } catch (ex) {
48 TEST(10, "TypeError", ex.name);
49 }
50
51 END();