Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / tests / e4x / Expressions / 11.3.1.js
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * ***** BEGIN LICENSE BLOCK *****
4  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is Rhino code, released
17  * May 6, 1999.
18  *
19  * The Initial Developer of the Original Code is
20  * Netscape Communications Corporation.
21  * Portions created by the Initial Developer are Copyright (C) 1997-2000
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *   Igor Bukanov
26  *   Ethan Hugg
27  *   Milen Nankov
28  *
29  * Alternatively, the contents of this file may be used under the terms of
30  * either the GNU General Public License Version 2 or later (the "GPL"), or
31  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
32  * in which case the provisions of the GPL or the LGPL are applicable instead
33  * of those above. If you wish to allow use of your version of this file only
34  * under the terms of either the GPL or the LGPL, and not to allow others to
35  * use your version of this file under the terms of the MPL, indicate your
36  * decision by deleting the provisions above and replace them with the notice
37  * and other provisions required by the GPL or the LGPL. If you do not delete
38  * the provisions above, a recipient may use your version of this file under
39  * the terms of any one of the MPL, the GPL or the LGPL.
40  *
41  * ***** END LICENSE BLOCK ***** */
42
43
44 START("11.3.1 - Delete Operator");
45
46 order =
47 <order id="123456">
48     <customer id="123">
49         <firstname>John</firstname>
50         <lastname>Doe</lastname>
51         <address>123 Foobar Ave.</address>
52         <city>Bellevue</city>
53         <state>WA</state>
54     </customer>
55     <item>
56         <description>Big Screen Television</description>
57         <price>1299.99</price>
58         <quantity>1</quantity>
59     </item>
60     <item id="3456">
61         <description>Big Screen Television</description>
62         <price>1299.99</price>
63         <quantity>1</quantity>
64     </item>
65     <item id="56789">
66         <description>DVD Player</description>
67         <price>399.99</price>
68         <quantity>1</quantity>
69     </item>
70 </order>;   
71
72 // Delete the customer address
73 correct =
74 <order id="123456">
75     <customer id="123">
76         <firstname>John</firstname>
77         <lastname>Doe</lastname>
78         <city>Bellevue</city>
79         <state>WA</state>
80     </customer>
81     <item>
82         <description>Big Screen Television</description>
83         <price>1299.99</price>
84         <quantity>1</quantity>
85     </item>
86     <item id="3456">
87         <description>Big Screen Television</description>
88         <price>1299.99</price>
89         <quantity>1</quantity>
90     </item>
91     <item id="56789">
92         <description>DVD Player</description>
93         <price>399.99</price>
94         <quantity>1</quantity>
95     </item>
96 </order>;   
97
98 delete order.customer.address;
99 TEST_XML(1, "", order.customer.address);
100 TEST(2, correct, order);
101
102 order =
103 <order id="123456">
104     <customer id="123">
105         <firstname>John</firstname>
106         <lastname>Doe</lastname>
107         <address>123 Foobar Ave.</address>
108         <city>Bellevue</city>
109         <state>WA</state>
110     </customer>
111     <item>
112         <description>Big Screen Television</description>
113         <price>1299.99</price>
114         <quantity>1</quantity>
115     </item>
116     <item id="3456">
117         <description>Big Screen Television</description>
118         <price>1299.99</price>
119         <quantity>1</quantity>
120     </item>
121     <item id="56789">
122         <description>DVD Player</description>
123         <price>399.99</price>
124         <quantity>1</quantity>
125     </item>
126 </order>;   
127
128 // delete the custmomer ID
129 correct =
130 <order id="123456">
131     <customer>
132         <firstname>John</firstname>
133         <lastname>Doe</lastname>
134         <address>123 Foobar Ave.</address>
135         <city>Bellevue</city>
136         <state>WA</state>
137     </customer>
138     <item>
139         <description>Big Screen Television</description>
140         <price>1299.99</price>
141         <quantity>1</quantity>
142     </item>
143     <item id="3456">
144         <description>Big Screen Television</description>
145         <price>1299.99</price>
146         <quantity>1</quantity>
147     </item>
148     <item id="56789">
149         <description>DVD Player</description>
150         <price>399.99</price>
151         <quantity>1</quantity>
152     </item>
153 </order>;   
154
155 delete order.customer.@id;
156 TEST_XML(3, "", order.customer.@id);
157 TEST(4, correct, order);
158
159 order =
160 <order id="123456">
161     <customer id="123">
162         <firstname>John</firstname>
163         <lastname>Doe</lastname>
164         <address>123 Foobar Ave.</address>
165         <city>Bellevue</city>
166         <state>WA</state>
167     </customer>
168     <item>
169         <description>Big Screen Television</description>
170         <price>1299.99</price>
171         <quantity>1</quantity>
172     </item>
173     <item id="3456">
174         <description>Big Screen Television</description>
175         <price>1299.99</price>
176         <quantity>1</quantity>
177     </item>
178     <item id="56789">
179         <description>DVD Player</description>
180         <price>399.99</price>
181         <quantity>1</quantity>
182     </item>
183 </order>;   
184
185 // delete the first item price
186 correct =
187 <order id="123456">
188     <customer id="123">
189         <firstname>John</firstname>
190         <lastname>Doe</lastname>
191         <address>123 Foobar Ave.</address>
192         <city>Bellevue</city>
193         <state>WA</state>
194     </customer>
195     <item>
196         <description>Big Screen Television</description>
197         <quantity>1</quantity>
198     </item>
199     <item id="3456">
200         <description>Big Screen Television</description>
201         <price>1299.99</price>
202         <quantity>1</quantity>
203     </item>
204     <item id="56789">
205         <description>DVD Player</description>
206         <price>399.99</price>
207         <quantity>1</quantity>
208     </item>
209 </order>;   
210
211 delete order.item.price[0];
212 TEST_XML(5, "", order.item[0].price);
213 TEST(6, <price>1299.99</price>, order.item.price[0]);
214 TEST(7, order, correct);
215
216 order =
217 <order id="123456">
218     <customer id="123">
219         <firstname>John</firstname>
220         <lastname>Doe</lastname>
221         <address>123 Foobar Ave.</address>
222         <city>Bellevue</city>
223         <state>WA</state>
224     </customer>
225     <item>
226         <description>Big Screen Television</description>
227         <price>1299.99</price>
228         <quantity>1</quantity>
229     </item>
230     <item id="3456">
231         <description>Big Screen Television</description>
232         <price>1299.99</price>
233         <quantity>1</quantity>
234     </item>
235     <item id="56789">
236         <description>DVD Player</description>
237         <price>399.99</price>
238         <quantity>1</quantity>
239     </item>
240 </order>;   
241
242 // delete all the items
243 correct =<order id="123456">
244     <customer id="123">
245         <firstname>John</firstname>
246         <lastname>Doe</lastname>
247         <address>123 Foobar Ave.</address>
248         <city>Bellevue</city>
249         <state>WA</state>
250     </customer>
251 </order>;   
252
253 delete order.item;
254 TEST_XML(8, "", order.item);
255 TEST(9, correct, order);
256
257 default xml namespace = "http://someuri";
258 x = <x/>;
259 x.a.b = "foo";
260 delete x.a.b;
261 TEST_XML(10, "", x.a.b);
262
263 var ns = new Namespace("");
264 x.a.b = <b xmlns="">foo</b>;
265 delete x.a.b;
266 TEST(11, "foo", x.a.ns::b.toString());
267
268 delete x.a.ns::b;
269 TEST_XML(12, "", x.a.ns::b);
270
271 END();