GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — assert: fix loose deepEqual arrays with undefined and null failing · nodejs/node@180778f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/util
    • comparisons.js
  • test/parallel
    • test-assert-deep.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/util/comparisons.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/comparisons.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,9 +978,10 @@ function objEquiv(a, b, mode, keys1, keys2, memos, iterationType) {
978978
if (b[i] === undefined) {
979979
if (!hasOwn(b, i))
980980
return sparseArrayEquiv(a, b, mode, memos, i);
981-
if (a[i] !== undefined || !hasOwn(a, i))
981+
if ((a[i] !== undefined || !hasOwn(a, i)) && (mode !== kLoose || a[i] !== null))
982982
return false;
983-
} else if (a[i] === undefined || !innerDeepEqual(a[i], b[i], mode, memos)) {
983+
} else if ((a[i] === undefined || !innerDeepEqual(a[i], b[i], mode, memos)) &&
984+
(mode !== kLoose || b[i] !== null)) {
984985
return false;
985986
}
986987
}
Collapse file

‎test/parallel/test-assert-deep.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-assert-deep.js
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ test('deepEqual', () => {
126126
}
127127
});
128128

129+
test('loose deepEqual', () => {
130+
assertOnlyDeepEqual([null, undefined, undefined], [null, undefined, null]);
131+
assertNotDeepOrStrict([null, undefined, undefined, 1], [null, undefined, null, 2]);
132+
});
133+
129134
test('date', () => {
130135
assertNotDeepOrStrict(date, date2);
131136
assert.throws(
@@ -246,6 +251,13 @@ function assertOnlyDeepEqual(a, b, err) {
246251
() => assert.deepStrictEqual(b, a),
247252
err || { code: 'ERR_ASSERTION' }
248253
);
254+
255+
const partial = mustCall(() => {
256+
assert.partialDeepStrictEqual(b, a);
257+
assert.partialDeepStrictEqual(a, b);
258+
});
259+
260+
assert.throws(partial, err || { code: 'ERR_ASSERTION' });
249261
}
250262

251263
test('es6 Maps and Sets', () => {

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.