Bug 1332691: Make a testharness.js polyfill for Spidermonkey; r=luke
authorBenjamin Bouvier <benj@benj.me>
Mon, 20 Feb 2017 17:30:25 +0100
changeset 344789 f98c8a722582d8a44fd706dea2b6c2b7bcdb931a
parent 344788 07b697bc921ff8d49d0f38ae83ec5ad911bb056e
child 344790 a75ac6014699ed0d432388b706891d3e6a9f71b1
push id37969
push userkwierso@gmail.com
push dateSat, 25 Feb 2017 00:59:33 +0000
treeherderautoland@23bd8be8d881 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1332691
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1332691: Make a testharness.js polyfill for Spidermonkey; r=luke MozReview-Commit-ID: IWhymoUJgJ7
js/src/jit-test/lib/wasm-testharness.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/lib/wasm-testharness.js
@@ -0,0 +1,45 @@
+if (!wasmIsSupported())
+    quit();
+
+load(scriptdir + 'harness/index.js');
+load(scriptdir + 'harness/wasm-constants.js');
+load(scriptdir + 'harness/wasm-module-builder.js');
+
+function test(func, description) {
+    let maybeErr;
+    try {
+        func();
+    } catch(e) {
+        maybeErr = e;
+    }
+
+    if (typeof maybeErr !== 'undefined') {
+        throw new Error(`${description}: FAIL.
+${maybeErr}
+${maybeErr.stack}`);
+    } else {
+        print(`${description}: PASS.`);
+    }
+}
+
+function promise_test(func, description) {
+    func()
+    .then(_ => {
+        print(`${description}: PASS.`);
+    })
+    .catch(err => {
+        print(`${description}: FAIL.
+${err}`);
+    });
+    drainJobQueue();
+}
+
+let assert_equals = assertEq;
+let assert_true = (x, errMsg) => { assertEq(x, true); }
+let assert_false = (x, errMsg) => { assertEq(x, false); }
+
+function assert_unreached(description) {
+    throw new Error(`unreachable:\n${description}`);
+}
+
+setJitCompilerOption('wasm.test-mode', 1);