test(WeakRef): add missing ECMAScript compliance tests#4916
test(WeakRef): add missing ECMAScript compliance tests#4916jedel1043 merged 3 commits intoboa-dev:mainfrom
Conversation
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>
There was a problem hiding this comment.
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
WeakRefthrows when called withoutnew. - Added tests asserting the constructor rejects non-object targets (including
null/undefined) and thatderef()returns stable identity while strongly referenced. - Added tests for invalid
thisonWeakRef.prototype.derefand forlengthproperty 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.
Test262 conformance changes
Tested main commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This PR expands the test coverage for the
WeakRefbuiltin 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:

WeakRefwithoutnew(should throw aTypeError)WeakRef.prototype.deref()identity behaviourWeakRef.prototype.derefwith an invalidthisWeakRef.lengthWeakRef.prototype.deref.lengthAll tests use Boa's internal engine test harness (
run_test_actionsandTestAction) defined incore/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.