Debian Codegraph @

rhino/testsrc/tests/e4x/XML/13.4.4.10.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.10.js';
8
9 var nTest = 0;
10
11 START("13.4.4.10 - XML contains()");
12
13 TEST(++nTest, true, XML.prototype.hasOwnProperty("contains"));
14
15 emps =
16 <employees>
17 <employee id="0"><name>Jim</name><age>25</age></employee>
18 <employee id="1"><name>Joe</name><age>20</age></employee>
19 </employees>;
20
21 TEST(++nTest, true, emps.contains(emps));
22
23 // Martin - bug 289706
24
25 expect = 'gods.contains(\'Kibo\')==false && (gods==\'Kibo\')==false';
26
27 var gods = <gods>
28 <god>Kibo</god>
29 <god>Xibo</god>
30 </gods>;
31
32 printStatus('XML markup is:\r\n' + gods.toXMLString());
33
34 var string = 'Kibo';
35 actual = 'gods.contains(\'' + string + '\')==' + gods.contains(string);
36 actual += ' && ';
37 actual += '(gods==\'' + string + '\')==' + (gods == string);
38
39 TEST(++nTest, expect, actual);
40
41 // Martin - bug 289790
42
43 function containsTest(xmlObject, value)
44 {
45 var comparison = (xmlObject == value);
46 var containsCheck = xmlObject.contains(value);
47 var result = (comparison == containsCheck);
48
49 printStatus('Comparing ' + xmlObject.nodeKind() +
50 ' against ' + (typeof value) + ':');
51
52 printStatus('==: ' + comparison + '; contains: ' + containsCheck +
53 '; check ' + (result ? 'passed' : 'failed'));
54 return result;
55 }
56
57 actual = containsTest(new XML('Kibo'), 'Kibo');
58 TEST(++nTest, true, actual);
59
60 actual = containsTest(<god>Kibo</god>, 'Kibo');
61 TEST(++nTest, true, actual);
62
63 END();