• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// META: global=window,dedicatedworker,jsshell
2// META: script=/wasm/jsapi/memory/assertions.js
3
4test(() => {
5  const tag = new WebAssembly.Tag({ parameters: [] });
6  const exn = new WebAssembly.Exception(tag, []);
7  assert_throws_js(TypeError, () => exn.is());
8}, "Missing arguments");
9
10test(() => {
11  const invalidValues = [undefined, null, true, "", Symbol(), 1, {}];
12  const tag = new WebAssembly.Tag({ parameters: [] });
13  const exn = new WebAssembly.Exception(tag, []);
14  for (argument of invalidValues) {
15    assert_throws_js(TypeError, () => exn.is(argument));
16  }
17}, "Invalid exception argument");
18
19test(() => {
20  const tag1 = new WebAssembly.Tag({ parameters: ["i32"] });
21  const tag2 = new WebAssembly.Tag({ parameters: ["i32"] });
22  const exn = new WebAssembly.Exception(tag1, [42]);
23  assert_true(exn.is(tag1));
24  assert_false(exn.is(tag2));
25}, "is");
26