Debian Codegraph @

rhino/testsrc/tests/e4x/XMLList/13.5.4.4.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.4.js';
8
9 START("13.5.4.4 - XMLList child()");
10
11 TEST(1, true, XMLList.prototype.hasOwnProperty("child"));
12
13 // Test with XMLList of size 0
14 x = new XMLList()
15 TEST(2, "xml", typeof(x.child("bravo")));
16 TEST_XML(3, "", x.child("bravo"));
17
18 // Test with XMLList of size 1
19 x += <alpha>one<bravo>two</bravo></alpha>;
20 TEST(4, "xml", typeof(x.child("bravo")));
21 TEST_XML(5, "<bravo>two</bravo>", x.child("bravo"));
22
23 x += <charlie><bravo>three</bravo></charlie>;
24 TEST(6, "xml", typeof(x.child("bravo")));
25
26 correct = <><bravo>two</bravo><bravo>three</bravo></>;
27 TEST(7, correct, x.child("bravo"));
28
29 // Test no match, null and undefined
30 TEST(8, "xml", typeof(x.child("foobar")));
31 TEST_XML(9, "", x.child("foobar"));
32
33 try {
34 x.child(null);
35 SHOULD_THROW(10);
36 } catch (ex) {
37 TEST(10, "TypeError", ex.name);
38 }
39
40 // Test numeric inputs
41 x =
42 <alpha>
43 <bravo>one</bravo>
44 <charlie>two</charlie>
45 </alpha>;
46
47 TEST(12, <bravo>one</bravo>, x.child(0));
48 TEST(13, <charlie>two</charlie>, x.child(1));
49
50 END();