Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
assert,util: fix commutativity edge case
Verify that both objects property keys are enumerable.

Fixes: #37710

PR-URL: #37711
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
BridgeAR authored and targos committed May 1, 2021
1 parent a191bc7 commit 9fb10dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/util/comparisons.js
Expand Up @@ -315,7 +315,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
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);
}

0 comments on commit 9fb10dc

Please sign in to comment.