Debian Codegraph @

rhino/testsrc/tests/e4x/XMLList/13.5.1.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.1.js';
8
9 START("13.5.1 - XMLList Constructor as Function");
10
11 x = XMLList();
12
13 TEST(1, "xml", typeof(x));
14 TEST(2, true, x instanceof XMLList);
15
16 // Make sure it's not copied if it's an XMLList
17 x =
18 <>
19 <alpha>one</alpha>
20 <bravo>two</bravo>
21 </>;
22
23 y = XMLList(x);
24 TEST(3, x === y, true);
25
26 x += <charlie>three</charlie>;
27 TEST(4, x === y, false);
28
29 // Load from one XML type
30 x = XMLList(<alpha>one</alpha>);
31 TEST_XML(5, "<alpha>one</alpha>", x);
32
33 // Load from Anonymous
34 x = XMLList(<><alpha>one</alpha><bravo>two</bravo></>);
35 correct = new XMLList();
36 correct += <alpha>one</alpha>;
37 correct += <bravo>two</bravo>;
38 TEST_XML(6, correct.toString(), x);
39
40 // Load from Anonymous as string
41 x = XMLList(<><alpha>one</alpha><bravo>two</bravo></>);
42 correct = new XMLList();
43 correct += <alpha>one</alpha>;
44 correct += <bravo>two</bravo>;
45 TEST_XML(7, correct.toString(), x);
46
47 // Load from single textnode
48 x = XMLList("foobar");
49 TEST_XML(8, "foobar", x);
50
51 x = XMLList(7);
52 TEST_XML(9, "7", x);
53
54 // Undefined and null should behave like ""
55 x = XMLList(null);
56 TEST_XML(10, "", x);
57
58 x = XMLList(undefined);
59 TEST_XML(11, "", x);
60
61 END();