Debian Codegraph @

rhino/testsrc/tests/e4x/XML/13.4.4.32.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.4.32.js';
8
9 START("13.4.4.32 - XML replace()");
10
11 TEST(1, true, XML.prototype.hasOwnProperty("replace"));
12
13 // Replace the first employee record with an open staff requisition
14 emps =
15 <employees>
16 <employee id="0"><name>Jim</name><age>25</age></employee>
17 <employee id="1"><name>Joe</name><age>20</age></employee>
18 </employees>;
19
20 correct =
21 <employees>
22 <requisition status="open" />
23 <employee id="1"><name>Joe</name><age>20</age></employee>
24 </employees>;
25
26 emps.replace(0, <requisition status="open" />);
27
28 TEST(2, correct, emps);
29
30 // Replace all children with open staff requisition
31
32 emps =
33 <employees>
34 <employee id="0"><name>Jim</name><age>25</age></employee>
35 <employee id="1"><name>Joe</name><age>20</age></employee>
36 </employees>;
37
38 correct =
39 <employees>
40 <requisition status="open" />
41 </employees>;
42
43 emps.replace("*", <requisition status="open" />);
44
45 TEST(3, correct, emps);
46
47 // Replace all employee elements with open staff requisition
48
49 emps =
50 <employees>
51 <employee id="0"><name>Jim</name><age>25</age></employee>
52 <employee id="1"><name>Joe</name><age>20</age></employee>
53 </employees>;
54
55 correct =
56 <employees>
57 <requisition status="open" />
58 </employees>;
59
60 emps.replace("employee", <requisition status="open" />);
61
62 TEST(4, correct, emps);
63
64 END();