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 <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 4e21eb4 commit 1ec6923

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎test/parallel/test-assert-deep.js‎

Lines changed: 21 additions & 0 deletions
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+
consta={};
955+
constb={};
956+
for(leti=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
consta=newString(1);

0 commit comments

Comments
 (0)