Debian Codegraph @

rhino/testsrc/tests/e4x/XML/13.4.4.3.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.3.js';
8
9 START("13.4.4.3 - XML appendChild()");
10
11 TEST(1, true, XML.prototype.hasOwnProperty("appendChild"));
12
13 // Add new employee to list
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 <employee id="0"><name>Jim</name><age>25</age></employee>
23 <employee id="1"><name>Joe</name><age>20</age></employee>
24 <employee id="2"><name>Sue</name><age>30</age></employee>
25 </employees>;
26
27 newEmp = <employee id="2"><name>Sue</name><age>30</age></employee>;
28
29 emps.appendChild(newEmp);
30 TEST(2, correct, emps);
31
32 // Add a new child element to the end of Jim's employee element
33 emps =
34 <employees>
35 <employee id="0"><name>Jim</name><age>25</age></employee>
36 <employee id="1"><name>Joe</name><age>20</age></employee>
37 </employees>;
38
39 correct =
40 <employees>
41 <employee id="0"><name>Jim</name><age>25</age><hobby>snorkeling</hobby></employee>
42 <employee id="1"><name>Joe</name><age>20</age></employee>
43 </employees>;
44
45 emps.employee.(name == "Jim").appendChild(<hobby>snorkeling</hobby>);
46 TEST(3, correct, emps);
47
48 END();