Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion test/js-api/global/constructor.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,31 @@ test(() => {

test(() => {
const argument = { "value": "v128" };
assert_throws_js(TypeError, () =>new WebAssembly.Global(argument));
assert_throws_js(TypeError, () => new WebAssembly.Global(argument));
}, "Construct v128 global");

test(() => {
let global = new WebAssembly.Global({value: "externref"}, "initial value");
assert_Global(global, "initial value");
for (let value of [
undefined,
null,
true,
1,
-0,
1.5,
-2n,
Symbol("test"),
"string",
{"an": "object"},
() => null
]) {
global.value = value;
Comment on lines +188 to +189
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to throw an assertion in step 5 because you didn't pass mutable: true in the constructor?

assert_Global(global, value);
}
}, "externref global");
Comment on lines +187 to +192
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case isn't testing the constructor, which is what this file is for. I believe there's a file for the value getter/setter nearby


test(() => {
let global = new WebAssembly.Global({value: "externref"});
assert_Global(global, undefined);
}, "externref global with default value");