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 <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
BridgeAR committed Dec 5, 2018
1 parent 4d41c8f commit 7fb8d31
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 @@ -416,9 +416,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 @@ -394,6 +394,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 7fb8d31

Please sign in to comment.