From 1ec6923276728b02b1bf706257d62dd61278e772 Mon Sep 17 00:00:00 2001 From: Marie Terrier Date: Tue, 6 Nov 2018 17:37:47 +0100 Subject: [PATCH] test : compare objects not identical by reference PR-URL: https://github.com/nodejs/node/pull/24189 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca --- test/parallel/test-assert-deep.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index af1003fd51eebe..45f4353ce6c577 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -947,6 +947,27 @@ assert.throws(() => assert.deepStrictEqual(new Boolean(true), {}), ); } +// 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);