From 3a09b40b6eb1f493d22ca4a05f54d5e21f542a25 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 24 Jul 2024 23:03:00 +0100 Subject: [PATCH] Test: Add equiv test for two sets containing the same by-ref array Inspired by https://github.com/nodejs/node/issues/53423. Already works here, but might as well cover it going forward. --- test/main/deepEqual.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/main/deepEqual.js b/test/main/deepEqual.js index 5cf50451d..a384fc617 100644 --- a/test/main/deepEqual.js +++ b/test/main/deepEqual.js @@ -1849,7 +1849,7 @@ QUnit.test.if('Sets', hasES6Set, function (assert) { s2 = new Set([2, 3]); assert.equal(QUnit.equiv(s1, s2), false, "Sets can 'short-circuit' for early failure"); - // Sets Containing objects + // Sets containing the same by-ref objects o1 = { foo: 0, bar: true }; o2 = { foo: 0, bar: true }; o3 = { foo: 1, bar: true }; @@ -1867,6 +1867,13 @@ QUnit.test.if('Sets', hasES6Set, function (assert) { s2 = new Set([o3]); assert.equal(QUnit.equiv(s1, s2), false, 'Sets containing different objects'); + // Sets containing the same by-ref array + // Inspired by https://github.com/nodejs/node/issues/53423 + var a1 = ['x']; + s1 = new Set([a1, ['y']]); + s2 = new Set([a1, ['y']]); + assert.equal(QUnit.equiv(s1, s2), true, 'Sets containing the same by-ref array'); + // Sets containing sets s1 = new Set([1, 2, 3]); s2 = new Set([1, 2, 3]);