Skip to content

fix(assert): handle boxed primitives and duplicate keys in keyed collections in equal - #7392

Open
helmipradita wants to merge 1 commit into
denoland:mainfrom
helmipradita:fix/assert-equal-edge-cases
Open

helmipradita wants to merge 1 commit into
denoland:mainfrom
helmipradita:fix/assert-equal-edge-cases

Conversation

@helmipradita

Copy link
Copy Markdown

Refs #7387

Description

In @std/assert equal():

  1. Boxed primitive objects (new Number(1), new Boolean(true), Object(1n), Object(sym)) have no own enumerable keys and were treated as empty objects matching each other regardless of their underlying primitive values. This adds checks comparing their .valueOf() using sameValueZero.
  2. When comparing Set and Map collections with object elements/keys, the non-primitive loop simply decremented a counter whenever an entry in a matched any entry in b, without tracking whether that entry in b was already matched. As a result, duplicate entries could match the same target entry multiple times (e.g. Set([{a: 1}, {a: 1}]) vs Set([{a: 1}, {a: 2}])). This tracks unmatched entries of b using a Set and deletes entries upon matching.

@github-actions github-actions Bot added the assert label Nov 8, 2026
@codecov

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.03%. Comparing base (f834d02) to head (5cb3b41).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7392      +/-   ##
==========================================
- Coverage   95.04%   95.03%   -0.02%     
==========================================
  Files         619      618       -1     
  Lines       52012    51771     -241     
  Branches     9450     9411      -39     
==========================================
- Hits        49434    49199     -235     
+ Misses       2031     2022       -9     
- Partials      547      550       +3     

☔ View full report in Codecov by Harness.
📢 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant