Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(690)

Unified Diff: test/mjsunit/wasm/errors.js

Issue 2584843002: Implement LinkError; import tweaks (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-result.cc ('k') | test/mjsunit/wasm/export-table.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « src/wasm/wasm-result.cc ('k') | test/mjsunit/wasm/export-table.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698