Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion test/harness/async_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,26 @@ function assert_trap(action, source) {
.catch(_ => {});
}

function assert_exception(action, source) {
const test = `Test that a WebAssembly code throws an exception (${source})`;
const loc = new Error().stack.toString().replace("Error", "");
chain = Promise.all([chain, action()])
.then(
result => {
uniqueTest(_ => {
assert_true(false, loc);
}, test);
},
error => {
uniqueTest(_ => {
// Pass
}, test);
}
)
// Clear all exceptions, so that subsequent tests get executed.
.catch(_ => {});
}

function assert_return(action, source, ...expected) {
const test = `Test that a WebAssembly code returns a specific result (${source})`;
const loc = new Error().stack.toString().replace("Error", "");
Expand Down Expand Up @@ -355,7 +375,7 @@ try {
}

function assert_exhaustion(action) {
const test = "Test that a WebAssembly code exhauts the stack space";
const test = "Test that a WebAssembly code exhausts the stack space";
const loc = new Error().stack.toString().replace("Error", "");
chain = Promise.all([action(), chain])
.then(
Expand Down
10 changes: 10 additions & 0 deletions test/harness/sync_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,16 @@ function assert_trap(action, source) {
}, `A wast module that must trap at runtime. (${source})`);
}

function assert_exception(action, source) {
let result = action();

_assert(result instanceof Result);

uniqueTest(() => {
assert_true(result.isError(), 'expected error result');
}, `A wast module that must throw an exception at runtime. (${source})`);
}

let StackOverflow;
try { (function f() { 1 + f() })() } catch (e) { StackOverflow = e.constructor }

Expand Down