Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 97050ab

Browse files
Ms2germoz-wptsync-bot
authored andcommitted
Bug 1729408 [wpt PR 30369] - [wasm] Add some API shape tests for WebAssembly.Function., a=testonly
Automatic update from web-platform-tests [wasm] Add some API shape tests for WebAssembly.Function. -- wpt-commits: 3c6d55acbc602f5e38bd99d0228ee4e375826881 wpt-pr: 30369
1 parent d9998a8 commit 97050ab

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

testing/web-platform/tests/wasm/jsapi/function/call.tentative.any.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ test(() => {
99
var fun = new WebAssembly.Function({parameters: ["i32", "i32"], results: ["i32"]}, addxy);
1010
assert_equals(fun(1, 2), 3)
1111
}, "test calling function")
12+
13+
test(() => {
14+
var fun = new WebAssembly.Function({parameters: ["i32", "i32"], results: ["i32"]}, addxy);
15+
assert_throws_js(TypeError, () => new fun(1, 2));
16+
}, "test constructing function");

testing/web-platform/tests/wasm/jsapi/function/constructor.tentative.any.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@ function addxy(x, y) {
55
return x + y
66
}
77

8+
test(() => {
9+
assert_implements(WebAssembly.Function, "WebAssembly.Function is not implemented");
10+
assert_function_name(WebAssembly.Function, "Function", "WebAssembly.Function");
11+
}, "name");
12+
13+
test(() => {
14+
assert_implements(WebAssembly.Function, "WebAssembly.Function is not implemented");
15+
assert_function_length(WebAssembly.Function, 2, "WebAssembly.Function");
16+
}, "length");
17+
18+
test(() => {
19+
assert_implements(WebAssembly.Function, "WebAssembly.Function is not implemented");
20+
assert_throws_js(TypeError, () => new WebAssembly.Function());
21+
const argument = {parameters: [], results: []};
22+
assert_throws_js(TypeError, () => new WebAssembly.Function(argument));
23+
}, "Too few arguments");
24+
25+
test(() => {
26+
assert_implements(WebAssembly.Function, "WebAssembly.Function is not implemented");
27+
const arguments = [{parameters: ["i32", "i32"], results: ["i32"]}, addxy];
28+
assert_throws_js(TypeError, () => WebAssembly.Function(...arguments));
29+
}, "Calling");
30+
831
test(() => {
932
assert_implements(WebAssembly.Function, "WebAssembly.Function is not implemented");
1033
var fun = new WebAssembly.Function({parameters: ["i32", "i32"], results: ["i32"]}, addxy);

0 commit comments

Comments
 (0)