mirror of
https://github.com/tc39/test262.git
synced 2025-12-01 11:03:13 +01:00
Replace assertThrowsInstanceOf with assert.throws in sm/TypedArray
This commit is contained in:
parent
23d9d1ad9d
commit
68acce80ed
@ -41,9 +41,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.at.call(invalidReceiver);
|
||||
}, TypeError, "Assert that 'at' fails if this value is not a TypedArray");
|
||||
}, "Assert that 'at' fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
|
||||
@ -11,7 +11,7 @@ esid: pending
|
||||
---*/
|
||||
const testArray = [1n];
|
||||
for (const constructor of anyTypedArrayConstructors) {
|
||||
assertThrowsInstanceOf(() => new constructor(testArray), TypeError);
|
||||
assertThrowsInstanceOf(() => new constructor(testArray.values()), TypeError);
|
||||
assert.throws(TypeError, () => new constructor(testArray));
|
||||
assert.throws(TypeError, () => new constructor(testArray.values()));
|
||||
}
|
||||
|
||||
|
||||
@ -70,8 +70,8 @@ function ValueReturning(value, detach) {
|
||||
for (let {buffer} of createBuffers()) {
|
||||
let constructor = ConstructorWithThrowingPrototype();
|
||||
|
||||
assertThrowsInstanceOf(() =>
|
||||
Reflect.construct(Int32Array, [buffer, poisonedValue, 0], constructor), ExpectedError);
|
||||
assert.throws(ExpectedError, () =>
|
||||
Reflect.construct(Int32Array, [buffer, poisonedValue, 0], constructor));
|
||||
}
|
||||
|
||||
// Ensure step 4 |AllocateTypedArray| is executed before step 9 |IsDetachedBuffer(buffer)|.
|
||||
@ -79,8 +79,8 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
let constructor = ConstructorWithThrowingPrototype();
|
||||
|
||||
detach();
|
||||
assertThrowsInstanceOf(() =>
|
||||
Reflect.construct(Int32Array, [buffer, 0, 0], constructor), ExpectedError);
|
||||
assert.throws(ExpectedError, () =>
|
||||
Reflect.construct(Int32Array, [buffer, 0, 0], constructor));
|
||||
}
|
||||
|
||||
// Ensure step 4 |AllocateTypedArray| is executed before step 9 |IsDetachedBuffer(buffer)|.
|
||||
@ -88,16 +88,16 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
for (let {buffer, detach} of createBuffers()) {
|
||||
let constructor = ConstructorWithThrowingPrototype(detach);
|
||||
|
||||
assertThrowsInstanceOf(() =>
|
||||
Reflect.construct(Int32Array, [buffer, 0, 0], constructor), ExpectedError);
|
||||
assert.throws(ExpectedError, () =>
|
||||
Reflect.construct(Int32Array, [buffer, 0, 0], constructor));
|
||||
}
|
||||
|
||||
// Ensure step 4 |AllocateTypedArray| is executed before step 8.a |ToIndex(length)|.
|
||||
for (let {buffer} of createBuffers()) {
|
||||
let constructor = ConstructorWithThrowingPrototype();
|
||||
|
||||
assertThrowsInstanceOf(() =>
|
||||
Reflect.construct(Int32Array, [buffer, 0, poisonedValue], constructor), ExpectedError);
|
||||
assert.throws(ExpectedError, () =>
|
||||
Reflect.construct(Int32Array, [buffer, 0, poisonedValue], constructor));
|
||||
}
|
||||
|
||||
// Ensure step 6 |ToIndex(byteOffset)| is executed before step 9 |IsDetachedBuffer(buffer)|.
|
||||
@ -105,7 +105,7 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = ValueThrowing();
|
||||
|
||||
detach();
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, 0), ExpectedError);
|
||||
assert.throws(ExpectedError, () => new Int32Array(buffer, byteOffset, 0));
|
||||
}
|
||||
|
||||
// Ensure step 6 |ToIndex(byteOffset)| is executed before step 9 |IsDetachedBuffer(buffer)|.
|
||||
@ -113,14 +113,14 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = ValueThrowing(detach);
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, 0), ExpectedError);
|
||||
assert.throws(ExpectedError, () => new Int32Array(buffer, byteOffset, 0));
|
||||
}
|
||||
|
||||
// Ensure step 6 |ToIndex(byteOffset)| is executed before step 8.a |ToIndex(length)|.
|
||||
for (let {buffer} of createBuffers()) {
|
||||
let byteOffset = ValueThrowing();
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, poisonedValue), ExpectedError);
|
||||
assert.throws(ExpectedError, () => new Int32Array(buffer, byteOffset, poisonedValue));
|
||||
}
|
||||
|
||||
// Ensure step 7 |offset modulo elementSize ≠ 0| is executed before step 9 |IsDetachedBuffer(buffer)|.
|
||||
@ -128,7 +128,7 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = 1;
|
||||
|
||||
detach();
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, 0), RangeError);
|
||||
assert.throws(RangeError, () => new Int32Array(buffer, byteOffset, 0));
|
||||
}
|
||||
|
||||
// Ensure step 7 |offset modulo elementSize ≠ 0| is executed before step 9 |IsDetachedBuffer(buffer)|.
|
||||
@ -136,12 +136,12 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = ValueReturning(1, detach);
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, 0), RangeError);
|
||||
assert.throws(RangeError, () => new Int32Array(buffer, byteOffset, 0));
|
||||
}
|
||||
|
||||
// Ensure step 7 |offset modulo elementSize ≠ 0| is executed before step 8.a |ToIndex(length)|.
|
||||
for (let {buffer} of createBuffers()) {
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, 1, poisonedValue), RangeError);
|
||||
assert.throws(RangeError, () => new Int32Array(buffer, 1, poisonedValue));
|
||||
}
|
||||
|
||||
// Ensure step 8.a |ToIndex(length)| is executed before step 9 |IsDetachedBuffer(buffer)|.
|
||||
@ -150,7 +150,7 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
let length = ValueThrowing();
|
||||
|
||||
detach();
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, length), ExpectedError);
|
||||
assert.throws(ExpectedError, () => new Int32Array(buffer, byteOffset, length));
|
||||
}
|
||||
|
||||
// Ensure step 8.a |ToIndex(length)| is executed before step 9 |IsDetachedBuffer(buffer)|.
|
||||
@ -159,7 +159,7 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = ValueReturning(0, detach);
|
||||
let length = ValueThrowing();
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, length), ExpectedError);
|
||||
assert.throws(ExpectedError, () => new Int32Array(buffer, byteOffset, length));
|
||||
}
|
||||
|
||||
// Ensure step 8.a |ToIndex(length)| is executed before step 9 |IsDetachedBuffer(buffer)|.
|
||||
@ -168,7 +168,7 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = 0;
|
||||
let length = ValueThrowing(detach);
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, length), ExpectedError);
|
||||
assert.throws(ExpectedError, () => new Int32Array(buffer, byteOffset, length));
|
||||
}
|
||||
|
||||
// Ensure step 9 |IsDetachedBuffer(buffer)| is executed before step 11.a |bufferByteLength modulo elementSize ≠ 0|.
|
||||
@ -176,7 +176,7 @@ for (let {buffer, detach} of createBuffers([1, 9])) {
|
||||
let byteOffset = 0;
|
||||
|
||||
detach();
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset), TypeError);
|
||||
assert.throws(TypeError, () => new Int32Array(buffer, byteOffset));
|
||||
}
|
||||
|
||||
// Ensure step 9 |IsDetachedBuffer(buffer)| is executed before step 11.a |bufferByteLength modulo elementSize ≠ 0|.
|
||||
@ -184,7 +184,7 @@ for (let {buffer, detach} of createBuffers([1, 9])) {
|
||||
for (let {buffer, detach} of createBuffers([1, 9])) {
|
||||
let byteOffset = ValueReturning(0, detach);
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset), TypeError);
|
||||
assert.throws(TypeError, () => new Int32Array(buffer, byteOffset));
|
||||
}
|
||||
|
||||
// Ensure step 9 |IsDetachedBuffer(buffer)| is executed before step 11.c |newByteLength < 0|.
|
||||
@ -192,7 +192,7 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = 64;
|
||||
|
||||
detach();
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset), TypeError);
|
||||
assert.throws(TypeError, () => new Int32Array(buffer, byteOffset));
|
||||
}
|
||||
|
||||
// Ensure step 9 |IsDetachedBuffer(buffer)| is executed before step 11.c |newByteLength < 0|.
|
||||
@ -200,7 +200,7 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = ValueReturning(64, detach);
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset), TypeError);
|
||||
assert.throws(TypeError, () => new Int32Array(buffer, byteOffset));
|
||||
}
|
||||
|
||||
// Ensure step 9 |IsDetachedBuffer(buffer)| is executed before step 12.b |offset+newByteLength > bufferByteLength|.
|
||||
@ -209,7 +209,7 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = 64;
|
||||
let length = ValueReturning(0, detach);
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, length), TypeError);
|
||||
assert.throws(TypeError, () => new Int32Array(buffer, byteOffset, length));
|
||||
}
|
||||
|
||||
// Ensure step 9 |IsDetachedBuffer(buffer)| is executed before step 12.b |offset+newByteLength > bufferByteLength|.
|
||||
@ -218,7 +218,7 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = 0;
|
||||
let length = ValueReturning(64, detach);
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, length), TypeError);
|
||||
assert.throws(TypeError, () => new Int32Array(buffer, byteOffset, length));
|
||||
}
|
||||
|
||||
// Ensure we handle the case when ToIndex(byteOffset) detaches the array buffer.
|
||||
@ -226,7 +226,7 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = ValueReturning(0, detach);
|
||||
let length = 0;
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, length), TypeError);
|
||||
assert.throws(TypeError, () => new Int32Array(buffer, byteOffset, length));
|
||||
}
|
||||
|
||||
// Ensure we handle the case when ToIndex(length) detaches the array buffer.
|
||||
@ -234,6 +234,6 @@ for (let {buffer, detach} of createBuffers()) {
|
||||
let byteOffset = 0;
|
||||
let length = ValueReturning(0, detach);
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(buffer, byteOffset, length), TypeError);
|
||||
assert.throws(TypeError, () => new Int32Array(buffer, byteOffset, length));
|
||||
}
|
||||
|
||||
|
||||
@ -17,27 +17,27 @@ const ab = new ArrayBuffer(0);
|
||||
|
||||
for (let TA of typedArrayConstructors) {
|
||||
// Test bound checks around INT32_MAX for |byteOffset| argument.
|
||||
assertThrowsInstanceOf(() => new TA(ab, 2**31 - TA.BYTES_PER_ELEMENT), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 2**31 - 1), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 2**31), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 2**31 + 1), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 2**31 + TA.BYTES_PER_ELEMENT), RangeError);
|
||||
assert.throws(RangeError, () => new TA(ab, 2**31 - TA.BYTES_PER_ELEMENT));
|
||||
assert.throws(RangeError, () => new TA(ab, 2**31 - 1));
|
||||
assert.throws(RangeError, () => new TA(ab, 2**31));
|
||||
assert.throws(RangeError, () => new TA(ab, 2**31 + 1));
|
||||
assert.throws(RangeError, () => new TA(ab, 2**31 + TA.BYTES_PER_ELEMENT));
|
||||
|
||||
// Test bound checks around UINT32_MAX for |byteOffset| argument.
|
||||
assertThrowsInstanceOf(() => new TA(ab, 2**32 - TA.BYTES_PER_ELEMENT), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 2**32 - 1), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 2**32), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 2**32 + 1), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 2**32 + TA.BYTES_PER_ELEMENT), RangeError);
|
||||
assert.throws(RangeError, () => new TA(ab, 2**32 - TA.BYTES_PER_ELEMENT));
|
||||
assert.throws(RangeError, () => new TA(ab, 2**32 - 1));
|
||||
assert.throws(RangeError, () => new TA(ab, 2**32));
|
||||
assert.throws(RangeError, () => new TA(ab, 2**32 + 1));
|
||||
assert.throws(RangeError, () => new TA(ab, 2**32 + TA.BYTES_PER_ELEMENT));
|
||||
|
||||
// Test bound checks around INT32_MAX for |length| argument.
|
||||
assertThrowsInstanceOf(() => new TA(ab, 0, 2**31 - 1), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 0, 2**31), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 0, 2**31 + 1), RangeError);
|
||||
assert.throws(RangeError, () => new TA(ab, 0, 2**31 - 1));
|
||||
assert.throws(RangeError, () => new TA(ab, 0, 2**31));
|
||||
assert.throws(RangeError, () => new TA(ab, 0, 2**31 + 1));
|
||||
|
||||
// Test bound checks around UINT32_MAX for |length| argument.
|
||||
assertThrowsInstanceOf(() => new TA(ab, 0, 2**32 - 1), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 0, 2**32), RangeError);
|
||||
assertThrowsInstanceOf(() => new TA(ab, 0, 2**32 + 1), RangeError);
|
||||
assert.throws(RangeError, () => new TA(ab, 0, 2**32 - 1));
|
||||
assert.throws(RangeError, () => new TA(ab, 0, 2**32));
|
||||
assert.throws(RangeError, () => new TA(ab, 0, 2**32 + 1));
|
||||
}
|
||||
|
||||
|
||||
@ -30,9 +30,9 @@ for (let ctor of typedArrayConstructors) {
|
||||
return primitive;
|
||||
}
|
||||
};
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
new ctor(arg);
|
||||
}, TypeError);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,11 +12,11 @@ esid: pending
|
||||
for (var constructor of typedArrayConstructors) {
|
||||
var buf = new constructor();
|
||||
$262.detachArrayBuffer(buf.buffer);
|
||||
assertThrowsInstanceOf(() => new constructor(buf), TypeError);
|
||||
assert.throws(TypeError, () => new constructor(buf));
|
||||
|
||||
var buffer = new ArrayBuffer();
|
||||
$262.detachArrayBuffer(buffer);
|
||||
assertThrowsInstanceOf(() => new constructor(buffer), TypeError);
|
||||
assert.throws(TypeError, () => new constructor(buffer));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -10,10 +10,10 @@ description: |
|
||||
esid: pending
|
||||
---*/
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
assertThrowsInstanceOf(() => constructor(), TypeError);
|
||||
assertThrowsInstanceOf(() => constructor(1), TypeError);
|
||||
assertThrowsInstanceOf(() => constructor.call(null), TypeError);
|
||||
assertThrowsInstanceOf(() => constructor.apply(null, []), TypeError);
|
||||
assertThrowsInstanceOf(() => Reflect.apply(constructor, null, []), TypeError);
|
||||
assert.throws(TypeError, () => constructor());
|
||||
assert.throws(TypeError, () => constructor(1));
|
||||
assert.throws(TypeError, () => constructor.call(null));
|
||||
assert.throws(TypeError, () => constructor.apply(null, []));
|
||||
assert.throws(TypeError, () => Reflect.apply(constructor, null, []));
|
||||
}
|
||||
|
||||
|
||||
@ -14,9 +14,9 @@ esid: pending
|
||||
var AB = new ArrayBuffer(12); // Length divides 4
|
||||
var BC = new ArrayBuffer(14); // Length does not divide 4
|
||||
|
||||
assertThrowsInstanceOf(() => new Int32Array(AB, -1), RangeError); // 22.2.4.5 #8
|
||||
assertThrowsInstanceOf(() => new Int32Array(AB, 2), RangeError); // 22.2.4.5 #10
|
||||
assertThrowsInstanceOf(() => new Int32Array(BC), RangeError); // 22.2.4.5 #13.a
|
||||
assertThrowsInstanceOf(() => new Int32Array(AB, 16), RangeError); // 22.2.4.5 #13.c
|
||||
assertThrowsInstanceOf(() => new Int32Array(AB, 0, 4), RangeError); // 22.2.4.5 #14.c
|
||||
assert.throws(RangeError, () => new Int32Array(AB, -1)); // 22.2.4.5 #8
|
||||
assert.throws(RangeError, () => new Int32Array(AB, 2)); // 22.2.4.5 #10
|
||||
assert.throws(RangeError, () => new Int32Array(BC)); // 22.2.4.5 #13.a
|
||||
assert.throws(RangeError, () => new Int32Array(AB, 16)); // 22.2.4.5 #13.c
|
||||
assert.throws(RangeError, () => new Int32Array(AB, 0, 4)); // 22.2.4.5 #14.c
|
||||
|
||||
|
||||
@ -30,87 +30,87 @@ var POISON = (function() {
|
||||
});
|
||||
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.copyWithin(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.entries();
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.fill(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.filter(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.find(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.findIndex(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.forEach(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.indexOf(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.includes(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.join(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.keys();
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.lastIndexOf(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.map(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.reduce(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.reduceRight(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.reverse();
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.slice(POISON, POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.some(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.values();
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.every(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
array.sort(POISON);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
|
||||
@ -39,9 +39,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.entries.call(invalidReceiver);
|
||||
}, TypeError, "Assert that entries fails if this value is not a TypedArray");
|
||||
}, "Assert that entries fails if this value is not a TypedArray");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -86,14 +86,14 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(count, 3);
|
||||
|
||||
// There is no callback or callback is not a function.
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.every();
|
||||
}, TypeError);
|
||||
});
|
||||
var invalidCallbacks = [undefined, null, 1, false, "", Symbol(), [], {}, /./];
|
||||
invalidCallbacks.forEach(callback => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.every(callback);
|
||||
}, TypeError);
|
||||
});
|
||||
})
|
||||
|
||||
// Callback is a generator.
|
||||
@ -113,9 +113,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.every.call(invalidReceiver, () => true);
|
||||
}, TypeError, "Assert that every fails if this value is not a TypedArray");
|
||||
}, "Assert that every fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
@ -209,14 +209,14 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(count, 3);
|
||||
|
||||
// There is no callback or callback is not a function.
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.some();
|
||||
}, TypeError);
|
||||
});
|
||||
var invalidCallbacks = [undefined, null, 1, false, "", Symbol(), [], {}, /./];
|
||||
invalidCallbacks.forEach(callback => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.some(callback);
|
||||
}, TypeError);
|
||||
});
|
||||
})
|
||||
|
||||
// Callback is a generator.
|
||||
@ -239,9 +239,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.some.call(invalidReceiver, () => true);
|
||||
}, TypeError, "Assert that some fails if this value is not a TypedArray");
|
||||
}, "Assert that some fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
|
||||
@ -33,13 +33,13 @@ function DetachTypedArrayValue(ta, value) {
|
||||
for (let length of [0, 1, 10, 4096]) {
|
||||
let ta = new Int32Array(length);
|
||||
let value = DetachArrayBufferValue(ta.buffer, 123);
|
||||
assertThrowsInstanceOf(() => ta.fill(value), TypeError);
|
||||
assert.throws(TypeError, () => ta.fill(value));
|
||||
}
|
||||
|
||||
// Test when ArrayBuffer is reified during the fill() call.
|
||||
for (let length of [0, 1, 10, 4096]) {
|
||||
let ta = new Int32Array(length);
|
||||
let value = DetachTypedArrayValue(ta, 123);
|
||||
assertThrowsInstanceOf(() => ta.fill(value), TypeError);
|
||||
assert.throws(TypeError, () => ta.fill(value));
|
||||
}
|
||||
|
||||
|
||||
@ -55,9 +55,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.fill.call(invalidReceiver, 1);
|
||||
}, TypeError);
|
||||
});
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
|
||||
@ -35,11 +35,11 @@ anyTypedArrayConstructors.forEach(constructor => {
|
||||
thisValues.push(Symbol());
|
||||
|
||||
thisValues.forEach(thisArg =>
|
||||
assertThrowsInstanceOf(() => arr[method].call(thisArg, () => true), TypeError)
|
||||
assert.throws(TypeError, () => arr[method].call(thisArg, () => true))
|
||||
);
|
||||
|
||||
assertThrowsInstanceOf(() => arr[method](), TypeError);
|
||||
assertThrowsInstanceOf(() => arr[method](1), TypeError);
|
||||
assert.throws(TypeError, () => arr[method]());
|
||||
assert.throws(TypeError, () => arr[method](1));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -35,11 +35,11 @@ anyTypedArrayConstructors.forEach(constructor => {
|
||||
thisValues.push(Symbol());
|
||||
|
||||
thisValues.forEach(thisArg =>
|
||||
assertThrowsInstanceOf(() => arr[method].call(thisArg, () => true), TypeError)
|
||||
assert.throws(TypeError, () => arr[method].call(thisArg, () => true))
|
||||
);
|
||||
|
||||
assertThrowsInstanceOf(() => arr[method](), TypeError);
|
||||
assertThrowsInstanceOf(() => arr[method](1), TypeError);
|
||||
assert.throws(TypeError, () => arr[method]());
|
||||
assert.throws(TypeError, () => arr[method](1));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -65,14 +65,14 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(count, 3);
|
||||
|
||||
// There is no callback or callback is not a function.
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.forEach();
|
||||
}, TypeError);
|
||||
});
|
||||
var invalidCallbacks = [undefined, null, 1, false, "", Symbol(), [], {}, /./];
|
||||
invalidCallbacks.forEach(callback => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.forEach(callback);
|
||||
}, TypeError);
|
||||
});
|
||||
})
|
||||
|
||||
// Callback is a generator.
|
||||
@ -94,9 +94,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.forEach.call(invalidReceiver, () => true);
|
||||
}, TypeError, "Assert that some fails if this value is not a TypedArray");
|
||||
}, "Assert that some fails if this value is not a TypedArray");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -25,9 +25,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
() => ({}) // arrow functions are not constructors
|
||||
];
|
||||
for (var v of nonconstructors) {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.from.call(v, arr);
|
||||
}, TypeError);
|
||||
});
|
||||
}
|
||||
|
||||
// %TypedArray%.from does not get confused if global constructors for typed arrays
|
||||
|
||||
@ -11,9 +11,9 @@ esid: pending
|
||||
---*/
|
||||
for (var constructor of anyTypedArrayConstructors) {
|
||||
// %TypedArray%.from throws if the argument is undefined or null.
|
||||
assertThrowsInstanceOf(() => constructor.from(), TypeError);
|
||||
assertThrowsInstanceOf(() => constructor.from(undefined), TypeError);
|
||||
assertThrowsInstanceOf(() => constructor.from(null), TypeError);
|
||||
assert.throws(TypeError, () => constructor.from());
|
||||
assert.throws(TypeError, () => constructor.from(undefined));
|
||||
assert.throws(TypeError, () => constructor.from(null));
|
||||
|
||||
// Unlike Array.from, %TypedArray%.from doesn't get or set the length property.
|
||||
function ObjectWithThrowingLengthGetterSetter(...rest) {
|
||||
@ -29,12 +29,12 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(ObjectWithThrowingLengthGetterSetter.from([123])[0], 123);
|
||||
|
||||
// %TypedArray%.from throws if mapfn is neither callable nor undefined.
|
||||
assertThrowsInstanceOf(() => constructor.from([3, 4, 5], {}), TypeError);
|
||||
assertThrowsInstanceOf(() => constructor.from([3, 4, 5], "also not a function"), TypeError);
|
||||
assertThrowsInstanceOf(() => constructor.from([3, 4, 5], null), TypeError);
|
||||
assert.throws(TypeError, () => constructor.from([3, 4, 5], {}));
|
||||
assert.throws(TypeError, () => constructor.from([3, 4, 5], "also not a function"));
|
||||
assert.throws(TypeError, () => constructor.from([3, 4, 5], null));
|
||||
|
||||
// Even if the function would not have been called.
|
||||
assertThrowsInstanceOf(() => constructor.from([], JSON), TypeError);
|
||||
assert.throws(TypeError, () => constructor.from([], JSON));
|
||||
|
||||
// If mapfn is not undefined and not callable, the error happens before anything else.
|
||||
// Before calling the constructor, before touching the arrayLike.
|
||||
@ -50,7 +50,7 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
get: function () { log += "2"; },
|
||||
getOwnPropertyDescriptor: function () { log += "3"; }
|
||||
});
|
||||
assertThrowsInstanceOf(() => constructor.from.call(C, p, {}), TypeError);
|
||||
assert.throws(TypeError, () => constructor.from.call(C, p, {}));
|
||||
assert.sameValue(log, "");
|
||||
|
||||
// If mapfn throws, the new object has already been created.
|
||||
@ -66,20 +66,19 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
|
||||
// It's a TypeError if the @@iterator property is a primitive (except null and undefined).
|
||||
for (var primitive of ["foo", 17, Symbol(), true]) {
|
||||
assertThrowsInstanceOf(() => constructor.from({[Symbol.iterator] : primitive}), TypeError);
|
||||
assert.throws(TypeError, () => constructor.from({[Symbol.iterator] : primitive}));
|
||||
}
|
||||
assert.deepEqual(constructor.from({[Symbol.iterator]: null}), new constructor());
|
||||
assert.deepEqual(constructor.from({[Symbol.iterator]: undefined}), new constructor());
|
||||
|
||||
// It's a TypeError if the iterator's .next() method returns a primitive.
|
||||
for (var primitive of [undefined, null, "foo", 17, Symbol(), true]) {
|
||||
assertThrowsInstanceOf(
|
||||
assert.throws(TypeError,
|
||||
() => constructor.from({
|
||||
[Symbol.iterator]() {
|
||||
return {next() { return primitive; }};
|
||||
}
|
||||
}),
|
||||
TypeError);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,6 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(desc.enumerable, false);
|
||||
assert.sameValue(desc.writable, true);
|
||||
assert.sameValue(constructor.from.length, 1);
|
||||
assertThrowsInstanceOf(() => new constructor.from(), TypeError); // not a constructor
|
||||
assert.throws(TypeError, () => new constructor.from()); // not a constructor
|
||||
}
|
||||
|
||||
|
||||
@ -15,5 +15,5 @@ esid: pending
|
||||
var ta = new Int32Array(4);
|
||||
$262.detachArrayBuffer(ta.buffer);
|
||||
|
||||
assertThrowsInstanceOf(() => Int32Array.from(ta), TypeError);
|
||||
assert.throws(TypeError, () => Int32Array.from(ta));
|
||||
|
||||
|
||||
@ -34,9 +34,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.includes.call(invalidReceiver);
|
||||
}, TypeError, "Assert that reverse fails if this value is not a TypedArray");
|
||||
}, "Assert that reverse fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
|
||||
@ -43,9 +43,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.indexOf.call(invalidReceiver);
|
||||
}, TypeError, "Assert that indexOf fails if this value is not a TypedArray");
|
||||
}, "Assert that indexOf fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// test that this.length is never called
|
||||
@ -104,9 +104,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.lastIndexOf.call(invalidReceiver);
|
||||
}, TypeError, "Assert that lastIndexOf fails if this value is not a TypedArray");
|
||||
}, "Assert that lastIndexOf fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
|
||||
@ -68,14 +68,14 @@ if (typeof $262.detachArrayBuffer === "function" && typeof createNewGlobal === "
|
||||
checkResult(thisNext.call(iterator), {value: 2, done: false});
|
||||
|
||||
bufferGlobal.$262.detachArrayBuffer(buffer);
|
||||
assertThrowsInstanceOf(() => thisNext.call(iterator), TypeError);
|
||||
assert.throws(TypeError, () => thisNext.call(iterator));
|
||||
|
||||
// Test an unexhausted iterator.
|
||||
[arr, buffer, iterator] = arrayBufferIterator();
|
||||
checkResult(thisNext.call(iterator), {value: 1, done: false});
|
||||
|
||||
bufferGlobal.$262.detachArrayBuffer(buffer);
|
||||
assertThrowsInstanceOf(() => thisNext.call(iterator), TypeError);
|
||||
assert.throws(TypeError, () => thisNext.call(iterator));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,8 +25,8 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(new constructor(1).join(), "0");
|
||||
assert.sameValue(new constructor(3).join(), "0,0,0");
|
||||
|
||||
assertThrowsInstanceOf(() => new constructor().join({toString(){throw new TypeError}}), TypeError);
|
||||
assertThrowsInstanceOf(() => new constructor().join(Symbol()), TypeError);
|
||||
assert.throws(TypeError, () => new constructor().join({toString(){throw new TypeError}}));
|
||||
assert.throws(TypeError, () => new constructor().join(Symbol()));
|
||||
|
||||
// Called from other globals.
|
||||
if (typeof createNewGlobal === "function") {
|
||||
@ -38,9 +38,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.join.call(invalidReceiver);
|
||||
}, TypeError, "Assert that join fails if this value is not a TypedArray");
|
||||
}, "Assert that join fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
|
||||
@ -37,9 +37,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.keys.call(invalidReceiver);
|
||||
}, TypeError, "Assert that keys fails if this value is not a TypedArray");
|
||||
}, "Assert that keys fails if this value is not a TypedArray");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -94,14 +94,14 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(count, 3);
|
||||
|
||||
// There is no callback or callback is not a function.
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.map();
|
||||
}, TypeError);
|
||||
});
|
||||
var invalidCallbacks = [undefined, null, 1, false, "", Symbol(), [], {}, /./];
|
||||
invalidCallbacks.forEach(callback => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.map(callback);
|
||||
}, TypeError);
|
||||
});
|
||||
})
|
||||
|
||||
// Callback is a generator.
|
||||
@ -121,9 +121,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.filter.call(invalidReceiver, () => true);
|
||||
}, TypeError, "Assert that map fails if this value is not a TypedArray");
|
||||
}, "Assert that map fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
@ -218,14 +218,14 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.sameValue(count, 3);
|
||||
|
||||
// There is no callback or callback is not a function.
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.filter();
|
||||
}, TypeError);
|
||||
});
|
||||
var invalidCallbacks = [undefined, null, 1, false, "", Symbol(), [], {}, /./];
|
||||
invalidCallbacks.forEach(callback => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.filter(callback);
|
||||
}, TypeError);
|
||||
});
|
||||
})
|
||||
|
||||
// Callback is a generator.
|
||||
@ -246,9 +246,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.filter.call(invalidReceiver, () => true);
|
||||
}, TypeError, "Assert that filter fails if this value is not a TypedArray");
|
||||
}, "Assert that filter fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
|
||||
@ -32,8 +32,8 @@ var throws = [
|
||||
];
|
||||
|
||||
for (var desc of throws) {
|
||||
assertThrowsInstanceOf(function() { Object.defineProperty(obj, 0, desc); }, TypeError);
|
||||
assertThrowsInstanceOf(function() { Object.defineProperties(obj, {0: desc}); }, TypeError);
|
||||
assert.throws(TypeError, function() { Object.defineProperty(obj, 0, desc); });
|
||||
assert.throws(TypeError, function() { Object.defineProperties(obj, {0: desc}); });
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, 0, {});
|
||||
|
||||
@ -27,8 +27,8 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
assert.deepEqual(constructor.of("1", "2", "3"), new constructor([1, 2, 3]));
|
||||
|
||||
// This method can't be transplanted to other constructors.
|
||||
assertThrowsInstanceOf(() => constructor.of.call(Array), TypeError);
|
||||
assertThrowsInstanceOf(() => constructor.of.call(Array, 1, 2, 3), TypeError);
|
||||
assert.throws(TypeError, () => constructor.of.call(Array));
|
||||
assert.throws(TypeError, () => constructor.of.call(Array, 1, 2, 3));
|
||||
|
||||
var hits = 0;
|
||||
assert.deepEqual(constructor.of.call(function(len) {
|
||||
@ -51,40 +51,40 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidConstructors = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
constructor.of, () => {}];
|
||||
invalidConstructors.forEach(C => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.of.call(C);
|
||||
}, TypeError);
|
||||
});
|
||||
});
|
||||
|
||||
// Throw if `this` is a method definition or a getter/setter function.
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.of.call({method() {}}.method);
|
||||
}, TypeError);
|
||||
assertThrowsInstanceOf(() => {
|
||||
});
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.of.call(Object.getOwnPropertyDescriptor({get getter() {}}, "getter").get);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
// Generators are not legal constructors.
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.of.call(function*(len) {
|
||||
return len;
|
||||
}, "a")
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
// An exception might be thrown in a strict assignment to the new object's indexed properties.
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.of.call(function() {
|
||||
return {get 0() {}};
|
||||
}, "a");
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.of.call(function() {
|
||||
return Object("1");
|
||||
}, "a");
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.of.call(function() {
|
||||
return Object.create({
|
||||
set 0(v) {
|
||||
@ -92,7 +92,7 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
}
|
||||
});
|
||||
}, "a");
|
||||
}, TypeError);
|
||||
});
|
||||
}
|
||||
|
||||
for (let constructor of anyTypedArrayConstructors.filter(isFloatConstructor)) {
|
||||
|
||||
@ -51,7 +51,7 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
// Throw an exception in the callback.
|
||||
var count = 0;
|
||||
var sum = 0;
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.reduce((previous, current, index, array) => {
|
||||
count++;
|
||||
sum += current;
|
||||
@ -59,19 +59,19 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
throw TypeError("reduce");
|
||||
}
|
||||
})
|
||||
}, TypeError);
|
||||
});
|
||||
assert.sameValue(count, 3);
|
||||
assert.sameValue(sum, 9);
|
||||
|
||||
// There is no callback or callback is not a function.
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.reduce();
|
||||
}, TypeError);
|
||||
});
|
||||
var invalidCallbacks = [undefined, null, 1, false, "", Symbol(), [], {}, /./];
|
||||
invalidCallbacks.forEach(callback => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.reduce(callback);
|
||||
}, TypeError);
|
||||
});
|
||||
})
|
||||
|
||||
// Callback is a generator.
|
||||
@ -89,9 +89,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(3), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.reduce.call(invalidReceiver, () => {});
|
||||
}, TypeError, "Assert that reduce fails if this value is not a TypedArray");
|
||||
}, "Assert that reduce fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
@ -144,7 +144,7 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
// Throw an exception in the callback.
|
||||
var count = 0;
|
||||
var sum = 0;
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.reduceRight((previous, current, index, array) => {
|
||||
count++;
|
||||
sum += current;
|
||||
@ -152,19 +152,19 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
throw TypeError("reduceRight");
|
||||
}
|
||||
})
|
||||
}, TypeError);
|
||||
});
|
||||
assert.sameValue(count, 3);
|
||||
assert.sameValue(sum, 9);
|
||||
|
||||
// There is no callback or callback is not a function.
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.reduceRight();
|
||||
}, TypeError);
|
||||
});
|
||||
var invalidCallbacks = [undefined, null, 1, false, "", Symbol(), [], {}, /./];
|
||||
invalidCallbacks.forEach(callback => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
arr.reduceRight(callback);
|
||||
}, TypeError);
|
||||
});
|
||||
})
|
||||
|
||||
// Callback is a generator.
|
||||
@ -182,9 +182,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(3), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.reduceRight.call(invalidReceiver, () => {});
|
||||
}, TypeError, "Assert that reduceRight fails if this value is not a TypedArray");
|
||||
}, "Assert that reduceRight fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
|
||||
@ -32,9 +32,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.reverse.call(invalidReceiver);
|
||||
}, TypeError, "Assert that reverse fails if this value is not a TypedArray");
|
||||
}, "Assert that reverse fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
|
||||
@ -29,9 +29,9 @@ assert.sameValue(Object.isSealed(array), false);
|
||||
|
||||
array = new Int32Array(2);
|
||||
array.b = "test";
|
||||
assertThrowsInstanceOf(() => Object.seal(array), TypeError);
|
||||
assert.throws(TypeError, () => Object.seal(array));
|
||||
assert.sameValue(Object.isSealed(array), false);
|
||||
assertThrowsInstanceOf(() => array.c = 15, TypeError);
|
||||
assert.throws(TypeError, () => array.c = 15);
|
||||
|
||||
// Freeze
|
||||
assert.sameValue(Object.isFrozen(new Int32Array(2)), false);
|
||||
@ -52,7 +52,7 @@ assert.sameValue(Object.isFrozen(array), true);
|
||||
|
||||
// Non-empty typed arrays can never be frozen, because the elements stay writable
|
||||
array = new Int32Array(1);
|
||||
assertThrowsInstanceOf(() => Object.freeze(array), TypeError);
|
||||
assert.throws(TypeError, () => Object.freeze(array));
|
||||
assert.sameValue(Object.isExtensible(array), false);
|
||||
assert.sameValue(Object.isFrozen(array), false);
|
||||
|
||||
|
||||
@ -24,5 +24,5 @@ let obj = {
|
||||
};
|
||||
|
||||
// Throws a SyntaxError, because "huzzah!" can't be parsed as a BigInt.
|
||||
assertThrowsInstanceOf(() => ta.set(obj), SyntaxError);
|
||||
assert.throws(SyntaxError, () => ta.set(obj));
|
||||
|
||||
|
||||
@ -27,11 +27,11 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
for (let {typedArray, buffer} of createTypedArrays()) {
|
||||
$262.detachArrayBuffer(buffer);
|
||||
|
||||
assertThrowsInstanceOf(() => typedArray.set(null, {
|
||||
assert.throws(ExpectedError, () => typedArray.set(null, {
|
||||
valueOf() {
|
||||
throw new ExpectedError();
|
||||
}
|
||||
}), ExpectedError);
|
||||
}));
|
||||
}
|
||||
|
||||
// Check for detached buffer after calling ToInteger(offset). Test with:
|
||||
@ -41,12 +41,12 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
for (let [offset, error] of [[0, TypeError], [1000000, TypeError], [-1, RangeError]]) {
|
||||
for (let source of [[], [0], new Int32Array(0), new Int32Array(1)]) {
|
||||
for (let {typedArray, buffer} of createTypedArrays()) {
|
||||
assertThrowsInstanceOf(() => typedArray.set(source, {
|
||||
assert.throws(error, () => typedArray.set(source, {
|
||||
valueOf() {
|
||||
$262.detachArrayBuffer(buffer);
|
||||
return offset;
|
||||
}
|
||||
}), error);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -56,11 +56,11 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
for (let {typedArray: source, buffer: sourceBuffer} of createTypedArrays()) {
|
||||
$262.detachArrayBuffer(sourceBuffer);
|
||||
|
||||
assertThrowsInstanceOf(() => typedArray.set(source, {
|
||||
assert.throws(ExpectedError, () => typedArray.set(source, {
|
||||
valueOf() {
|
||||
throw new ExpectedError();
|
||||
}
|
||||
}), ExpectedError);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,12 +71,12 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
for (let [offset, error] of [[0, TypeError], [1000000, TypeError], [-1, RangeError]]) {
|
||||
for (let {typedArray} of createTypedArrays()) {
|
||||
for (let {typedArray: source, buffer: sourceBuffer} of createTypedArrays()) {
|
||||
assertThrowsInstanceOf(() => typedArray.set(source, {
|
||||
assert.throws(error, () => typedArray.set(source, {
|
||||
valueOf() {
|
||||
$262.detachArrayBuffer(sourceBuffer);
|
||||
return offset;
|
||||
}
|
||||
}), error);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,12 +89,12 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
for (let src of [ta => ta, ta => new Int32Array(ta.buffer), ta => new Float32Array(ta.buffer)]) {
|
||||
for (let {typedArray, buffer} of createTypedArrays()) {
|
||||
let source = src(typedArray);
|
||||
assertThrowsInstanceOf(() => typedArray.set(source, {
|
||||
assert.throws(TypeError, () => typedArray.set(source, {
|
||||
valueOf() {
|
||||
$262.detachArrayBuffer(buffer);
|
||||
return 0;
|
||||
}
|
||||
}), TypeError);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
}
|
||||
};
|
||||
if (typedArray.length === 0) {
|
||||
assertThrowsInstanceOf(() => typedArray.set(source), RangeError);
|
||||
assert.throws(RangeError, () => typedArray.set(source));
|
||||
} else {
|
||||
typedArray.set(source);
|
||||
}
|
||||
@ -162,7 +162,7 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
}
|
||||
};
|
||||
let err = typedArray.length === 0 ? RangeError : ExpectedError;
|
||||
assertThrowsInstanceOf(() => typedArray.set(source), err);
|
||||
assert.throws(err, () => typedArray.set(source));
|
||||
}
|
||||
|
||||
// Same as above, but with side-effect when executing ToNumber(Get(src, "0")).
|
||||
@ -183,7 +183,7 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
}
|
||||
};
|
||||
let err = typedArray.length === 0 ? RangeError : ExpectedError;
|
||||
assertThrowsInstanceOf(() => typedArray.set(source), err);
|
||||
assert.throws(err, () => typedArray.set(source));
|
||||
}
|
||||
|
||||
// Side-effects when getting the source elements detach the buffer.
|
||||
@ -197,7 +197,7 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
}
|
||||
});
|
||||
if (typedArray.length === 0) {
|
||||
assertThrowsInstanceOf(() => typedArray.set(source), RangeError);
|
||||
assert.throws(RangeError, () => typedArray.set(source));
|
||||
} else {
|
||||
typedArray.set(source);
|
||||
}
|
||||
@ -223,7 +223,7 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
}
|
||||
});
|
||||
if (typedArray.length <= 1) {
|
||||
assertThrowsInstanceOf(() => typedArray.set(source), RangeError);
|
||||
assert.throws(RangeError, () => typedArray.set(source));
|
||||
} else {
|
||||
assert.sameValue(accessed, false);
|
||||
typedArray.set(source);
|
||||
@ -240,7 +240,7 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
}
|
||||
}];
|
||||
if (typedArray.length === 0) {
|
||||
assertThrowsInstanceOf(() => typedArray.set(source), RangeError);
|
||||
assert.throws(RangeError, () => typedArray.set(source));
|
||||
} else {
|
||||
typedArray.set(source);
|
||||
}
|
||||
@ -263,7 +263,7 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
}
|
||||
}];
|
||||
if (typedArray.length <= 1) {
|
||||
assertThrowsInstanceOf(() => typedArray.set(source), RangeError);
|
||||
assert.throws(RangeError, () => typedArray.set(source));
|
||||
} else {
|
||||
assert.sameValue(accessed, false);
|
||||
typedArray.set(source);
|
||||
|
||||
@ -83,7 +83,7 @@ let invalidOffsets = [
|
||||
|
||||
for (let offset of invalidOffsets) {
|
||||
for (let source of sources) {
|
||||
assertThrowsInstanceOf(() => ta.set(source, offset), RangeError);
|
||||
assert.throws(RangeError, () => ta.set(source, offset));
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,12 +93,12 @@ for (let source of emptySources) {
|
||||
ta.set(source, 4.9);
|
||||
}
|
||||
for (let source of nonEmptySource) {
|
||||
assertThrowsInstanceOf(() => ta.set(source, 4), RangeError);
|
||||
assertThrowsInstanceOf(() => ta.set(source, 4.9), RangeError);
|
||||
assert.throws(RangeError, () => ta.set(source, 4));
|
||||
assert.throws(RangeError, () => ta.set(source, 4.9));
|
||||
}
|
||||
|
||||
// ToInteger(symbol value) throws a TypeError.
|
||||
for (let source of sources) {
|
||||
assertThrowsInstanceOf(() => ta.set(source, Symbol()), TypeError);
|
||||
assert.throws(TypeError, () => ta.set(source, Symbol()));
|
||||
}
|
||||
|
||||
|
||||
@ -15,15 +15,15 @@ let ta = new Int32Array(4);
|
||||
|
||||
for (let nullOrUndefined of [null, undefined]) {
|
||||
// ToObject(array) throws a TypeError when |array| is null or undefined.
|
||||
assertThrowsInstanceOf(() => ta.set(nullOrUndefined), TypeError);
|
||||
assert.throws(TypeError, () => ta.set(nullOrUndefined));
|
||||
|
||||
// ToInteger(offset) is called before ToObject(array).
|
||||
class ExpectedError extends Error {}
|
||||
assertThrowsInstanceOf(() => ta.set(nullOrUndefined, {
|
||||
assert.throws(ExpectedError, () => ta.set(nullOrUndefined, {
|
||||
valueOf() {
|
||||
throw new ExpectedError();
|
||||
}
|
||||
}), ExpectedError);
|
||||
}));
|
||||
}
|
||||
|
||||
// Ensure ta is still initialized with zeros.
|
||||
@ -37,7 +37,7 @@ ta.set("123");
|
||||
assert.compareArray(ta, [1, 2, 3, 0]);
|
||||
|
||||
// Throws a RangeError if the length is too large.
|
||||
assertThrowsInstanceOf(() => ta.set("456789"), RangeError);
|
||||
assert.throws(RangeError, () => ta.set("456789"));
|
||||
assert.compareArray(ta, [1, 2, 3, 0]);
|
||||
|
||||
// When called with other primitive values the typed array contents don't
|
||||
|
||||
@ -45,7 +45,7 @@ if (typeof createNewGlobal === "function") {
|
||||
|
||||
// Called with wrapped typed array, array buffer already detached.
|
||||
otherGlobal.$262.detachArrayBuffer(source.buffer);
|
||||
assertThrowsInstanceOf(() => target.set(source), TypeError);
|
||||
assert.throws(TypeError, () => target.set(source));
|
||||
|
||||
var source = new otherGlobal[TA.name](1);
|
||||
taintLengthProperty(source);
|
||||
@ -58,7 +58,7 @@ if (typeof createNewGlobal === "function") {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
assertThrowsInstanceOf(() => target.set(source, offset), TypeError);
|
||||
assert.throws(TypeError, () => target.set(source, offset));
|
||||
}
|
||||
|
||||
// Create typed array from different global (implictly created when
|
||||
@ -70,7 +70,7 @@ if (typeof createNewGlobal === "function") {
|
||||
|
||||
// Called with wrapped typed array, array buffer already detached.
|
||||
otherGlobal.$262.detachArrayBuffer(source.buffer);
|
||||
assertThrowsInstanceOf(() => target.set(source), TypeError);
|
||||
assert.throws(TypeError, () => target.set(source));
|
||||
|
||||
var source = new TA(new otherGlobal.ArrayBuffer(1 * TA.BYTES_PER_ELEMENT));
|
||||
taintLengthProperty(source);
|
||||
@ -83,7 +83,7 @@ if (typeof createNewGlobal === "function") {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
assertThrowsInstanceOf(() => target.set(source, offset), TypeError);
|
||||
assert.throws(TypeError, () => target.set(source, offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,9 +32,9 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
// ArrayBuffer is detached when entering slice().
|
||||
for (let {typedArray, buffer} of createTypedArrays()) {
|
||||
$262.detachArrayBuffer(buffer());
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
typedArray.slice(0);
|
||||
}, TypeError, "ArrayBuffer is detached on function entry");
|
||||
}, "ArrayBuffer is detached on function entry");
|
||||
}
|
||||
|
||||
// ArrayBuffer is detached when computing ToInteger(start).
|
||||
@ -54,9 +54,9 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
if (length === 0) {
|
||||
typedArray.slice(start);
|
||||
} else {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
typedArray.slice(start);
|
||||
}, TypeError, "ArrayBuffer is detached in ToInteger(start)");
|
||||
}, "ArrayBuffer is detached in ToInteger(start)");
|
||||
}
|
||||
assert.sameValue(detached, true, "$262.detachArrayBuffer was called");
|
||||
}
|
||||
@ -78,9 +78,9 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
if (length === 0) {
|
||||
typedArray.slice(0, end);
|
||||
} else {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
typedArray.slice(0, end);
|
||||
}, TypeError, "ArrayBuffer is detached in ToInteger(end)");
|
||||
}, "ArrayBuffer is detached in ToInteger(end)");
|
||||
}
|
||||
assert.sameValue(detached, true, "$262.detachArrayBuffer was called");
|
||||
}
|
||||
@ -102,9 +102,9 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
if (length === 0) {
|
||||
typedArray.slice(0);
|
||||
} else {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
typedArray.slice(0);
|
||||
}, TypeError, "ArrayBuffer is detached in TypedArraySpeciesCreate(...)");
|
||||
}, "ArrayBuffer is detached in TypedArraySpeciesCreate(...)");
|
||||
}
|
||||
assert.sameValue(detached, true, "$262.detachArrayBuffer was called");
|
||||
}
|
||||
|
||||
@ -15,11 +15,11 @@ for (var constructor of typedArrayConstructors) {
|
||||
undefConstructor.constructor = undefined;
|
||||
assert.deepEqual(undefConstructor.slice(1), new constructor(1));
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
var strConstructor = new constructor;
|
||||
strConstructor.constructor = "not a constructor";
|
||||
strConstructor.slice(123);
|
||||
}, TypeError, "Assert that we have an invalid constructor");
|
||||
}, "Assert that we have an invalid constructor");
|
||||
|
||||
// If obj.constructor[@@species] is undefined or null then the default
|
||||
// constructor is used.
|
||||
@ -49,10 +49,10 @@ for (var constructor of typedArrayConstructors) {
|
||||
|
||||
// If obj.constructor[@@species] is neither undefined nor null, and it's
|
||||
// not a constructor, TypeError should be thrown.
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
var strSpecies = new constructor;
|
||||
strSpecies.constructor = { [Symbol.species]: "not a constructor" };
|
||||
strSpecies.slice(123);
|
||||
}, TypeError);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -38,9 +38,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.slice.call(invalidReceiver, 0);
|
||||
}, TypeError, "Assert that slice fails if this value is not a TypedArray");
|
||||
}, "Assert that slice fails if this value is not a TypedArray");
|
||||
});
|
||||
|
||||
// Test that the length getter is never called.
|
||||
|
||||
@ -18,7 +18,7 @@ const typedArray = new Int32Array(0);
|
||||
|
||||
// Throws if the comparator is neither undefined nor callable.
|
||||
for (let invalidComparator of [null, 0, true, Symbol(), {}, []]) {
|
||||
assertThrowsInstanceOf(() => typedArray.sort(invalidComparator), TypeError);
|
||||
assert.throws(TypeError, () => typedArray.sort(invalidComparator));
|
||||
}
|
||||
|
||||
// Doesn't throw if the comparator is undefined or a callable object.
|
||||
|
||||
@ -11,12 +11,12 @@ esid: pending
|
||||
---*/
|
||||
// Ensure that TypedArrays throw when attempting to sort a detached ArrayBuffer
|
||||
if (typeof $262.detachArrayBuffer === "function") {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
let buffer = new ArrayBuffer(32);
|
||||
let array = new Int32Array(buffer);
|
||||
$262.detachArrayBuffer(buffer);
|
||||
array.sort();
|
||||
}, TypeError);
|
||||
});
|
||||
}
|
||||
|
||||
// Ensure detaching buffer in comparator doesn't throw an error.
|
||||
@ -58,23 +58,23 @@ if (typeof createNewGlobal === "function" && typeof $262.detachArrayBuffer === "
|
||||
}
|
||||
|
||||
// Ensure that TypedArray.prototype.sort will not sort non-TypedArrays
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
let array = [4, 3, 2, 1];
|
||||
Int32Array.prototype.sort.call(array);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
Int32Array.prototype.sort.call({a: 1, b: 2});
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
Int32Array.prototype.sort.call(Int32Array.prototype);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
let buf = new ArrayBuffer(32);
|
||||
Int32Array.prototype.sort.call(buf);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
// Ensure that comparator errors are propagataed
|
||||
function badComparator(x, y) {
|
||||
@ -83,14 +83,14 @@ function badComparator(x, y) {
|
||||
return x - y;
|
||||
}
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
let array = new Uint8Array([99, 99, 99, 99]);
|
||||
array.sort(badComparator);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
let array = new Uint8Array([1, 99, 2, 99]);
|
||||
array.sort(badComparator);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ const NON_INLINE_STORAGE = 1024;
|
||||
// Non-empty typed arrays cannot be sealed.
|
||||
for (let length of [INLINE_STORAGE, NON_INLINE_STORAGE]) {
|
||||
let ta = new Int32Array(length);
|
||||
assertThrowsInstanceOf(() => Object.seal(ta), TypeError);
|
||||
assert.throws(TypeError, () => Object.seal(ta));
|
||||
|
||||
assert.sameValue(Object.isExtensible(ta), false);
|
||||
assert.sameValue(Object.isSealed(ta), false);
|
||||
@ -46,7 +46,7 @@ for (let length of [INLINE_STORAGE, NON_INLINE_STORAGE]) {
|
||||
// Non-empty typed arrays cannot be frozen.
|
||||
for (let length of [INLINE_STORAGE, NON_INLINE_STORAGE]) {
|
||||
let ta = new Int32Array(length);
|
||||
assertThrowsInstanceOf(() => Object.freeze(ta), TypeError);
|
||||
assert.throws(TypeError, () => Object.freeze(ta));
|
||||
|
||||
assert.sameValue(Object.isExtensible(ta), false);
|
||||
assert.sameValue(Object.isSealed(ta), false);
|
||||
|
||||
@ -16,7 +16,7 @@ if (typeof $262.detachArrayBuffer === "function") {
|
||||
for (let constructor of typedArrayConstructors) {
|
||||
let typedArray = new constructor(42);
|
||||
$262.detachArrayBuffer(typedArray.buffer);
|
||||
assertThrowsInstanceOf(() => typedArray.toLocaleString(), TypeError);
|
||||
assert.throws(TypeError, () => typedArray.toLocaleString());
|
||||
}
|
||||
|
||||
// Doesn't throw a TypeError if detached in Number.prototype.toLocaleString.
|
||||
|
||||
@ -32,9 +32,9 @@ assert.sameValue(TypedArrayPrototype.toLocaleString.name, "toLocaleString");
|
||||
assert.sameValue(TypedArrayPrototype.toLocaleString.length, 0);
|
||||
|
||||
// It's not a generic method.
|
||||
assertThrowsInstanceOf(() => TypedArrayPrototype.toLocaleString.call(), TypeError);
|
||||
assert.throws(TypeError, () => TypedArrayPrototype.toLocaleString.call());
|
||||
for (let invalid of [void 0, null, {}, [], function(){}, true, 0, "", Symbol()]) {
|
||||
assertThrowsInstanceOf(() => TypedArrayPrototype.toLocaleString.call(invalid), TypeError);
|
||||
assert.throws(TypeError, () => TypedArrayPrototype.toLocaleString.call(invalid));
|
||||
}
|
||||
|
||||
const localeOne = 1..toLocaleString(),
|
||||
|
||||
@ -14,5 +14,5 @@ var ta = new Int32Array([3, 2, 1]);
|
||||
|
||||
$262.detachArrayBuffer(ta.buffer);
|
||||
|
||||
assertThrowsInstanceOf(() => ta.toReversed(), TypeError);
|
||||
assert.throws(TypeError, () => ta.toReversed());
|
||||
|
||||
|
||||
@ -14,5 +14,5 @@ var ta = new Int32Array([3, 2, 1]);
|
||||
|
||||
$262.detachArrayBuffer(ta.buffer);
|
||||
|
||||
assertThrowsInstanceOf(() => ta.toSorted(), TypeError);
|
||||
assert.throws(TypeError, () => ta.toSorted());
|
||||
|
||||
|
||||
@ -38,9 +38,9 @@ for (var constructor of anyTypedArrayConstructors) {
|
||||
var invalidReceivers = [undefined, null, 1, false, "", Symbol(), [], {}, /./,
|
||||
new Proxy(new constructor(), {})];
|
||||
invalidReceivers.forEach(invalidReceiver => {
|
||||
assertThrowsInstanceOf(() => {
|
||||
assert.throws(TypeError, () => {
|
||||
constructor.prototype.values.call(invalidReceiver);
|
||||
}, TypeError, "Assert that values fails if this value is not a TypedArray");
|
||||
}, "Assert that values fails if this value is not a TypedArray");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -14,5 +14,5 @@ var ta = new Int32Array([3, 2, 1]);
|
||||
|
||||
$262.detachArrayBuffer(ta.buffer);
|
||||
|
||||
assertThrowsInstanceOf(() => ta.with(0, 0), TypeError);
|
||||
assert.throws(TypeError, () => ta.with(0, 0));
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ let value = {
|
||||
|
||||
let ta = new Int32Array(5);
|
||||
for (let index of indices) {
|
||||
assertThrowsInstanceOf(() => ta.with(index, value), Err);
|
||||
assert.throws(Err, () => ta.with(index, value), Err);
|
||||
}
|
||||
|
||||
for (let index of indices) {
|
||||
@ -37,6 +37,6 @@ for (let index of indices) {
|
||||
}
|
||||
};
|
||||
|
||||
assertThrowsInstanceOf(() => ta.with(index, value), RangeError);
|
||||
assert.throws(RangeError, () => ta.with(index, value));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user