Replace assertThrowsInstanceOf with assert.throws in sm/Set

This commit is contained in:
André Bargull 2025-04-30 14:15:48 +02:00 committed by Philip Chimento
parent 40b3946818
commit 2fe9977b83
7 changed files with 54 additions and 54 deletions

View File

@ -160,7 +160,7 @@ for (let values of [
]); ]);
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => new Set([1]).difference(setLike), TypeError); assert.throws(TypeError, () => new Set([1]).difference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -185,7 +185,7 @@ for (let values of [
]); ]);
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => new Set([1]).difference(setLike), TypeError); assert.throws(TypeError, () => new Set([1]).difference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -198,7 +198,7 @@ for (let values of [
setLikeObj.keys = nonCallable; setLikeObj.keys = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.difference(setLike), TypeError); assert.throws(TypeError, () => emptySet.difference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -211,7 +211,7 @@ for (let values of [
setLikeObj.has = nonCallable; setLikeObj.has = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.difference(setLike), TypeError); assert.throws(TypeError, () => emptySet.difference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -223,7 +223,7 @@ for (let values of [
sizeValue = NaN; sizeValue = NaN;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.difference(setLike), TypeError); assert.throws(TypeError, () => emptySet.difference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -234,7 +234,7 @@ for (let values of [
sizeValue = undefined; sizeValue = undefined;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.difference(setLike), TypeError); assert.throws(TypeError, () => emptySet.difference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -243,7 +243,7 @@ for (let values of [
} }
// Doesn't accept Array as an input. // Doesn't accept Array as an input.
assertThrowsInstanceOf(() => emptySet.difference([]), TypeError); assert.throws(TypeError, () => emptySet.difference([]));
// Works with Set subclasses. // Works with Set subclasses.
{ {
@ -274,7 +274,7 @@ assertThrowsInstanceOf(() => emptySet.difference([]), TypeError);
for (let thisValue of [ for (let thisValue of [
null, undefined, true, "", {}, new Map, new Proxy(new Set, {}), null, undefined, true, "", {}, new Map, new Proxy(new Set, {}),
]) { ]) {
assertThrowsInstanceOf(() => Set.prototype.difference.call(thisValue, emptySet), TypeError); assert.throws(TypeError, () => Set.prototype.difference.call(thisValue, emptySet));
} }
// Doesn't return the original Set object. // Doesn't return the original Set object.

View File

@ -160,7 +160,7 @@ for (let values of [
]); ]);
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => new Set([1]).intersection(setLike), TypeError); assert.throws(TypeError, () => new Set([1]).intersection(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -185,7 +185,7 @@ for (let values of [
]); ]);
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => new Set([1]).intersection(setLike), TypeError); assert.throws(TypeError, () => new Set([1]).intersection(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -198,7 +198,7 @@ for (let values of [
setLikeObj.keys = nonCallable; setLikeObj.keys = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.intersection(setLike), TypeError); assert.throws(TypeError, () => emptySet.intersection(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -211,7 +211,7 @@ for (let values of [
setLikeObj.has = nonCallable; setLikeObj.has = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.intersection(setLike), TypeError); assert.throws(TypeError, () => emptySet.intersection(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -223,7 +223,7 @@ for (let values of [
sizeValue = NaN; sizeValue = NaN;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.intersection(setLike), TypeError); assert.throws(TypeError, () => emptySet.intersection(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -234,7 +234,7 @@ for (let values of [
sizeValue = undefined; sizeValue = undefined;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.intersection(setLike), TypeError); assert.throws(TypeError, () => emptySet.intersection(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -243,7 +243,7 @@ for (let values of [
} }
// Doesn't accept Array as an input. // Doesn't accept Array as an input.
assertThrowsInstanceOf(() => emptySet.intersection([]), TypeError); assert.throws(TypeError, () => emptySet.intersection([]));
// Works with Set subclasses. // Works with Set subclasses.
{ {
@ -274,7 +274,7 @@ assertThrowsInstanceOf(() => emptySet.intersection([]), TypeError);
for (let thisValue of [ for (let thisValue of [
null, undefined, true, "", {}, new Map, new Proxy(new Set, {}), null, undefined, true, "", {}, new Map, new Proxy(new Set, {}),
]) { ]) {
assertThrowsInstanceOf(() => Set.prototype.intersection.call(thisValue, emptySet), TypeError); assert.throws(TypeError, () => Set.prototype.intersection.call(thisValue, emptySet));
} }
// Doesn't return the original Set object. // Doesn't return the original Set object.

View File

@ -145,7 +145,7 @@ for (let values of [
]); ]);
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => new Set([1]).isDisjointFrom(setLike), TypeError); assert.throws(TypeError, () => new Set([1]).isDisjointFrom(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -170,7 +170,7 @@ for (let values of [
]); ]);
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => new Set([1]).isDisjointFrom(setLike), TypeError); assert.throws(TypeError, () => new Set([1]).isDisjointFrom(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -183,7 +183,7 @@ for (let values of [
setLikeObj.keys = nonCallable; setLikeObj.keys = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isDisjointFrom(setLike), TypeError); assert.throws(TypeError, () => emptySet.isDisjointFrom(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -196,7 +196,7 @@ for (let values of [
setLikeObj.has = nonCallable; setLikeObj.has = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isDisjointFrom(setLike), TypeError); assert.throws(TypeError, () => emptySet.isDisjointFrom(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -208,7 +208,7 @@ for (let values of [
sizeValue = NaN; sizeValue = NaN;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isDisjointFrom(setLike), TypeError); assert.throws(TypeError, () => emptySet.isDisjointFrom(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -219,7 +219,7 @@ for (let values of [
sizeValue = undefined; sizeValue = undefined;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isDisjointFrom(setLike), TypeError); assert.throws(TypeError, () => emptySet.isDisjointFrom(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -228,7 +228,7 @@ for (let values of [
} }
// Doesn't accept Array as an input. // Doesn't accept Array as an input.
assertThrowsInstanceOf(() => emptySet.isDisjointFrom([]), TypeError); assert.throws(TypeError, () => emptySet.isDisjointFrom([]));
// Works with Set subclasses. // Works with Set subclasses.
{ {
@ -259,7 +259,7 @@ assertThrowsInstanceOf(() => emptySet.isDisjointFrom([]), TypeError);
for (let thisValue of [ for (let thisValue of [
null, undefined, true, "", {}, new Map, new Proxy(new Set, {}), null, undefined, true, "", {}, new Map, new Proxy(new Set, {}),
]) { ]) {
assertThrowsInstanceOf(() => Set.prototype.isDisjointFrom.call(thisValue, emptySet), TypeError); assert.throws(TypeError, () => Set.prototype.isDisjointFrom.call(thisValue, emptySet));
} }
// Calls |has| when the this-value has fewer keys. // Calls |has| when the this-value has fewer keys.

View File

@ -118,7 +118,7 @@ for (let values of [
setLikeObj.keys = nonCallable; setLikeObj.keys = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isSubsetOf(setLike), TypeError); assert.throws(TypeError, () => emptySet.isSubsetOf(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -131,7 +131,7 @@ for (let values of [
setLikeObj.has = nonCallable; setLikeObj.has = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isSubsetOf(setLike), TypeError); assert.throws(TypeError, () => emptySet.isSubsetOf(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -143,7 +143,7 @@ for (let values of [
sizeValue = NaN; sizeValue = NaN;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isSubsetOf(setLike), TypeError); assert.throws(TypeError, () => emptySet.isSubsetOf(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -154,7 +154,7 @@ for (let values of [
sizeValue = undefined; sizeValue = undefined;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isSubsetOf(setLike), TypeError); assert.throws(TypeError, () => emptySet.isSubsetOf(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -163,7 +163,7 @@ for (let values of [
} }
// Doesn't accept Array as an input. // Doesn't accept Array as an input.
assertThrowsInstanceOf(() => emptySet.isSubsetOf([]), TypeError); assert.throws(TypeError, () => emptySet.isSubsetOf([]));
// Works with Set subclasses. // Works with Set subclasses.
{ {
@ -194,7 +194,7 @@ assertThrowsInstanceOf(() => emptySet.isSubsetOf([]), TypeError);
for (let thisValue of [ for (let thisValue of [
null, undefined, true, "", {}, new Map, new Proxy(new Set, {}), null, undefined, true, "", {}, new Map, new Proxy(new Set, {}),
]) { ]) {
assertThrowsInstanceOf(() => Set.prototype.isSubsetOf.call(thisValue, emptySet), TypeError); assert.throws(TypeError, () => Set.prototype.isSubsetOf.call(thisValue, emptySet));
} }
// Doesn't call |has| when this-value has more elements. // Doesn't call |has| when this-value has more elements.

View File

@ -136,7 +136,7 @@ for (let values of [
}, log); }, log);
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isSupersetOf(setLike), TypeError); assert.throws(TypeError, () => emptySet.isSupersetOf(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -151,7 +151,7 @@ for (let values of [
setLikeObj.keys = () => 123; setLikeObj.keys = () => 123;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isSupersetOf(setLike), TypeError); assert.throws(TypeError, () => emptySet.isSupersetOf(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -164,7 +164,7 @@ for (let values of [
setLikeObj.keys = nonCallable; setLikeObj.keys = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isSupersetOf(setLike), TypeError); assert.throws(TypeError, () => emptySet.isSupersetOf(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -177,7 +177,7 @@ for (let values of [
setLikeObj.has = nonCallable; setLikeObj.has = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isSupersetOf(setLike), TypeError); assert.throws(TypeError, () => emptySet.isSupersetOf(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -189,7 +189,7 @@ for (let values of [
sizeValue = NaN; sizeValue = NaN;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isSupersetOf(setLike), TypeError); assert.throws(TypeError, () => emptySet.isSupersetOf(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -200,7 +200,7 @@ for (let values of [
sizeValue = undefined; sizeValue = undefined;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.isSupersetOf(setLike), TypeError); assert.throws(TypeError, () => emptySet.isSupersetOf(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -209,7 +209,7 @@ for (let values of [
} }
// Doesn't accept Array as an input. // Doesn't accept Array as an input.
assertThrowsInstanceOf(() => emptySet.isSupersetOf([]), TypeError); assert.throws(TypeError, () => emptySet.isSupersetOf([]));
// Works with Set subclasses. // Works with Set subclasses.
{ {
@ -240,7 +240,7 @@ assertThrowsInstanceOf(() => emptySet.isSupersetOf([]), TypeError);
for (let thisValue of [ for (let thisValue of [
null, undefined, true, "", {}, new Map, new Proxy(new Set, {}), null, undefined, true, "", {}, new Map, new Proxy(new Set, {}),
]) { ]) {
assertThrowsInstanceOf(() => Set.prototype.isSupersetOf.call(thisValue, emptySet), TypeError); assert.throws(TypeError, () => Set.prototype.isSupersetOf.call(thisValue, emptySet));
} }
// Doesn't call |has| nor |keys| when this-value has fewer elements. // Doesn't call |has| nor |keys| when this-value has fewer elements.

View File

@ -123,7 +123,7 @@ for (let values of [
}, log); }, log);
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.symmetricDifference(setLike), TypeError); assert.throws(TypeError, () => emptySet.symmetricDifference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -138,7 +138,7 @@ for (let values of [
setLikeObj.keys = () => 123; setLikeObj.keys = () => 123;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.symmetricDifference(setLike), TypeError); assert.throws(TypeError, () => emptySet.symmetricDifference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -151,7 +151,7 @@ for (let values of [
setLikeObj.keys = nonCallable; setLikeObj.keys = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.symmetricDifference(setLike), TypeError); assert.throws(TypeError, () => emptySet.symmetricDifference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -164,7 +164,7 @@ for (let values of [
setLikeObj.has = nonCallable; setLikeObj.has = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.symmetricDifference(setLike), TypeError); assert.throws(TypeError, () => emptySet.symmetricDifference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -176,7 +176,7 @@ for (let values of [
sizeValue = NaN; sizeValue = NaN;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.symmetricDifference(setLike), TypeError); assert.throws(TypeError, () => emptySet.symmetricDifference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -187,7 +187,7 @@ for (let values of [
sizeValue = undefined; sizeValue = undefined;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.symmetricDifference(setLike), TypeError); assert.throws(TypeError, () => emptySet.symmetricDifference(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -196,7 +196,7 @@ for (let values of [
} }
// Doesn't accept Array as an input. // Doesn't accept Array as an input.
assertThrowsInstanceOf(() => emptySet.symmetricDifference([]), TypeError); assert.throws(TypeError, () => emptySet.symmetricDifference([]));
// Works with Set subclasses. // Works with Set subclasses.
{ {
@ -227,7 +227,7 @@ assertThrowsInstanceOf(() => emptySet.symmetricDifference([]), TypeError);
for (let thisValue of [ for (let thisValue of [
null, undefined, true, "", {}, new Map, new Proxy(new Set, {}), null, undefined, true, "", {}, new Map, new Proxy(new Set, {}),
]) { ]) {
assertThrowsInstanceOf(() => Set.prototype.symmetricDifference.call(thisValue, emptySet), TypeError); assert.throws(TypeError, () => Set.prototype.symmetricDifference.call(thisValue, emptySet));
} }
// Doesn't return the original Set object. // Doesn't return the original Set object.

View File

@ -123,7 +123,7 @@ for (let values of [
}, log); }, log);
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.union(setLike), TypeError); assert.throws(TypeError, () => emptySet.union(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -138,7 +138,7 @@ for (let values of [
setLikeObj.keys = () => 123; setLikeObj.keys = () => 123;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.union(setLike), TypeError); assert.throws(TypeError, () => emptySet.union(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -151,7 +151,7 @@ for (let values of [
setLikeObj.keys = nonCallable; setLikeObj.keys = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.union(setLike), TypeError); assert.throws(TypeError, () => emptySet.union(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -164,7 +164,7 @@ for (let values of [
setLikeObj.has = nonCallable; setLikeObj.has = nonCallable;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.union(setLike), TypeError); assert.throws(TypeError, () => emptySet.union(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -176,7 +176,7 @@ for (let values of [
sizeValue = NaN; sizeValue = NaN;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.union(setLike), TypeError); assert.throws(TypeError, () => emptySet.union(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -187,7 +187,7 @@ for (let values of [
sizeValue = undefined; sizeValue = undefined;
log.length = 0; log.length = 0;
assertThrowsInstanceOf(() => emptySet.union(setLike), TypeError); assert.throws(TypeError, () => emptySet.union(setLike));
assert.compareArray(log, [ assert.compareArray(log, [
"[[get]]", "size", "[[get]]", "size",
@ -196,7 +196,7 @@ for (let values of [
} }
// Doesn't accept Array as an input. // Doesn't accept Array as an input.
assertThrowsInstanceOf(() => emptySet.union([]), TypeError); assert.throws(TypeError, () => emptySet.union([]));
// Works with Set subclasses. // Works with Set subclasses.
{ {
@ -227,7 +227,7 @@ assertThrowsInstanceOf(() => emptySet.union([]), TypeError);
for (let thisValue of [ for (let thisValue of [
null, undefined, true, "", {}, new Map, new Proxy(new Set, {}), null, undefined, true, "", {}, new Map, new Proxy(new Set, {}),
]) { ]) {
assertThrowsInstanceOf(() => Set.prototype.union.call(thisValue, emptySet), TypeError); assert.throws(TypeError, () => Set.prototype.union.call(thisValue, emptySet));
} }
// Doesn't return the original Set object. // Doesn't return the original Set object.