-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix(deepEqual): prevent null return breaking nested Promise/function comparisons #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…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
There was a problem hiding this 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
_strictEqualsBoolwrapper so Promise/function/symbol/WeakMap/WeakSet comparisons never returnnull(non-reference-equal →false). - Fixed
_getTypeComparer()to avoid accidentally selecting the"undefined"comparer whenobjTypeis 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 Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
nevware21-bot
left a comment
There was a problem hiding this 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
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:
Changes: