From 6d42c95acbb8b9377ae9c865d12bcb8c2c3373e5 Mon Sep 17 00:00:00 2001 From: Marie Terrier Date: Tue, 6 Nov 2018 17:37:47 +0100 Subject: [PATCH] test : add strict equal of identical objects not identical by reference --- 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 3a5fca74d4c287..ddbc5e78eafcaf 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -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);