Skip to content
Merged
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
17 changes: 11 additions & 6 deletions lib/internal/util/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,10 @@ function setObjectEquiv(array, a, b, mode, memo) {
if (b.has(val1)) {
continue;
}
} else if (mode !== kLoose || b.has(val1)) {
} else if (b.has(val1)) {
continue;
} else if (mode !== kLoose) {
return false;
}
}

Expand Down Expand Up @@ -816,11 +818,14 @@ function mapObjectEquiv(array, a, b, mode, memo) {
const extraChecks = mode === kLoose || array.length !== a.size;

for (const { 0: key1, 1: item1 } of a) {
if (extraChecks &&
(typeof key1 !== 'object' || key1 === null) &&
(mode !== kLoose ||
(b.has(key1) && innerDeepEqual(item1, b.get(key1), mode, memo)))) { // Mixed mode
continue;
if (extraChecks && (typeof key1 !== 'object' || key1 === null)) {
if (b.has(key1)) {
if (mode !== kLoose || innerDeepEqual(item1, b.get(key1), mode, memo)) {
continue;
}
} else if (mode !== kLoose) {
return false;
}
}

let innerStart = start;
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-assert-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,21 @@ test('Handle sparse arrays', () => {
assertNotDeepOrStrict(a, b, AssertionError, { partial: 'pass' });
});

test('Handle sets and maps with mixed keys', () => {
// https://github.com/nodejs/node/issues/61386
const aSet = new Set([0, new Set([1, 2, 3]), new Set([4, 5, 6])]);
const bSet = new Set([
0,
new Set([1, new Set([2, 3]), new Set([20, 30])]),
new Set([4, new Set([5, 6]), new Set([50, 60])]),
]);
assertNotDeepOrStrict(aSet, bSet);

const aMap = new Map([[0, 'zero'], [1, 'one'], [new Set([1, 2, 3]), 'A']]);
const bMap = new Map([[0, 'zero'], [new Set([1, 2, 3]), 'A'], [new Set([9]), 'B']]);
assertNotDeepOrStrict(aMap, bMap);
});

test('Handle different error messages', () => {
const err1 = new Error('foo1');
assertNotDeepOrStrict(err1, new Error('foo2'), assert.AssertionError);
Expand Down
4 changes: 2 additions & 2 deletions vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -749,15 +749,15 @@ if errorlevel 1 goto exit
goto lint-cpp

:lint-cpp
if not defined lint_cpp goto lint-js
if not defined lint_cpp goto lint-js-build
if defined NODEJS_MAKE goto run-make-lint
where make > NUL 2>&1 && make -v | findstr /C:"GNU Make" 1> NUL
if "%ERRORLEVEL%"=="0" set "NODEJS_MAKE=make PYTHON=python" & goto run-make-lint
where wsl > NUL 2>&1
if "%ERRORLEVEL%"=="0" set "NODEJS_MAKE=wsl make" & goto run-make-lint
echo Could not find GNU Make, needed for linting C/C++
echo Alternatively, you can use WSL
goto lint-js
goto lint-js-build

:run-make-lint
%NODEJS_MAKE% lint-cpp
Expand Down
Loading