Chromium Code Reviews| 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 | |
|
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
| |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 let failures = []; | |
| 6 | |
| 7 let last_promise = new Promise((resolve, reject) => { resolve(); }); | |
| 8 | |
| 9 function test(func, description) { | |
| 10 let maybeErr; | |
| 11 try { func(); } | |
| 12 catch(e) { maybeErr = e; } | |
| 13 if (typeof maybeErr !== 'undefined') { | |
| 14 print(`${description}: FAIL. ${maybeErr}`); | |
| 15 failures.push(description); | |
| 16 } else { | |
| 17 print(`${description}: PASS.`); | |
| 18 } | |
| 19 } | |
| 20 | |
| 21 function promise_test(func, description) { | |
| 22 last_promise = last_promise.then(func) | |
| 23 .then(_ => { print(`${description}: PASS.`); }) | |
| 24 .catch(err => { | |
| 25 print(`${description}: FAIL. ${err}`); | |
| 26 failures.push(description); | |
| 27 }); | |
| 28 } | |
| 29 | |
| 30 let assert_equals = assertEquals; | |
| 31 let assert_true = assertEquals.bind(null, true); | |
| 32 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
| |
| 33 | |
| 34 function assert_unreached(description) { | |
| 35 throw new Error(`unreachable:\n${description}`); | |
| 36 } | |
| 37 | |
| 38 function assertErrorMessage(f, ctor, test) { | |
| 39 try { f(); } | |
| 40 catch (e) { | |
| 41 assert_true(e instanceof ctor, "expected exception " + ctor.name + ", got " + e); | |
| 42 return; | |
| 43 } | |
| 44 assert_true(false, "expected exception " + ctor.name + ", no exception thrown" ); | |
| 45 }; | |
| 46 | |
| 47 load("test/wasm-js/test/lib/wasm-constants.js"); | |
| 48 load("test/wasm-js/test/lib/wasm-module-builder.js"); | |
| 49 load("test/wasm-js/test/js-api/jsapi.js"); | |
| 50 | |
| 51 last_promise.then(_ => { | |
| 52 if (failures.length > 0) { | |
| 53 print("Some tests FAILED:"); | |
| 54 for (let i in failures) { | |
| 55 print(` ${failures[i]}`); | |
| 56 } | |
| 57 quit(1); | |
| 58 } | |
| 59 }); | |
| OLD | NEW |