Skip to content

Commit e07c9b8

Browse files
BridgeARtargos
authored andcommitted
assert,util: revert recursive breaking change
This commit is there to be reverted after merging. It makes it easy to backport the overall PR and allows easy forward fixing. Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de> PR-URL: #46593 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 7f85a2c commit e07c9b8

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

doc/api/assert.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,6 @@ An alias of [`assert.ok()`][].
546546
<!-- YAML
547547
added: v0.1.21
548548
changes:
549-
- version: REPLACEME
550-
pr-url: https://github.com/nodejs/node/pull/46593
551-
description: Recursion now stops when either side encounters a circular
552-
reference.
553549
- version: v18.0.0
554550
pr-url: https://github.com/nodejs/node/pull/41020
555551
description: Regular expressions lastIndex property is now compared as well.
@@ -621,7 +617,7 @@ are also recursively evaluated by the following rules.
621617
* [Object wrappers][] are compared both as objects and unwrapped values.
622618
* `Object` properties are compared unordered.
623619
* [`Map`][] keys and [`Set`][] items are compared unordered.
624-
* Recursion stops when both sides differ or either side encounters a circular
620+
* Recursion stops when both sides differ or both sides encounter a circular
625621
reference.
626622
* Implementation does not test the [`[[Prototype]]`][prototype-spec] of
627623
objects.
@@ -731,10 +727,6 @@ parameter is an instance of an [`Error`][] then it will be thrown instead of the
731727
<!-- YAML
732728
added: v1.2.0
733729
changes:
734-
- version: REPLACEME
735-
pr-url: https://github.com/nodejs/node/pull/46593
736-
description: Recursion now stops when either side encounters a circular
737-
reference.
738730
- version: v18.0.0
739731
pr-url: https://github.com/nodejs/node/pull/41020
740732
description: Regular expressions lastIndex property is now compared as well.
@@ -788,7 +780,7 @@ are recursively evaluated also by the following rules.
788780
* [Object wrappers][] are compared both as objects and unwrapped values.
789781
* `Object` properties are compared unordered.
790782
* [`Map`][] keys and [`Set`][] items are compared unordered.
791-
* Recursion stops when both sides differ or either side encounters a circular
783+
* Recursion stops when both sides differ or both sides encounter a circular
792784
reference.
793785
* [`WeakMap`][] and [`WeakSet`][] comparison does not rely on their values. See
794786
below for further details.

lib/internal/util/comparisons.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,7 @@ function keyCheck(val1, val2, strict, memos, iterationType, aKeys) {
343343
if (memos.set === undefined) {
344344
if (memos.deep === false) {
345345
if (memos.a === val1) {
346-
return memos.b === val2;
347-
}
348-
if (memos.b === val2) {
349-
return false;
346+
if (memos.b === val2) return true;
350347
}
351348
memos.c = val1;
352349
memos.d = val2;
@@ -366,12 +363,9 @@ function keyCheck(val1, val2, strict, memos, iterationType, aKeys) {
366363

367364
const originalSize = set.size;
368365
set.add(val1);
369-
if (originalSize === set.size) {
370-
return set.has(val2);
371-
}
372366
set.add(val2);
373-
if (originalSize === set.size - 1) {
374-
return false;
367+
if (originalSize === set.size) {
368+
return true;
375369
}
376370

377371
const areEq = objEquiv(val1, val2, strict, aKeys, memos, iterationType);

test/parallel/test-assert-deep.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ assertNotDeepOrStrict(
425425
b.a = {};
426426
b.a.a = a;
427427

428-
assertNotDeepOrStrict(a, b);
428+
assertDeepAndStrictEqual(a, b);
429429
}
430430

431431
{
@@ -435,7 +435,7 @@ assertNotDeepOrStrict(
435435
b.a = b;
436436
const c = {};
437437
c.a = a;
438-
assertNotDeepOrStrict(b, c);
438+
assertDeepAndStrictEqual(b, c);
439439
}
440440

441441
{
@@ -445,7 +445,7 @@ assertNotDeepOrStrict(
445445
b.add(b);
446446
const c = new Set();
447447
c.add(a);
448-
assertNotDeepOrStrict(b, c);
448+
assertDeepAndStrictEqual(b, c);
449449
}
450450

451451
// https://github.com/nodejs/node-v0.x-archive/pull/7178

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy