Debian Codegraph @

rhino/testsrc/tests/e4x/Expressions/11.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 = '11.4.1.js';
8
9 START("11.4.1 - Addition Operator");
10
11 employeeData = <name>Fred</name> + <age>28</age> + <hobby>skiing</hobby>;
12 TEST(1, "xml", typeof(employeeData));
13 correct = <><name>Fred</name><age>28</age><hobby>skiing</hobby></>;
14 TEST(2, correct, employeeData);
15
16 order = <order>
17 <item>
18 <description>Big Screen Television</description>
19 </item>
20 <item>
21 <description>DVD Player</description>
22 </item>
23 <item>
24 <description>CD Player</description>
25 </item>
26 <item>
27 <description>8-Track Player</description>
28 </item>
29 </order>;
30
31 correct =
32 <item><description>Big Screen Television</description></item> +
33 <item><description>CD Player</description></item> +
34 <item><description>8-Track Player</description></item>;
35
36 myItems = order.item[0] + order.item[2] + order.item[3];
37 TEST(3, "xml", typeof(myItems));
38 TEST(4, correct, myItems);
39
40 correct =
41 <item><description>Big Screen Television</description></item> +
42 <item><description>DVD Player</description></item> +
43 <item><description>CD Player</description></item> +
44 <item><description>8-Track Player</description></item> +
45 <item><description>New Item</description></item>;
46
47 newItems = order.item + <item><description>New Item</description></item>;
48 TEST(5, "xml", typeof(newItems));
49 TEST(6, correct, newItems);
50
51 order =
52 <order>
53 <item>
54 <description>Big Screen Television</description>
55 <price>1299.99</price>
56 </item>
57 <item>
58 <description>DVD Player</description>
59 <price>399.99</price>
60 </item>
61 <item>
62 <description>CD Player</description>
63 <price>199.99</price>
64 </item>
65 <item>
66 <description>8-Track Player</description>
67 <price>69.99</price>
68 </item>
69 </order>;
70
71
72 totalPrice = +order.item[0].price + +order.item[1].price;
73 TEST(7, "number", typeof(totalPrice));
74 TEST(8, 1699.98, totalPrice);
75
76 totalPrice = Number(order.item[1].price) + Number(order.item[3].price);
77 TEST(9, 469.98, totalPrice);
78
79
80 order =
81 <order>
82 <customer>
83 <address>
84 <street>123 Foobar Ave.</street>
85 <city>Bellevue</city>
86 <state>WA</state>
87 <zip>98008</zip>
88 </address>
89 </customer>
90 </order>;
91
92 streetCity = "" + order.customer.address.street + order.customer.address.city;
93 TEST(10, "string", typeof(streetCity));
94 TEST(11, "123 Foobar Ave.Bellevue", streetCity);
95
96
97 statezip = String(order.customer.address.state) + order.customer.address.zip;
98 TEST(12, "string", typeof(statezip));
99 TEST(13, "WA98008", statezip);
100
101
102
103 END();