Skip to content

Commit 3c6d55a

Browse files
committed
[wasm] Add some API shape tests for WebAssembly.Function.
1 parent 83c20f1 commit 3c6d55a

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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");

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)