Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/internal/util/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,9 +998,10 @@ function objEquiv(a, b, mode, keys1, keys2, memos, iterationType) {
if (b[i] === undefined) {
if (!hasOwn(b, i))
return sparseArrayEquiv(a, b, mode, memos, i);
if (a[i] !== undefined || !hasOwn(a, i))
if ((a[i] !== undefined || !hasOwn(a, i)) && (mode !== kLoose || a[i] !== null))
return false;
} else if (a[i] === undefined || !innerDeepEqual(a[i], b[i], mode, memos)) {
} else if ((a[i] === undefined || !innerDeepEqual(a[i], b[i], mode, memos)) &&
(mode !== kLoose || b[i] !== null)) {
return false;
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/parallel/test-assert-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ test('deepEqual', () => {
}
});

test('loose deepEqual', () => {
assertOnlyDeepEqual([null, undefined, undefined], [null, undefined, null]);
assertNotDeepOrStrict([null, undefined, undefined, 1], [null, undefined, null, 2]);
});

test('date', () => {
assertNotDeepOrStrict(date, date2);
assert.throws(
Expand Down Expand Up @@ -246,6 +251,13 @@ function assertOnlyDeepEqual(a, b, err) {
() => assert.deepStrictEqual(b, a),
err || { code: 'ERR_ASSERTION' }
);

const partial = mustCall(() => {
assert.partialDeepStrictEqual(b, a);
assert.partialDeepStrictEqual(a, b);
});

assert.throws(partial, err || { code: 'ERR_ASSERTION' });
}

test('es6 Maps and Sets', () => {
Expand Down
Loading