Debian Codegraph @

rhino/testsrc/tests/e4x/XML/13.4.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.4.1.js';
8
9 START("13.4.1 - XML Constructor as Function");
10
11 x = XML();
12 TEST(1, "xml", typeof(x));
13 TEST(2, true, x instanceof XML);
14
15 correct =
16 <Envelope
17 xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
18 xmlns:stock="http://mycompany.com/stocks"
19 soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
20 <Body>
21 <stock:GetLastTradePrice>
22 <stock:symbol>DIS</stock:symbol>
23 </stock:GetLastTradePrice>
24 </Body>
25 </Envelope>;
26
27 x = XML(correct);
28 TEST(3, correct, x);
29
30 text =
31 "<Envelope" +
32 " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
33 " xmlns:stock=\"http://mycompany.com/stocks\"" +
34 " soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" +
35 " <Body>" +
36 " <stock:GetLastTradePrice>" +
37 " <stock:symbol>DIS</stock:symbol>" +
38 " </stock:GetLastTradePrice>" +
39 " </Body>" +
40 "</Envelope>";
41
42 x = XML(text);
43 TEST(4, correct, x);
44
45 // Make sure it's not copied if it's XML
46 x =
47 <alpha>
48 <bravo>two</bravo>
49 </alpha>;
50
51 y = XML(x);
52
53 x.bravo = "three";
54
55 correct =
56 <alpha>
57 <bravo>three</bravo>
58 </alpha>;
59
60 TEST(5, correct, y);
61
62 // Make text node
63 x = XML("4");
64 TEST_XML(6, 4, x);
65
66 x = XML(4);
67 TEST_XML(7, 4, x);
68
69 // Undefined and null should behave like ""
70 x = XML(null);
71 TEST_XML(8, "", x);
72
73 x = XML(undefined);
74 TEST_XML(9, "", x);
75
76
77 END();