Commit 5686d294 authored by Sven Sauleau's avatar Sven Sauleau Committed by Commit Bot

[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/1352298Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57885}
parent 449fe719
......@@ -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}`);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment