summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/lib/asserts.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/lib/asserts.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/lib/asserts.js')
-rw-r--r--js/src/jit-test/lib/asserts.js99
1 files changed, 99 insertions, 0 deletions
diff --git a/js/src/jit-test/lib/asserts.js b/js/src/jit-test/lib/asserts.js
new file mode 100644
index 000000000..119d5bd0f
--- /dev/null
+++ b/js/src/jit-test/lib/asserts.js
@@ -0,0 +1,99 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+load(libdir + "../../tests/ecma_6/shell.js");
+
+if (typeof assertWarning === 'undefined') {
+ var assertWarning = function assertWarning(f, errorClass, msg) {
+ var hadWerror = options().split(",").indexOf("werror") !== -1;
+
+ // Ensure the "werror" option is disabled.
+ if (hadWerror)
+ options("werror");
+
+ try {
+ f();
+ } catch (exc) {
+ if (hadWerror)
+ options("werror");
+
+ // print() rather than throw a different exception value, in case
+ // the caller wants exc.stack.
+ if (msg)
+ print("assertWarning: " + msg);
+ print("assertWarning: Unexpected exception calling " + f +
+ " with warnings-as-errors disabled");
+ throw exc;
+ }
+
+ // Enable the "werror" option.
+ options("werror");
+
+ try {
+ assertThrowsInstanceOf(f, errorClass, msg);
+ } catch (exc) {
+ if (msg)
+ print("assertWarning: " + msg);
+ throw exc;
+ } finally {
+ if (!hadWerror)
+ options("werror");
+ }
+ };
+}
+
+if (typeof assertNoWarning === 'undefined') {
+ var assertNoWarning = function assertWarning(f, msg) {
+ // Ensure the "werror" option is enabled.
+ var hadWerror = options().split(",").indexOf("werror") !== -1;
+ if (!hadWerror)
+ options("werror");
+
+ try {
+ f();
+ } catch (exc) {
+ if (msg)
+ print("assertNoWarning: " + msg);
+ print("assertNoWarning: Unexpected exception calling " + f +
+ "with warnings-as-errors enabled");
+ throw exc;
+ } finally {
+ if (!hadWerror)
+ options("werror");
+ }
+ };
+}
+
+if (typeof assertErrorMessage === 'undefined') {
+ var assertErrorMessage = function assertErrorMessage(f, ctor, test) {
+ try {
+ f();
+ } catch (e) {
+ if (!(e instanceof ctor))
+ throw new Error("Assertion failed: expected exception " + ctor.name + ", got " + e);
+ if (typeof test == "string") {
+ if (test != e.message)
+ throw new Error("Assertion failed: expected " + test + ", got " + e.message);
+ } else {
+ if (!test.test(e.message))
+ throw new Error("Assertion failed: expected " + test.toString() + ", got " + e.message);
+ }
+ return;
+ }
+ throw new Error("Assertion failed: expected exception " + ctor.name + ", no exception thrown");
+ };
+}
+
+if (typeof assertTypeErrorMessage === 'undefined') {
+ var assertTypeErrorMessage = function assertTypeErrorMessage(f, test) {
+ assertErrorMessage(f, TypeError, test);
+ };
+}
+
+if (typeof assertRangeErrorMessage === 'undefined') {
+ var assertRangeErrorMessage = function assertRangeErrorMessage(f, test) {
+ assertErrorMessage(f, RangeError, test);
+ };
+}