Skip to content
Open
Changes from 1 commit
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;
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 185 to 190
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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. After checking how I missed that, I realized that I missed one "include" in my invocation for this file and that script was reponsible for actually executing the test cases. (It isn't very obvious to me how to run these scripts in e.g. d8.)

I addressed this issue now by splitting it up into testing the constructor and a separate test case for get-set.


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