diff --git a/tests/unit-global/es.set.difference.js b/tests/unit-global/es.set.difference.js index 62e0cec4daf3..f854cf7d7db8 100644 --- a/tests/unit-global/es.set.difference.js +++ b/tests/unit-global/es.set.difference.js @@ -23,6 +23,26 @@ QUnit.test('Set#difference', assert => { assert.deepEqual(from(new Set([1, 2, 3]).difference([3, 4])), [1, 2]); assert.deepEqual(from(new Set([1, 2, 3]).difference(createIterable([3, 4]))), [1, 2]); + assert.same(new Set([42, 43]).difference({ + size: Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + }).size, 0); + + assert.throws(() => new Set().difference({ + size: -Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + assert.throws(() => new Set([1, 2, 3]).difference(), TypeError); assert.throws(() => difference.call({}, [1, 2, 3]), TypeError); diff --git a/tests/unit-global/es.set.intersection.js b/tests/unit-global/es.set.intersection.js index b033214384c6..64f84283b33e 100644 --- a/tests/unit-global/es.set.intersection.js +++ b/tests/unit-global/es.set.intersection.js @@ -30,6 +30,26 @@ QUnit.test('Set#intersection', assert => { assert.deepEqual(from(new Set([1, 2, 3]).intersection([2, 3, 4])), [2, 3]); assert.deepEqual(from(new Set([1, 2, 3]).intersection(createIterable([2, 3, 4]))), [2, 3]); + assert.deepEqual(from(new Set([42, 43]).intersection({ + size: Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })), [42, 43]); + + assert.throws(() => new Set().intersection({ + size: -Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + assert.throws(() => new Set([1, 2, 3]).intersection(), TypeError); assert.throws(() => intersection.call({}, [1, 2, 3]), TypeError); diff --git a/tests/unit-global/es.set.is-disjoint-from.js b/tests/unit-global/es.set.is-disjoint-from.js index a73c86c883ac..09015f0c2c93 100644 --- a/tests/unit-global/es.set.is-disjoint-from.js +++ b/tests/unit-global/es.set.is-disjoint-from.js @@ -26,6 +26,26 @@ QUnit.test('Set#isDisjointFrom', assert => { assert.true(new Set([1]).isDisjointFrom(createIterable([2]))); assert.false(new Set([1]).isDisjointFrom(createIterable([1]))); + assert.false(new Set([42, 43]).isDisjointFrom({ + size: Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + + assert.throws(() => new Set().isDisjointFrom({ + size: -Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + assert.throws(() => new Set([1, 2, 3]).isDisjointFrom(), TypeError); assert.throws(() => isDisjointFrom.call({}, [1, 2, 3]), TypeError); assert.throws(() => isDisjointFrom.call(undefined, [1, 2, 3]), TypeError); diff --git a/tests/unit-global/es.set.is-subset-of.js b/tests/unit-global/es.set.is-subset-of.js index 4d9ce8427de8..7728a78f9e5b 100644 --- a/tests/unit-global/es.set.is-subset-of.js +++ b/tests/unit-global/es.set.is-subset-of.js @@ -26,6 +26,26 @@ QUnit.test('Set#isSubsetOf', assert => { assert.true(new Set([1]).isSubsetOf(createIterable([1, 2, 3]))); assert.false(new Set([1]).isSubsetOf(createIterable([2, 3, 4]))); + assert.true(new Set([42, 43]).isSubsetOf({ + size: Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + + assert.throws(() => new Set().isSubsetOf({ + size: -Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + assert.throws(() => new Set([1, 2, 3]).isSubsetOf(), TypeError); assert.throws(() => isSubsetOf.call({}, [1, 2, 3]), TypeError); assert.throws(() => isSubsetOf.call(undefined, [1, 2, 3]), TypeError); diff --git a/tests/unit-global/es.set.is-superset-of.js b/tests/unit-global/es.set.is-superset-of.js index a2b74f06590e..bd6cb3256013 100644 --- a/tests/unit-global/es.set.is-superset-of.js +++ b/tests/unit-global/es.set.is-superset-of.js @@ -26,6 +26,26 @@ QUnit.test('Set#isSupersetOf', assert => { assert.true(new Set([1, 2, 3]).isSupersetOf(createIterable([1]))); assert.false(new Set([2, 3, 4]).isSupersetOf(createIterable([1]))); + assert.false(new Set([42, 43]).isSupersetOf({ + size: Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + + assert.throws(() => new Set().isSupersetOf({ + size: -Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + assert.throws(() => new Set([1, 2, 3]).isSupersetOf(), TypeError); assert.throws(() => isSupersetOf.call({}, [1, 2, 3]), TypeError); assert.throws(() => isSupersetOf.call(undefined, [1, 2, 3]), TypeError); diff --git a/tests/unit-pure/es.set.difference.js b/tests/unit-pure/es.set.difference.js index 1d9d572bc1fd..c9c09ca68d0f 100644 --- a/tests/unit-pure/es.set.difference.js +++ b/tests/unit-pure/es.set.difference.js @@ -25,6 +25,26 @@ QUnit.test('Set#difference', assert => { assert.deepEqual(from(new Set([1, 2, 3]).difference([3, 4])), [1, 2]); assert.deepEqual(from(new Set([1, 2, 3]).difference(createIterable([3, 4]))), [1, 2]); + assert.same(new Set([42, 43]).difference({ + size: Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + }).size, 0); + + assert.throws(() => new Set().difference({ + size: -Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + assert.throws(() => new Set([1, 2, 3]).difference(), TypeError); assert.throws(() => difference.call({}, [1, 2, 3]), TypeError); diff --git a/tests/unit-pure/es.set.intersection.js b/tests/unit-pure/es.set.intersection.js index 82193f231407..429905c06a97 100644 --- a/tests/unit-pure/es.set.intersection.js +++ b/tests/unit-pure/es.set.intersection.js @@ -32,6 +32,26 @@ QUnit.test('Set#intersection', assert => { assert.deepEqual(from(new Set([1, 2, 3]).intersection([2, 3, 4])), [2, 3]); assert.deepEqual(from(new Set([1, 2, 3]).intersection(createIterable([2, 3, 4]))), [2, 3]); + assert.deepEqual(from(new Set([42, 43]).intersection({ + size: Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })), [42, 43]); + + assert.throws(() => new Set().intersection({ + size: -Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + assert.throws(() => new Set([1, 2, 3]).intersection(), TypeError); assert.throws(() => intersection.call({}, [1, 2, 3]), TypeError); diff --git a/tests/unit-pure/es.set.is-disjoint-from.js b/tests/unit-pure/es.set.is-disjoint-from.js index 79342ead7c6c..96e18d8389bc 100644 --- a/tests/unit-pure/es.set.is-disjoint-from.js +++ b/tests/unit-pure/es.set.is-disjoint-from.js @@ -28,6 +28,26 @@ QUnit.test('Set#isDisjointFrom', assert => { assert.true(new Set([1]).isDisjointFrom(createIterable([2]))); assert.false(new Set([1]).isDisjointFrom(createIterable([1]))); + assert.false(new Set([42, 43]).isDisjointFrom({ + size: Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + + assert.throws(() => new Set().isDisjointFrom({ + size: -Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + assert.throws(() => new Set([1, 2, 3]).isDisjointFrom(), TypeError); assert.throws(() => isDisjointFrom.call({}, [1, 2, 3]), TypeError); assert.throws(() => isDisjointFrom.call(undefined, [1, 2, 3]), TypeError); diff --git a/tests/unit-pure/es.set.is-subset-of.js b/tests/unit-pure/es.set.is-subset-of.js index 4378207a0a29..556e1c0d1d3f 100644 --- a/tests/unit-pure/es.set.is-subset-of.js +++ b/tests/unit-pure/es.set.is-subset-of.js @@ -28,6 +28,26 @@ QUnit.test('Set#isSubsetOf', assert => { assert.true(new Set([1]).isSubsetOf(createIterable([1, 2, 3]))); assert.false(new Set([1]).isSubsetOf(createIterable([2, 3, 4]))); + assert.true(new Set([42, 43]).isSubsetOf({ + size: Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + + assert.throws(() => new Set().isSubsetOf({ + size: -Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + assert.throws(() => new Set([1, 2, 3]).isSubsetOf(), TypeError); assert.throws(() => isSubsetOf.call({}, [1, 2, 3]), TypeError); assert.throws(() => isSubsetOf.call(undefined, [1, 2, 3]), TypeError); diff --git a/tests/unit-pure/es.set.is-superset-of.js b/tests/unit-pure/es.set.is-superset-of.js index 8cdc987abb9e..f4860ba6dd97 100644 --- a/tests/unit-pure/es.set.is-superset-of.js +++ b/tests/unit-pure/es.set.is-superset-of.js @@ -28,6 +28,26 @@ QUnit.test('Set#isSupersetOf', assert => { assert.true(new Set([1, 2, 3]).isSupersetOf(createIterable([1]))); assert.false(new Set([2, 3, 4]).isSupersetOf(createIterable([1]))); + assert.false(new Set([42, 43]).isSupersetOf({ + size: Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + + assert.throws(() => new Set().isSupersetOf({ + size: -Infinity, + has() { + return true; + }, + keys() { + throw new Error('Unexpected call to |keys| method'); + }, + })); + assert.throws(() => new Set([1, 2, 3]).isSupersetOf(), TypeError); assert.throws(() => isSupersetOf.call({}, [1, 2, 3]), TypeError); assert.throws(() => isSupersetOf.call(undefined, [1, 2, 3]), TypeError);