Skip to content

assert,util: fix commutativity edge case #37711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2021
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
2 changes: 1 addition & 1 deletion lib/internal/util/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function keyCheck(val1, val2, strict, memos, iterationType, aKeys) {
// Cheap key test
let i = 0;
for (; i < aKeys.length; i++) {
if (!ObjectPrototypeHasOwnProperty(val2, aKeys[i])) {
if (!ObjectPrototypePropertyIsEnumerable(val2, aKeys[i])) {
return false;
}
}
Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-assert-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -1194,3 +1194,13 @@ assert.throws(
Object.setPrototypeOf(b, null);
assertNotDeepOrStrict(a, b, assert.AssertionError);
}

{
// Verify commutativity
// Regression test for https://github.com/nodejs/node/issues/37710
const a = { x: 1 };
const b = { y: 1 };
Object.defineProperty(b, 'x', { value: 1 });

assertNotDeepOrStrict(a, b);
}