Chromium Code Reviews| Index: test/mjsunit/wasm/jsapi.js |
| diff --git a/test/mjsunit/wasm/jsapi.js b/test/mjsunit/wasm/jsapi.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..162ee67368b6659dcf9e4a433373fef811363aaf |
| --- /dev/null |
| +++ b/test/mjsunit/wasm/jsapi.js |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2017 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
|
Mircea Trofin
2017/01/31 02:07:31
could you rename this to something like jsapi-harn
titzer
2017/01/31 05:00:12
No, please don't delete tests, even if they are re
Eric Holk
2017/01/31 17:30:21
I renamed jsapi.js to jsapi-harness.js, but per Be
|
| +// found in the LICENSE file. |
| + |
| +let failures = []; |
| + |
| +let last_promise = new Promise((resolve, reject) => { resolve(); }); |
| + |
| +function test(func, description) { |
| + let maybeErr; |
| + try { func(); } |
| + catch(e) { maybeErr = e; } |
| + if (typeof maybeErr !== 'undefined') { |
| + print(`${description}: FAIL. ${maybeErr}`); |
| + failures.push(description); |
| + } else { |
| + print(`${description}: PASS.`); |
| + } |
| +} |
| + |
| +function promise_test(func, description) { |
| + last_promise = last_promise.then(func) |
| + .then(_ => { print(`${description}: PASS.`); }) |
| + .catch(err => { |
| + print(`${description}: FAIL. ${err}`); |
| + failures.push(description); |
| + }); |
| +} |
| + |
| +let assert_equals = assertEquals; |
| +let assert_true = assertEquals.bind(null, true); |
| +let assert_false = assertEquals.bind(null, false); |
|
Mircea Trofin
2017/01/31 02:07:31
Could you add a mechanic to whitelist failing test
Eric Holk
2017/01/31 17:30:21
I added known_failures, keyed on the test descript
|
| + |
| +function assert_unreached(description) { |
| + throw new Error(`unreachable:\n${description}`); |
| +} |
| + |
| +function assertErrorMessage(f, ctor, test) { |
| + try { f(); } |
| + catch (e) { |
| + assert_true(e instanceof ctor, "expected exception " + ctor.name + ", got " + e); |
| + return; |
| + } |
| + assert_true(false, "expected exception " + ctor.name + ", no exception thrown"); |
| +}; |
| + |
| +load("test/wasm-js/test/lib/wasm-constants.js"); |
| +load("test/wasm-js/test/lib/wasm-module-builder.js"); |
| +load("test/wasm-js/test/js-api/jsapi.js"); |
| + |
| +last_promise.then(_ => { |
| + if (failures.length > 0) { |
| + print("Some tests FAILED:"); |
| + for (let i in failures) { |
| + print(` ${failures[i]}`); |
| + } |
| + quit(1); |
| + } |
| +}); |