diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js index 111196264e..c1d46f6eaf 100644 --- a/test/mjsunit/mjsunit.js +++ b/test/mjsunit/mjsunit.js @@ -406,19 +406,18 @@ var failWithMessage; assertThrows = function assertThrows(code, type_opt, cause_opt) { - var threwException = true; try { if (typeof code === 'function') { code(); } else { eval(code); } - threwException = false; } catch (e) { if (typeof type_opt === 'function') { assertInstanceof(e, type_opt); } else if (type_opt !== void 0) { - failWithMessage("invalid use of assertThrows, maybe you want assertThrowsEquals"); + failWithMessage( + 'invalid use of assertThrows, maybe you want assertThrowsEquals'); } if (arguments.length >= 3) { assertEquals(e.message, cause_opt); @@ -426,7 +425,7 @@ var failWithMessage; // Success. return; } - failWithMessage("Did not throw exception"); + failWithMessage('Did not throw exception'); }; diff --git a/test/mjsunit/wasm/indirect-calls.js b/test/mjsunit/wasm/indirect-calls.js index 28effa8316..4c906a0110 100644 --- a/test/mjsunit/wasm/indirect-calls.js +++ b/test/mjsunit/wasm/indirect-calls.js @@ -74,7 +74,7 @@ module = (function () { kExprCallIndirect, sig_i_ii, kTableZero ]) .exportFunc(); - builder.appendToTable([mul.index, add.index, popcnt.index, main.index]); + builder.appendToTable([mul, add.index, popcnt.index, main.index]); return builder.instantiate({q: {mul: function(a, b) { return a * b | 0; }}}); })(); diff --git a/test/mjsunit/wasm/wasm-constants.js b/test/mjsunit/wasm/wasm-constants.js index e677f538d7..c71242a62c 100644 --- a/test/mjsunit/wasm/wasm-constants.js +++ b/test/mjsunit/wasm/wasm-constants.js @@ -339,36 +339,34 @@ let kTrapMsgs = [ ]; function assertTraps(trap, code) { - var threwException = true; - try { - if (typeof code === 'function') { - code(); - } else { - eval(code); - } - threwException = false; - } catch (e) { - assertEquals("object", typeof e); - assertEquals(kTrapMsgs[trap], e.message); - // Success. - return; + try { + if (typeof code === 'function') { + code(); + } else { + eval(code); } - throw new MjsUnitAssertionError("Did not trap, expected: " + kTrapMsgs[trap]); + } catch (e) { + assertEquals('object', typeof e); + assertEquals(kTrapMsgs[trap], e.message); + // Success. + return; + } + throw new MjsUnitAssertionError('Did not trap, expected: ' + kTrapMsgs[trap]); } function assertWasmThrows(value, code) { - assertEquals("number", typeof(value)); - try { - if (typeof code === 'function') { - code(); - } else { - eval(code); - } - } catch (e) { - assertEquals("number", typeof e); - assertEquals(value, e); - // Success. - return; + assertEquals('number', typeof value); + try { + if (typeof code === 'function') { + code(); + } else { + eval(code); } - throw new MjsUnitAssertionError("Did not throw at all, expected: " + value); + } catch (e) { + assertEquals('number', typeof e); + assertEquals(value, e); + // Success. + return; + } + throw new MjsUnitAssertionError('Did not throw, expected: ' + value); } diff --git a/test/mjsunit/wasm/wasm-module-builder.js b/test/mjsunit/wasm/wasm-module-builder.js index 63f09a7370..49c812f3a7 100644 --- a/test/mjsunit/wasm/wasm-module-builder.js +++ b/test/mjsunit/wasm/wasm-module-builder.js @@ -98,7 +98,8 @@ class WasmFunctionBuilder { addBody(body) { for (let b of body) { - if (typeof b != 'number') throw new Error('invalid body: ' + body); + if (typeof b != 'number') + throw new Error('invalid body (entries have to be numbers): ' + body); } this.body = body; // Automatically add the end for the function block to the body. @@ -264,6 +265,10 @@ class WasmModuleBuilder { } appendToTable(array) { + for (let n of array) { + if (typeof n != 'number') + throw new Error('invalid table (entries have to be numbers): ' + array); + } return this.addFunctionTableInit(this.function_table.length, false, array); }