[wasm] fix testharness - unreached_func
See usage in the js-api tests; previously it would have thrown without executing any tests. Now, it can be used to generate trapping functions. Bug: v8:8319 Change-Id: Ia1643d8f337a10ea86c1e700c7702ed7d3ed0c97 Reviewed-on: https://chromium-review.googlesource.com/c/1352298 Reviewed-by: Adam Klein <adamk@chromium.org> Commit-Queue: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/master@{#57885}
This commit is contained in:
parent
449fe71924
commit
5686d294f6
@ -19,7 +19,7 @@ let lastPromise = Promise.resolve();
|
||||
|
||||
function test(func, description) {
|
||||
let maybeErr;
|
||||
try { func({unreached_func: assert_unreached}); }
|
||||
try { func({unreached_func: unreached_func}); }
|
||||
catch(e) { maybeErr = e; }
|
||||
if (typeof maybeErr !== 'undefined') {
|
||||
console.log(`${description}: FAIL. ${maybeErr}`);
|
||||
@ -98,6 +98,12 @@ function assert_array_equals(actual, expected, description) {
|
||||
}
|
||||
}
|
||||
|
||||
function unreached_func(msg) {
|
||||
return function trap() {
|
||||
assert_unreached(msg);
|
||||
};
|
||||
}
|
||||
|
||||
function assert_unreached(description) {
|
||||
throw new Error(`unreachable:\n${description}`);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user