test : compare objects not identical by reference

PR-URL: https://github.com/nodejs/node/pull/24189
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Marie Terrier 2018-11-06 17:37:47 +01:00 committed by Gireesh Punathil
parent faa584ab22
commit 5e52e27a76

View File

@ -915,6 +915,27 @@ assert.deepStrictEqual(obj1, obj2);
);
}
// Strict equal with identical objects that are not identical
// by reference and longer than 30 elements
// E.g., assert.deepStrictEqual({ a: Symbol() }, { a: Symbol() })
{
const a = {};
const b = {};
for (let i = 0; i < 35; i++) {
a[`symbol${i}`] = Symbol();
b[`symbol${i}`] = Symbol();
}
assert.throws(
() => assert.deepStrictEqual(a, b),
{
code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]',
message: /\.\.\./g
}
);
}
// Basic valueOf check.
{
const a = new String(1);