// for (const arg of params) { // const tag = new WebAssembly.Tag({ parameters: arg }); // assertEqArray(tag.type().parameters, arg); // } // }
// WebAssembly.Exception tests.
assertErrorMessage(
() => WebAssembly.Exception(),
TypeError,
/calling a builtin Exception constructor without new is forbidden/
);
assertErrorMessage(
() => new WebAssembly.Exception(),
TypeError,
/At least 2 arguments required/
);
assertErrorMessage(
() => new WebAssembly.Exception(3, []),
TypeError,
/first argument must be a WebAssembly.Tag/
);
// Per spec, creating a new wasm exception with a JSTag value is rejected.
assertErrorMessage(
() => new WebAssembly.Exception(WebAssembly.JSTag, [42]),
TypeError,
/cannot wrap a WebAssembly.JSTag exception/
);
new WebAssembly.Exception(tag1, []); new WebAssembly.Exception(tag2, [3]); new WebAssembly.Exception(tag3, [3, 5.5]); new WebAssembly.Exception(tag4, [3, "foo", 4]); new WebAssembly.Exception(tag5, [3, "foo", 4, "bar"]);
assertErrorMessage(
() => new WebAssembly.Exception(tag2, []),
TypeError,
/expected 1 values but got 0/
);
assertErrorMessage(
() => new WebAssembly.Exception(tag2, [3n]),
TypeError,
/can't convert BigInt to number/
);
assertErrorMessage(
() => new WebAssembly.Exception(tag6, [undefined]),
TypeError,
/can only pass WebAssembly exported functions to funcref/
);
assertErrorMessage(
() => new WebAssembly.Exception(tag7, [undefined]),
TypeError,
/can't convert undefined to BigInt/
);
assertErrorMessage(
() => new WebAssembly.Exception(tag7, {}),
TypeError,
/\({}\) is not iterable/
);
assertErrorMessage(
() => new WebAssembly.Exception(tag7, 1),
TypeError,
/second argument must be an object/
);
// WebAssembly.Global getter and setter both reject non-exposable types.
{ const inst = wasmEvalText(`(module
(global (export "g") (mut nullexnref) (ref.null noexn))
)`); const g = inst.exports.g;
assertErrorMessage(() => g.value, TypeError, /cannot pass value to or from JS/);
assertErrorMessage(() => { g.value = null; }, TypeError, /cannot pass value to or from JS/);
}
// Exnref cannot cross the JS/wasm boundary as a function parameter. var inst = wasmEvalText(`
(module
(func (export "f") (result nullexnref)
unreachable
)
)`);
assertErrorMessage(() => inst.exports.f(), TypeError, /cannot pass value to or from JS/);
inst = wasmEvalText(`
(module
(func (export "f") (result exnref)
unreachable
)
)`);
assertErrorMessage(() => inst.exports.f(), TypeError, /cannot pass value to or from JS/);
inst = wasmEvalText(`
(module
(func (export "f") (result (ref exn))
unreachable
)
)`);
assertErrorMessage(() => inst.exports.f(), TypeError, /cannot pass value to or from JS/);
inst = wasmEvalText(`
(module
(func (export "f") (result (ref noexn))
unreachable
)
)`);
assertErrorMessage(() => inst.exports.f(), TypeError, /cannot pass value to or from JS/);
// Test Exception methods.
{ const exn1 = new WebAssembly.Exception(tag1, []);
assertEq(exn1.is(tag1), true);
assertEq(exn1.is(tag2), false);
assertErrorMessage(
() => exn1.is(),
TypeError,
/At least 1 argument required/
);
assertErrorMessage(
() => exn1.is(5),
TypeError,
/first argument must be a WebAssembly.Tag/
);
const exn2 = new WebAssembly.Exception(tag2, [3]);
assertEq(exn2.getArg(tag2, 0), 3);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.