mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
assert,util: correct comparison when both contain same reference
Co-authored-by: Chris Harvey <1362083+chharvey@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/53431 Refs: https://github.com/nodejs/node/issues/53423 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
@@ -502,8 +502,9 @@ function setEquiv(a, b, strict, memo) {
|
||||
for (const val of b) {
|
||||
// Primitive values have already been handled above.
|
||||
if (typeof val === 'object' && val !== null) {
|
||||
if (!setHasEqualElement(set, val, strict, memo))
|
||||
if (!a.has(val) && !setHasEqualElement(set, val, strict, memo)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!strict &&
|
||||
!a.has(val) &&
|
||||
!setHasEqualElement(set, val, strict, memo)) {
|
||||
|
||||
@@ -375,7 +375,11 @@ assertOnlyDeepEqual(
|
||||
new Map([[undefined, null], ['+000', 2n]]),
|
||||
new Map([[null, undefined], [false, '2']]),
|
||||
);
|
||||
|
||||
const xarray = ['x'];
|
||||
assertDeepAndStrictEqual(
|
||||
new Set([xarray, ['y']]),
|
||||
new Set([xarray, ['y']])
|
||||
);
|
||||
assertOnlyDeepEqual(
|
||||
new Set([null, '', 1n, 5, 2n, false]),
|
||||
new Set([undefined, 0, 5n, true, '2', '-000'])
|
||||
|
||||
Reference in New Issue
Block a user