Skip to content

Commit 732088d

Browse files
BridgeARBethGriggs
authored andcommitted
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 <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 931a04e commit 732088d

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
@@ -401,9 +401,7 @@ function mapMightHaveLoosePrim(a, b, prim, item, memo) {
401401
!innerDeepEqual(item, curB, false, memo)) {
402402
return false;
403403
}
404-
const curA = a.get(altValue);
405-
return curA === undefined && a.has(altValue) ||
406-
innerDeepEqual(item, curA, false, memo);
404+
return !a.has(altValue) && innerDeepEqual(item, curB, false, memo);
407405
}
408406

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

test/parallel/test-assert-deep.js

+8
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,14 @@ assertOnlyDeepEqual(
380380
new Map([[1, {}]]),
381381
new Map([[true, {}]])
382382
);
383+
assertOnlyDeepEqual(
384+
new Map([[undefined, true]]),
385+
new Map([[null, true]])
386+
);
387+
assertNotDeepOrStrict(
388+
new Map([[undefined, true]]),
389+
new Map([[true, true]])
390+
);
383391

384392
// GH-6416. Make sure circular refs don't throw.
385393
{

0 commit comments

Comments
 (0)