Skip to content

Commit 1ec6923

Browse files
meelieMylesBorins
authored andcommitted
test : compare objects not identical by reference
PR-URL: #24189 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 4e21eb4 commit 1ec6923

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/parallel/test-assert-deep.js

+21
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,27 @@ assert.throws(() => assert.deepStrictEqual(new Boolean(true), {}),
947947
);
948948
}
949949

950+
// Strict equal with identical objects that are not identical
951+
// by reference and longer than 30 elements
952+
// E.g., assert.deepStrictEqual({ a: Symbol() }, { a: Symbol() })
953+
{
954+
const a = {};
955+
const b = {};
956+
for (let i = 0; i < 35; i++) {
957+
a[`symbol${i}`] = Symbol();
958+
b[`symbol${i}`] = Symbol();
959+
}
960+
961+
assert.throws(
962+
() => assert.deepStrictEqual(a, b),
963+
{
964+
code: 'ERR_ASSERTION',
965+
name: 'AssertionError [ERR_ASSERTION]',
966+
message: /\.\.\./g
967+
}
968+
);
969+
}
970+
950971
// Basic valueOf check.
951972
{
952973
const a = new String(1);

0 commit comments

Comments
 (0)