1
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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/. */
9
* Report a failure in the 'accepted' manner
11
function reportFailure (section, msg)
13
msg = inSection(section)+"\n"+msg;
14
var lines = msg.split ("\n");
15
for (var i=0; i<lines.length; i++)
16
print (FAILED + lines[i]);
19
function START(summary)
25
function TEST(section, expected, actual)
27
var expected_t = typeof expected;
28
var actual_t = typeof actual;
35
return reportCompare(expected, actual, inSection(section) + SUMMARY);
38
function TEST_XML(section, expected, actual)
40
var actual_t = typeof actual;
41
var expected_t = typeof expected;
47
if (actual_t != "xml") {
48
// force error on type mismatch
49
return TEST(section, new XML(), actual);
52
if (expected_t == "string") {
53
return TEST(section, expected, actual.toXMLString());
56
if (expected_t == "number") {
57
return TEST(section, String(expected), actual.toXMLString());
60
throw section + ": Bad TEST_XML usage: type of expected is " +
61
expected_t + ", should be number or string";
67
function SHOULD_THROW(section)
69
TEST(section, "exception", "no exception");
76
if (typeof options == 'function')