Skip to content

[js-api] Add test case for externref global#1983

Merged
Ms2ger merged 4 commits into
WebAssembly:mainfrom
Liedtke:add_externref_testcase
Jan 5, 2026
Merged

[js-api] Add test case for externref global#1983
Ms2ger merged 4 commits into
WebAssembly:mainfrom
Liedtke:add_externref_testcase

Conversation

@Liedtke
Copy link
Copy Markdown
Contributor

@Liedtke Liedtke commented Sep 23, 2025

We should add some basic coverage for externref globals.
(We should extend this if #1980 results in adding more allowed types.)

Comment thread test/js-api/global/constructor.any.js Outdated
Comment on lines +188 to +189
]) {
global.value = value;
Copy link
Copy Markdown
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?

Comment on lines +187 to +192
() => null
]) {
global.value = value;
assert_Global(global, value);
}
}, "externref global");
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment on lines +187 to +192
() => null
]) {
global.value = value;
assert_Global(global, value);
}
}, "externref global");
Copy link
Copy Markdown
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.

() => null
]) {
global.value = value;
assert_equals(global.value, value);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See also #1984 (comment), this tests -0 as one of its inputs. assert_equals already treats 0 and -0 as different values:

assert_equals: expected -0 but got 0

Let me know if this is fine given that the current spec text isn't very precise.

@Liedtke
Copy link
Copy Markdown
Contributor Author

Liedtke commented Nov 18, 2025

Can this be merged?

Copy link
Copy Markdown
Collaborator

@Ms2ger Ms2ger left a comment

Choose a reason for hiding this comment

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

Thanks

@Ms2ger Ms2ger merged commit b238495 into WebAssembly:main Jan 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants