Skip to content

Commit

Permalink
assert: fix loose deepEqual map comparison
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
BridgeAR authored and rvagg committed Feb 28, 2019
1 parent 3d6266a commit 9da4af7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/internal/util/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,7 @@ function mapMightHaveLoosePrim(a, b, prim, item, memo) {
!innerDeepEqual(item, curB, false, memo)) {
return false;
}
const curA = a.get(altValue);
return curA === undefined && a.has(altValue) ||
innerDeepEqual(item, curA, false, memo);
return !a.has(altValue) && innerDeepEqual(item, curB, false, memo);
}

function setEquiv(a, b, strict, memo) {
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-assert-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ assertOnlyDeepEqual(
new Map([[1, {}]]),
new Map([[true, {}]])
);
assertOnlyDeepEqual(
new Map([[undefined, true]]),
new Map([[null, true]])
);
assertNotDeepOrStrict(
new Map([[undefined, true]]),
new Map([[true, true]])
);

// GH-6416. Make sure circular refs don't throw.
{
Expand Down

0 comments on commit 9da4af7

Please sign in to comment.