| Index: test/mjsunit/wasm/errors.js
|
| diff --git a/test/mjsunit/wasm/errors.js b/test/mjsunit/wasm/errors.js
|
| index 97ce89998b2eec60a6dbe64c1cec748684b46265..cf3377fbda396586b26b8bd06ebfdb799786e0eb 100644
|
| --- a/test/mjsunit/wasm/errors.js
|
| +++ b/test/mjsunit/wasm/errors.js
|
| @@ -33,10 +33,14 @@ function assertCompileError(bytes) {
|
| assertThrows(() => module(bytes), WebAssembly.CompileError);
|
| }
|
|
|
| -function assertLinkError(bytes, imports = {}) {
|
| +function assertTypeError(bytes, imports = {}) {
|
| assertThrows(() => instance(bytes, imports), TypeError);
|
| }
|
|
|
| +function assertLinkError(bytes, imports = {}) {
|
| + assertThrows(() => instance(bytes, imports), WebAssembly.LinkError);
|
| +}
|
| +
|
| function assertRuntimeError(bytes, imports = {}) {
|
| assertThrows(() => instance(bytes, imports).exports.run(),
|
| WebAssembly.RuntimeError);
|
| @@ -68,7 +72,7 @@ function assertConversionError(bytes, imports = {}) {
|
|
|
| b = builder();
|
| b.addImportWithModule("foo", "bar", kSig_v_v);
|
| - assertLinkError(b.toBuffer(), {});
|
| + assertTypeError(b.toBuffer(), {});
|
| b = builder();
|
| b.addImportWithModule("foo", "bar", kSig_v_v);
|
| assertLinkError(b.toBuffer(), {foo: {}});
|
| @@ -78,29 +82,33 @@ function assertConversionError(bytes, imports = {}) {
|
|
|
| b = builder();
|
| b.addImportedGlobal("foo", "bar", kAstI32);
|
| - assertLinkError(b.toBuffer(), {});
|
| - // TODO(titzer): implement stricter import checks for globals.
|
| - // b = builder();
|
| - // b.addImportedGlobal("foo", "bar", kAstI32);
|
| - // assertLinkError(b.toBuffer(), {foo: {}});
|
| - // b = builder();
|
| - // b.addImportedGlobal("foo", "bar", kAstI32);
|
| - // assertLinkError(b.toBuffer(), {foo: {bar: ""}});
|
| - // b = builder();
|
| - // b.addImportedGlobal("foo", "bar", kAstI32);
|
| - // assertLinkError(b.toBuffer(), {foo: {bar: () => 9}});
|
| + assertTypeError(b.toBuffer(), {});
|
| + b = builder();
|
| + b.addImportedGlobal("foo", "bar", kAstI32);
|
| + assertLinkError(b.toBuffer(), {foo: {}});
|
| + b = builder();
|
| + b.addImportedGlobal("foo", "bar", kAstI32);
|
| + assertLinkError(b.toBuffer(), {foo: {bar: ""}});
|
| + b = builder();
|
| + b.addImportedGlobal("foo", "bar", kAstI32);
|
| + assertLinkError(b.toBuffer(), {foo: {bar: () => 9}});
|
|
|
| b = builder();
|
| b.addImportedMemory("foo", "bar");
|
| - assertLinkError(b.toBuffer(), {});
|
| + assertTypeError(b.toBuffer(), {});
|
| b = builder();
|
| b.addImportedMemory("foo", "bar");
|
| assertLinkError(b.toBuffer(), {foo: {}});
|
| - // TODO(titzer): implement stricter import checks for globals.
|
| - // b = builder();
|
| - // b.addImportedMemory("foo", "bar", 1);
|
| - // assertLinkError(b.toBuffer(),
|
| - // {foo: {bar: new WebAssembly.Memory({initial: 0})}});
|
| + b = builder();
|
| + b.addImportedMemory("foo", "bar", 1);
|
| + assertLinkError(b.toBuffer(),
|
| + {foo: {bar: () => new WebAssembly.Memory({initial: 0})}});
|
| +
|
| + b = builder();
|
| + b.addFunction("f", kSig_v_v).addBody([
|
| + kExprUnreachable,
|
| + ]).end().addStart(0);
|
| + assertRuntimeError(b.toBuffer());
|
| })();
|
|
|
| (function TestTrapError() {
|
| @@ -128,6 +136,7 @@ function assertConversionError(bytes, imports = {}) {
|
| assertConversionError(b.addFunction("run", kSig_v_v).addBody([
|
| kExprI64Const, 0, kExprCallFunction, 0
|
| ]).exportFunc().end().toBuffer());
|
| +
|
| assertConversionError(builder().addFunction("run", kSig_l_v).addBody([
|
| kExprI64Const, 0
|
| ]).exportFunc().end().toBuffer());
|
|
|