Debian Codegraph @

rhino/testsrc/tests/e4x/shell.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 gTestsuite = 'e4x';
8
9 if (typeof version != 'undefined') {
10 // At least in Rhino, if version is set to 150 (which is what is used
11 // in top level shell.js), the implementation assumes E4X is not available.
12 version(160);
13 }
14
15 /*
16 * Report a failure in the 'accepted' manner
17 */
18 function reportFailure (section, msg)
19 {
20 msg = inSection(section)+"\n"+msg;
21 var lines = msg.split ("\n");
22 for (var i=0; i<lines.length; i++)
23 print (FAILED + lines[i]);
24 }
25
26 function START(summary)
27 {
28 SUMMARY = summary;
29 printStatus(summary);
30 }
31
32 function TEST(section, expected, actual)
33 {
34 var expected_t = typeof expected;
35 var actual_t = typeof actual;
36 var output = "";
37
38 SECTION = section;
39 EXPECTED = expected;
40 ACTUAL = actual;
41
42 return reportCompare(expected, actual, inSection(section) + SUMMARY);
43 }
44
45 function TEST_XML(section, expected, actual)
46 {
47 var actual_t = typeof actual;
48 var expected_t = typeof expected;
49
50 SECTION = section;
51 EXPECTED = expected;
52 ACTUAL = actual;
53
54 if (actual_t != "xml") {
55 // force error on type mismatch
56 return TEST(section, new XML(), actual);
57 }
58
59 if (expected_t == "string") {
60 return TEST(section, expected, actual.toXMLString());
61 }
62
63 if (expected_t == "number") {
64 return TEST(section, String(expected), actual.toXMLString());
65 }
66
67 throw section + ": Bad TEST_XML usage: type of expected is " +
68 expected_t + ", should be number or string";
69
70 // suppress warning
71 return false;
72 }
73
74 function SHOULD_THROW(section)
75 {
76 TEST(section, "exception", "no exception");
77 }
78
79 function END()
80 {
81 }
82
83 if (typeof options == 'function')
84 {
85 options('xml');
86 }