OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // TODO(eholk): Once we have stable test IDs, use those as the key instead. |
| 6 // See https://github.com/WebAssembly/spec/issues/415 |
| 7 const known_failures = { |
| 8 "'WebAssembly.Module.customSections' method": |
| 9 'https://bugs.chromium.org/p/v8/issues/detail?id=5815', |
| 10 "'WebAssembly.Table.prototype.get' method": |
| 11 'https://bugs.chromium.org/p/v8/issues/detail?id=5507', |
| 12 "'WebAssembly.Table.prototype.set' method": |
| 13 'https://bugs.chromium.org/p/v8/issues/detail?id=5507', |
| 14 }; |
| 15 |
| 16 let failures = []; |
| 17 |
| 18 let last_promise = new Promise((resolve, reject) => { resolve(); }); |
| 19 |
| 20 function test(func, description) { |
| 21 let maybeErr; |
| 22 try { func(); } |
| 23 catch(e) { maybeErr = e; } |
| 24 if (typeof maybeErr !== 'undefined') { |
| 25 print(`${description}: FAIL. ${maybeErr}`); |
| 26 failures.push(description); |
| 27 } else { |
| 28 print(`${description}: PASS.`); |
| 29 } |
| 30 } |
| 31 |
| 32 function promise_test(func, description) { |
| 33 last_promise = last_promise.then(func) |
| 34 .then(_ => { print(`${description}: PASS.`); }) |
| 35 .catch(err => { |
| 36 print(`${description}: FAIL. ${err}`); |
| 37 failures.push(description); |
| 38 }); |
| 39 } |
| 40 |
| 41 let assert_equals = assertEquals; |
| 42 let assert_true = assertEquals.bind(null, true); |
| 43 let assert_false = assertEquals.bind(null, false); |
| 44 |
| 45 function assert_unreached(description) { |
| 46 throw new Error(`unreachable:\n${description}`); |
| 47 } |
| 48 |
| 49 function assertErrorMessage(f, ctor, test) { |
| 50 try { f(); } |
| 51 catch (e) { |
| 52 assert_true(e instanceof ctor, "expected exception " + ctor.name + ", got "
+ e); |
| 53 return; |
| 54 } |
| 55 assert_true(false, "expected exception " + ctor.name + ", no exception thrown"
); |
| 56 }; |
| 57 |
| 58 load("test/wasm-js/test/harness/wasm-constants.js"); |
| 59 load("test/wasm-js/test/harness/wasm-module-builder.js"); |
| 60 load("test/wasm-js/test/js-api/jsapi.js"); |
| 61 |
| 62 last_promise.then(_ => { |
| 63 if (failures.length > 0) { |
| 64 let unexpected = false; |
| 65 print("Some tests FAILED:"); |
| 66 for (let i in failures) { |
| 67 if (known_failures[failures[i]]) { |
| 68 print(` ${failures[i]} [KNOWN: ${known_failures[failures[i]]}]`); |
| 69 } else { |
| 70 print(` ${failures[i]}`); |
| 71 unexpected = true; |
| 72 } |
| 73 } |
| 74 if (unexpected) { |
| 75 quit(1); |
| 76 } |
| 77 } |
| 78 }); |
OLD | NEW |