Debian Codegraph @

rhino/testsrc/tests/e4x/Expressions/11.3.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.3.1.js';
8
9 START("11.3.1 - Delete Operator");
10
11 order =
12 <order id="123456">
13 <customer id="123">
14 <firstname>John</firstname>
15 <lastname>Doe</lastname>
16 <address>123 Foobar Ave.</address>
17 <city>Bellevue</city>
18 <state>WA</state>
19 </customer>
20 <item>
21 <description>Big Screen Television</description>
22 <price>1299.99</price>
23 <quantity>1</quantity>
24 </item>
25 <item id="3456">
26 <description>Big Screen Television</description>
27 <price>1299.99</price>
28 <quantity>1</quantity>
29 </item>
30 <item id="56789">
31 <description>DVD Player</description>
32 <price>399.99</price>
33 <quantity>1</quantity>
34 </item>
35 </order>;
36
37 // Delete the customer address
38 correct =
39 <order id="123456">
40 <customer id="123">
41 <firstname>John</firstname>
42 <lastname>Doe</lastname>
43 <city>Bellevue</city>
44 <state>WA</state>
45 </customer>
46 <item>
47 <description>Big Screen Television</description>
48 <price>1299.99</price>
49 <quantity>1</quantity>
50 </item>
51 <item id="3456">
52 <description>Big Screen Television</description>
53 <price>1299.99</price>
54 <quantity>1</quantity>
55 </item>
56 <item id="56789">
57 <description>DVD Player</description>
58 <price>399.99</price>
59 <quantity>1</quantity>
60 </item>
61 </order>;
62
63 delete order.customer.address;
64 TEST_XML(1, "", order.customer.address);
65 TEST(2, correct, order);
66
67 order =
68 <order id="123456">
69 <customer id="123">
70 <firstname>John</firstname>
71 <lastname>Doe</lastname>
72 <address>123 Foobar Ave.</address>
73 <city>Bellevue</city>
74 <state>WA</state>
75 </customer>
76 <item>
77 <description>Big Screen Television</description>
78 <price>1299.99</price>
79 <quantity>1</quantity>
80 </item>
81 <item id="3456">
82 <description>Big Screen Television</description>
83 <price>1299.99</price>
84 <quantity>1</quantity>
85 </item>
86 <item id="56789">
87 <description>DVD Player</description>
88 <price>399.99</price>
89 <quantity>1</quantity>
90 </item>
91 </order>;
92
93 // delete the custmomer ID
94 correct =
95 <order id="123456">
96 <customer>
97 <firstname>John</firstname>
98 <lastname>Doe</lastname>
99 <address>123 Foobar Ave.</address>
100 <city>Bellevue</city>
101 <state>WA</state>
102 </customer>
103 <item>
104 <description>Big Screen Television</description>
105 <price>1299.99</price>
106 <quantity>1</quantity>
107 </item>
108 <item id="3456">
109 <description>Big Screen Television</description>
110 <price>1299.99</price>
111 <quantity>1</quantity>
112 </item>
113 <item id="56789">
114 <description>DVD Player</description>
115 <price>399.99</price>
116 <quantity>1</quantity>
117 </item>
118 </order>;
119
120 delete order.customer.@id;
121 TEST_XML(3, "", order.customer.@id);
122 TEST(4, correct, order);
123
124 order =
125 <order id="123456">
126 <customer id="123">
127 <firstname>John</firstname>
128 <lastname>Doe</lastname>
129 <address>123 Foobar Ave.</address>
130 <city>Bellevue</city>
131 <state>WA</state>
132 </customer>
133 <item>
134 <description>Big Screen Television</description>
135 <price>1299.99</price>
136 <quantity>1</quantity>
137 </item>
138 <item id="3456">
139 <description>Big Screen Television</description>
140 <price>1299.99</price>
141 <quantity>1</quantity>
142 </item>
143 <item id="56789">
144 <description>DVD Player</description>
145 <price>399.99</price>
146 <quantity>1</quantity>
147 </item>
148 </order>;
149
150 // delete the first item price
151 correct =
152 <order id="123456">
153 <customer id="123">
154 <firstname>John</firstname>
155 <lastname>Doe</lastname>
156 <address>123 Foobar Ave.</address>
157 <city>Bellevue</city>
158 <state>WA</state>
159 </customer>
160 <item>
161 <description>Big Screen Television</description>
162 <quantity>1</quantity>
163 </item>
164 <item id="3456">
165 <description>Big Screen Television</description>
166 <price>1299.99</price>
167 <quantity>1</quantity>
168 </item>
169 <item id="56789">
170 <description>DVD Player</description>
171 <price>399.99</price>
172 <quantity>1</quantity>
173 </item>
174 </order>;
175
176 delete order.item.price[0];
177 TEST_XML(5, "", order.item[0].price);
178 TEST(6, <price>1299.99</price>, order.item.price[0]);
179 TEST(7, order, correct);
180
181 order =
182 <order id="123456">
183 <customer id="123">
184 <firstname>John</firstname>
185 <lastname>Doe</lastname>
186 <address>123 Foobar Ave.</address>
187 <city>Bellevue</city>
188 <state>WA</state>
189 </customer>
190 <item>
191 <description>Big Screen Television</description>
192 <price>1299.99</price>
193 <quantity>1</quantity>
194 </item>
195 <item id="3456">
196 <description>Big Screen Television</description>
197 <price>1299.99</price>
198 <quantity>1</quantity>
199 </item>
200 <item id="56789">
201 <description>DVD Player</description>
202 <price>399.99</price>
203 <quantity>1</quantity>
204 </item>
205 </order>;
206
207 // delete all the items
208 correct =<order id="123456">
209 <customer id="123">
210 <firstname>John</firstname>
211 <lastname>Doe</lastname>
212 <address>123 Foobar Ave.</address>
213 <city>Bellevue</city>
214 <state>WA</state>
215 </customer>
216 </order>;
217
218 delete order.item;
219 TEST_XML(8, "", order.item);
220 TEST(9, correct, order);
221
222 default xml namespace = "http://someuri";
223 x = <x/>;
224 x.a.b = "foo";
225 delete x.a.b;
226 TEST_XML(10, "", x.a.b);
227
228 var ns = new Namespace("");
229 x.a.b = <b xmlns="">foo</b>;
230 delete x.a.b;
231 TEST(11, "foo", x.a.ns::b.toString());
232
233 delete x.a.ns::b;
234 TEST_XML(12, "", x.a.ns::b);
235
236 END();