Skip to content

Add WeakSet edge case tests#4914

Open
mrhapile wants to merge 2 commits intoboa-dev:mainfrom
mrhapile:test/weakset-edge-tests
Open

Add WeakSet edge case tests#4914
mrhapile wants to merge 2 commits intoboa-dev:mainfrom
mrhapile:test/weakset-edge-tests

Conversation

@mrhapile
Copy link
Contributor

@mrhapile mrhapile commented Mar 7, 2026

This PR expands the WeakSet unit test coverage.

The initial WeakSet tests introduced basic behavioral tests.
#4912
This PR adds additional ECMAScript edge case coverage.

The following behaviors are now tested:

  • Primitive rejection in WeakSet.prototype.add
  • Primitive-safe behavior for WeakSet.prototype.has
  • Primitive-safe behavior for WeakSet.prototype.delete
  • Duplicate object additions

These tests ensure correct handling of ECMAScript §24.4 WeakSet
invariants and improve robustness during future refactors.

Screenshot 2026-03-07 at 7 15 01 AM

All tests follow the same pattern used by other builtin tests.

mrhapile added 2 commits March 7, 2026 07:03
Signed-off-by: mrhapile <allinonegaming3456@gmail.com>
Signed-off-by: mrhapile <allinonegaming3456@gmail.com>
@mrhapile mrhapile requested a review from a team as a code owner March 7, 2026 01:53
Copilot AI review requested due to automatic review settings March 7, 2026 01:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands Boa’s Rust-level unit tests for the WeakSet builtin to cover additional ECMAScript edge cases, improving regression protection beyond test262 coverage.

Changes:

  • Adds a WeakSet builtin test module and wires it into weak_set/mod.rs.
  • Introduces unit tests for primitive rejection in WeakSet.prototype.add, primitive-safe has/delete, and duplicate object additions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
core/engine/src/builtins/weak_set/tests.rs Adds baseline + edge-case WeakSet behavior tests (add/has/delete, primitives, duplicates).
core/engine/src/builtins/weak_set/mod.rs Includes the test module under #[cfg(test)].

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +48 to +51
TestAction::assert_native_error(
"ws.add(null);",
JsNativeErrorKind::Type,
"WeakSet.add: expected target argument of type `object`, got target of type `object`",
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The null case asserts an error message where the "got" type is object (because typeof null is "object"), which makes the message read like there was no type mismatch ("expected object … got object"). This makes the test misleading/brittle and also locks in a confusing engine error string. Consider either (a) updating the WeakSet.add TypeError message to special-case null (e.g., report null explicitly) and then adjusting this assertion accordingly, or (b) changing this test to assert only that a TypeError is thrown for null without coupling to the exact message text.

Suggested change
TestAction::assert_native_error(
"ws.add(null);",
JsNativeErrorKind::Type,
"WeakSet.add: expected target argument of type `object`, got target of type `object`",
TestAction::assert(
"try { ws.add(null); false } catch (e) { e instanceof TypeError }",

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 49,666 49,666 0
Ignored 2,284 2,284 0
Failed 1,013 1,013 0
Panics 0 0 0
Conformance 93.77% 93.77% 0.00%

Tested main commit: 1753d9729e3d0930d808990f6911ca0b940a21d7
Tested PR commit: e7fdf7de78ed9c57e189fd2f132b80a6b88fc77b
Compare commits: 1753d97...e7fdf7d

@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.78%. Comparing base (6ddc2b4) to head (e7fdf7d).
⚠️ Report is 772 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #4914       +/-   ##
===========================================
+ Coverage   47.24%   57.78%   +10.54%     
===========================================
  Files         476      556       +80     
  Lines       46892    60739    +13847     
===========================================
+ Hits        22154    35101    +12947     
- Misses      24738    25638      +900     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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