~ubuntu-branches/ubuntu/saucy/mozjs17/saucy-proposed

« back to all changes in this revision

Viewing changes to js/src/tests/e4x/shell.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
8
/*
 
9
 * Report a failure in the 'accepted' manner
 
10
 */
 
11
function reportFailure (section, msg)
 
12
{
 
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]);
 
17
}
 
18
 
 
19
function START(summary)
 
20
{
 
21
    SUMMARY = summary;
 
22
    printStatus(summary);
 
23
}
 
24
 
 
25
function TEST(section, expected, actual)
 
26
{
 
27
    var expected_t = typeof expected;
 
28
    var actual_t = typeof actual;
 
29
    var output = "";
 
30
   
 
31
    SECTION = section;
 
32
    EXPECTED = expected;
 
33
    ACTUAL = actual;
 
34
 
 
35
    return reportCompare(expected, actual, inSection(section) + SUMMARY);
 
36
}
 
37
 
 
38
function TEST_XML(section, expected, actual)
 
39
{
 
40
    var actual_t = typeof actual;
 
41
    var expected_t = typeof expected;
 
42
 
 
43
    SECTION = section;
 
44
    EXPECTED = expected;
 
45
    ACTUAL = actual;
 
46
 
 
47
    if (actual_t != "xml") {
 
48
        // force error on type mismatch
 
49
        return TEST(section, new XML(), actual);
 
50
    }
 
51
 
 
52
    if (expected_t == "string") {
 
53
        return TEST(section, expected, actual.toXMLString());
 
54
    }
 
55
 
 
56
    if (expected_t == "number") {
 
57
        return TEST(section, String(expected), actual.toXMLString());
 
58
    }
 
59
 
 
60
    throw section + ": Bad TEST_XML usage: type of expected is " +
 
61
        expected_t + ", should be number or string";
 
62
 
 
63
    // suppress warning
 
64
    return false;
 
65
}
 
66
 
 
67
function SHOULD_THROW(section)
 
68
{
 
69
    TEST(section, "exception", "no exception");
 
70
}
 
71
 
 
72
function END()
 
73
{
 
74
}
 
75
 
 
76
if (typeof options == 'function')
 
77
{
 
78
  options('moar_xml');
 
79
}