js/src/jit-test/lib/asserts.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:0c6ec0a1a05e
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
6 load(libdir + "../../tests/ecma_6/shell.js");
7
8 if (typeof assertWarning === 'undefined') {
9 var assertWarning = function assertWarning(f, errorClass, msg) {
10 var hadWerror = options().split(",").indexOf("werror") !== -1;
11
12 // Ensure the "werror" option is disabled.
13 if (hadWerror)
14 options("werror");
15
16 try {
17 f();
18 } catch (exc) {
19 if (hadWerror)
20 options("werror");
21
22 // print() rather than throw a different exception value, in case
23 // the caller wants exc.stack.
24 if (msg)
25 print("assertWarning: " + msg);
26 print("assertWarning: Unexpected exception calling " + f +
27 " with warnings-as-errors disabled");
28 throw exc;
29 }
30
31 // Enable the "werror" option.
32 options("werror");
33
34 try {
35 assertThrowsInstanceOf(f, errorClass, msg);
36 } catch (exc) {
37 if (msg)
38 print("assertWarning: " + msg);
39 throw exc;
40 } finally {
41 if (!hadWerror)
42 options("werror");
43 }
44 };
45 }
46
47 if (typeof assertNoWarning === 'undefined') {
48 var assertNoWarning = function assertWarning(f, msg) {
49 // Ensure the "werror" option is enabled.
50 var hadWerror = options().split(",").indexOf("werror") !== -1;
51 if (!hadWerror)
52 options("werror");
53
54 try {
55 f();
56 } catch (exc) {
57 if (msg)
58 print("assertNoWarning: " + msg);
59 print("assertNoWarning: Unexpected exception calling " + f +
60 "with warnings-as-errors enabled");
61 throw exc;
62 } finally {
63 if (!hadWerror)
64 options("werror");
65 }
66 };
67 }

mercurial