From cd740a29d0183e9f58c3df98fe01957e1e70a97d Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 30 Nov 2019 16:02:37 -0800 Subject: [PATCH] test: assert: fix deepStrictEqual comparing a real array and fake array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/30743 Reviewed-By: Rich Trott Reviewed-By: Michaƫl Zasso --- test/parallel/test-assert-deep.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 87f2a5f44f7d64..4f928bf4a08a40 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -1050,6 +1050,21 @@ assert.throws( assert.deepStrictEqual(a, b); } +// Verify that an array and the equivalent fake array object +// are correctly compared +{ + const a = [1, 2, 3]; + const o = { + __proto__: Array.prototype, + 0: 1, + 1: 2, + 2: 3, + length: 3, + }; + Object.defineProperty(o, 'length', { enumerable: false }); + assertNotDeepOrStrict(o, a); +} + // Verify that extra keys will be tested for when using fake arrays. { const a = {