Debian Codegraph @

rhino/testsrc/tests/e4x/XML/13.4.4.11.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.11.js';
8
9 START("13.4.4.11 - XML copy()");
10
11 TEST(1, true, XML.prototype.hasOwnProperty("copy"));
12
13 emps =
14 <employees>
15 <employee id="0"><name>Jim</name><age>25</age></employee>
16 <employee id="1"><name>Joe</name><age>20</age></employee>
17 </employees>;
18
19 correct =
20 <employee id="0"><name>Jim</name><age>25</age></employee>;
21
22 x = emps.employee[0].copy();
23
24 TEST(2, null, x.parent());
25 TEST(3, correct, x);
26
27 // Make sure we're getting a copy, not a ref to orig.
28 emps =
29 <employees>
30 <employee id="0"><name>Jim</name><age>25</age></employee>
31 <employee id="1"><name>Joe</name><age>20</age></employee>
32 </employees>;
33
34 correct =
35 <employee id="0"><name>Jim</name><age>25</age></employee>
36
37 empCopy = emps.employee[0].copy();
38
39 emps.employee[0].name[0] = "Sally";
40
41 TEST(4, correct, empCopy);
42
43 // Try copying whole XML twice
44 emps =
45 <employees>
46 <employee id="0"><name>Jim</name><age>25</age></employee>
47 <employee id="1"><name>Joe</name><age>20</age></employee>
48 </employees>;
49
50 empCopy = emps.copy();
51 x = empCopy.copy();
52
53 TEST(5, x, emps);
54
55 END();