Skip to content

Commit

Permalink
Test: Add equiv test for two sets containing the same by-ref array
Browse files Browse the repository at this point in the history
Inspired by nodejs/node#53423.
Already works here, but might as well cover it going forward.
  • Loading branch information
Krinkle committed Jul 24, 2024
1 parent a729421 commit 3a09b40
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/main/deepEqual.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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]);
Expand Down

0 comments on commit 3a09b40

Please sign in to comment.