Skip to content

Commit 7fb8d31

Browse files
committed
assert: fix loose deepEqual map comparison
Loose map comparison had an logic error. It will now be properly compared. PR-URL: #24749 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 4d41c8f commit 7fb8d31

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/internal/util/comparisons.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,7 @@ function mapMightHaveLoosePrim(a, b, prim, item, memo) {
416416
!innerDeepEqual(item, curB, false, memo)) {
417417
return false;
418418
}
419-
const curA = a.get(altValue);
420-
return curA === undefined && a.has(altValue) ||
421-
innerDeepEqual(item, curA, false, memo);
419+
return !a.has(altValue) && innerDeepEqual(item, curB, false, memo);
422420
}
423421

424422
function setEquiv(a, b, strict, memo) {

test/parallel/test-assert-deep.js

+8
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,14 @@ assertOnlyDeepEqual(
394394
new Map([[1, {}]]),
395395
new Map([[true, {}]])
396396
);
397+
assertOnlyDeepEqual(
398+
new Map([[undefined, true]]),
399+
new Map([[null, true]])
400+
);
401+
assertNotDeepOrStrict(
402+
new Map([[undefined, true]]),
403+
new Map([[true, true]])
404+
);
397405

398406
// GH-6416. Make sure circular refs don't throw.
399407
{

0 commit comments

Comments
 (0)