Skip to content

test(WeakRef): add missing ECMAScript compliance tests#4916

Merged
jedel1043 merged 3 commits intoboa-dev:mainfrom
mrhapile:add-weakref-tests
Mar 8, 2026
Merged

test(WeakRef): add missing ECMAScript compliance tests#4916
jedel1043 merged 3 commits intoboa-dev:mainfrom
mrhapile:add-weakref-tests

Conversation

@mrhapile
Copy link
Contributor

@mrhapile mrhapile commented Mar 7, 2026

This PR expands the test coverage for the WeakRef builtin to better align with the ECMAScript specification.

Currently the repository only contains a test validating garbage collection behaviour (weak_ref_collected). While this verifies the core weak reference semantics, several specification-required behaviours are not explicitly tested.

This patch adds additional tests covering:
Screenshot 2026-03-07 at 8 24 06 AM

  • Calling WeakRef without new (should throw a TypeError)
  • Constructor rejecting primitive targets
  • Basic WeakRef.prototype.deref() identity behaviour
  • Calling WeakRef.prototype.deref with an invalid this
  • Builtin property checks:
    • WeakRef.length
    • WeakRef.prototype.deref.length

All tests use Boa's internal engine test harness (run_test_actions and TestAction) defined in core/engine/src/lib.rs, consistent with existing builtin tests (e.g. Map, Set, Array).

These changes only add tests and do not modify runtime behaviour.

Adds additional WeakRef tests using Boa's internal test harness.

The repository currently only tests GC collection behaviour
(). This patch expands coverage to include:

- WeakRef cannot be called without
- constructor rejects primitive targets
- basic deref identity behaviour
- invalid  for WeakRef.prototype.deref
- builtin property checks (WeakRef.length and deref.length)

All tests follow the existing  harness used
throughout Boa's builtin tests and do not modify runtime logic.

Signed-off-by: mrhapile <allinonegaming3456@gmail.com>
Copilot AI review requested due to automatic review settings March 7, 2026 02:57
@mrhapile mrhapile requested a review from a team as a code owner March 7, 2026 02:57
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

Expands Boa’s conformance test coverage for the ECMAScript WeakRef builtin by adding spec-focused unit tests using the existing run_test_actions harness.

Changes:

  • Added tests asserting WeakRef throws when called without new.
  • Added tests asserting the constructor rejects non-object targets (including null/undefined) and that deref() returns stable identity while strongly referenced.
  • Added tests for invalid this on WeakRef.prototype.deref and for length property values (WeakRef.length, WeakRef.prototype.deref.length).

💡 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.

@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,713 49,713 0
Ignored 2,262 2,262 0
Failed 988 988 0
Panics 0 0 0
Conformance 93.86% 93.86% 0.00%

Tested main commit: 5994303fbdc61f8cfa941a244d98ce6bfbd3ec5b
Tested PR commit: 4b95b1d7644fd5cc925dce0c580ad8a13426c8fd
Compare commits: 5994303...4b95b1d

@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

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

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #4916       +/-   ##
===========================================
+ Coverage   47.24%   57.84%   +10.59%     
===========================================
  Files         476      557       +81     
  Lines       46892    61059    +14167     
===========================================
+ Hits        22154    35319    +13165     
- Misses      24738    25740     +1002     

☔ 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.

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

LGTM!

@jedel1043 jedel1043 enabled auto-merge March 8, 2026 20:40
@jedel1043 jedel1043 added this pull request to the merge queue Mar 8, 2026
Merged via the queue into boa-dev:main with commit c491674 Mar 8, 2026
19 checks 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.

3 participants