Skip to content

Commit 2593b40

Browse files
meelieBridgeAR
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 26c625c commit 2593b40

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
@@ -915,6 +915,27 @@ assert.deepStrictEqual(obj1, obj2);
915915
);
916916
}
917917

918+
// Strict equal with identical objects that are not identical
919+
// by reference and longer than 30 elements
920+
// E.g., assert.deepStrictEqual({ a: Symbol() }, { a: Symbol() })
921+
{
922+
const a = {};
923+
const b = {};
924+
for (let i = 0; i < 35; i++) {
925+
a[`symbol${i}`] = Symbol();
926+
b[`symbol${i}`] = Symbol();
927+
}
928+
929+
assert.throws(
930+
() => assert.deepStrictEqual(a, b),
931+
{
932+
code: 'ERR_ASSERTION',
933+
name: 'AssertionError [ERR_ASSERTION]',
934+
message: /\.\.\./g
935+
}
936+
);
937+
}
938+
918939
// Basic valueOf check.
919940
{
920941
const a = new String(1);

0 commit comments

Comments
 (0)