Skip to content

Conversation

@nev21
Copy link
Contributor

@nev21 nev21 commented Feb 12, 2026

Fixes issue from PR #273 where _deepEquals() returning null from _strictEquals for non-reference-equal Promises/functions/WeakMaps caused nested comparisons to fail incorrectly. Callers check (=== false), treating null as "equal".

Two bugs fixed:

  1. Added _strictEqualsBool wrapper to convert null → false for types that should only be equal if reference-equal (Promise, function, symbol, WeakMap, WeakSet)
  2. Fixed _getTypeComparer() objType lookup bug where undefined objType accessed _typeEquals["undefined"] returning wrong comparer instead of falling back to theType

Changes:

  • core/src/assert/funcs/equal.ts:
    • Added _strictEqualsBool wrapper function
    • Updated _typeEquals map for promise/function/symbol/weakmap/weakset
    • Fixed _getTypeComparer to check (objType && _typeEquals[objType])
  • core/test/src/assert/assert.equals.test.ts:
    • Added regression test for Promise/function in nested objects/arrays

…comparisons

Fixes issue from PR #273 where _deepEquals() returning null from _strictEquals
for non-reference-equal Promises/functions/WeakMaps caused nested comparisons
to fail incorrectly. Callers check (=== false), treating null as "equal".

Two bugs fixed:
1. Added _strictEqualsBool wrapper to convert null → false for types that
   should only be equal if reference-equal (Promise, function, symbol,
   WeakMap, WeakSet)
2. Fixed _getTypeComparer() objType lookup bug where undefined objType
   accessed _typeEquals["undefined"] returning wrong comparer instead of
   falling back to theType

Changes:
- core/src/assert/funcs/equal.ts:
  * Added _strictEqualsBool wrapper function
  * Updated _typeEquals map for promise/function/symbol/weakmap/weakset
  * Fixed _getTypeComparer to check (objType && _typeEquals[objType])
- core/test/src/assert/assert.equals.test.ts:
  * Added regression test for Promise/function in nested objects/arrays
@nev21 nev21 added this to the 0.1.7 milestone Feb 12, 2026
@nev21 nev21 requested review from a team as code owners February 12, 2026 08:10
Copilot AI review requested due to automatic review settings February 12, 2026 08:10
@nev21 nev21 changed the title fix(deepEqual): prevent null return breaking nested Promise/function … fix(deepEqual): prevent null return breaking nested Promise/function comparisons Feb 12, 2026
@nev21 nev21 enabled auto-merge (squash) February 12, 2026 08:12
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

Fixes deep equality behavior in @nevware21/tripwire where _deepEquals() could return null for certain non-deep-comparable types (e.g., Promise/function) during nested comparisons, which callers incorrectly treated as “equal”. Also corrects type-comparer selection when objType is undefined.

Changes:

  • Added a _strictEqualsBool wrapper so Promise/function/symbol/WeakMap/WeakSet comparisons never return null (non-reference-equal → false).
  • Fixed _getTypeComparer() to avoid accidentally selecting the "undefined" comparer when objType is not present.
  • Added a regression test covering nested Promise/function comparisons in deepStrictEqual.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
core/src/assert/funcs/equal.ts Ensures strict-only types yield boolean results and fixes comparer lookup fallback logic.
core/test/src/assert/assert.equals.test.ts Adds regression coverage for nested Promise/function mismatches under deepStrictEqual.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.43%. Comparing base (119dd67) to head (e61ebe6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #275   +/-   ##
=======================================
  Coverage   91.43%   91.43%           
=======================================
  Files          78       78           
  Lines        3443     3445    +2     
  Branches      886      886           
=======================================
+ Hits         3148     3150    +2     
  Misses        295      295           
Files with missing lines Coverage Δ
core/src/assert/funcs/equal.ts 82.17% <100.00%> (+0.15%) ⬆️
🚀 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
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

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

Approved by nevware21-bot

@nev21 nev21 merged commit bccd7b7 into main Feb 12, 2026
17 checks passed
@nev21 nev21 deleted the nev21/deepEqual branch February 12, 2026 08:30
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