diff --git a/test/built-ins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..d6586ee659 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.at +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, TypedArray.prototype.at, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.at, + 'function', + 'implements TypedArray.prototype.at' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.at(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.at(0); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the at operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.at(0); + throw new Test262Error('at completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js b/test/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js new file mode 100644 index 0000000000..717e40b0ba --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the dynamically-sized TypedArray instance +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE); + var expected = BPE * 3; + + assert.sameValue(array.byteLength, expected); + + try { + ab.resize(BPE * 5); + expected = BPE * 4; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following grow"); + + try { + ab.resize(BPE * 3); + expected = BPE * 2; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (within bounds)"); + + try { + ab.resize(BPE); + expected = 0; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)"); +}); diff --git a/test/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js b/test/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js new file mode 100644 index 0000000000..6479069aba --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the fixed-sized TypedArray instance +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + assert.sameValue(array.byteLength, BPE * 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.byteLength, BPE * 2, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.byteLength, BPE * 2, "following shrink (within bounds)"); + + var expected; + try { + ab.resize(BPE * 2); + expected = 0; + } catch (_) { + expected = BPE * 2; + } + + assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)"); +}); diff --git a/test/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js b/test/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js new file mode 100644 index 0000000000..c32a223d4a --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the dynamically-sized TypedArray instance +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE); + + assert.sameValue(array.byteOffset, BPE); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)"); + + var expected; + try { + ab.resize(BPE); + expected = 0; + } catch (_) { + expected = BPE; + } + + assert.sameValue(array.byteOffset, expected, "following shrink (out of bounds)"); +}); diff --git a/test/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js b/test/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js new file mode 100644 index 0000000000..7af5fed068 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the fixed-sized TypedArray instance +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + assert.sameValue(array.byteOffset, BPE); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)"); + + var expected; + try { + ab.resize(BPE * 2); + expected = 0; + } catch (_) { + expected = BPE; + } + + assert.sameValue(array.byteOffset, expected, "following shrink (out of bounds)"); +}); diff --git a/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..8f4c43bbb5 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.copyWithin, + 'function', + 'implements TypedArray.prototype.copyWithin' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.copyWithin(new TA(), 0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.copyWithin(new TA(), 0); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the copyWithin operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.copyWithin(new TA(), 0); + throw new Test262Error('copyWithin completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..3e56399c13 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.entries +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.entries, + 'function', + 'implements TypedArray.prototype.entries' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.entries(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.entries(); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the entries operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.entries(); + throw new Test262Error('entries completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..86733a56cc --- /dev/null +++ b/test/built-ins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.every +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.every, + 'function', + 'implements TypedArray.prototype.every' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.every(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.every(() => {}); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the every operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.every(() => {}); + throw new Test262Error('every completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..b28898c647 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.fill +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.fill, + 'function', + 'implements TypedArray.prototype.fill' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.fill(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.fill(0); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the fill operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.fill(0); + throw new Test262Error('fill completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..4891766e60 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.filter +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.filter, + 'function', + 'implements TypedArray.prototype.filter' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.filter(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.filter(() => {}); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the filter operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.filter(() => {}); + throw new Test262Error('filter completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..41d2dbbf57 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.find +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.find, + 'function', + 'implements TypedArray.prototype.find' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.find(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.find(() => {}); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the find operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.find(() => {}); + throw new Test262Error('find completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..7431c2af26 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.findindex +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.findIndex, + 'function', + 'implements TypedArray.prototype.findIndex' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.findIndex(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.findIndex(() => {}); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the findIndex operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.findIndex(() => {}); + throw new Test262Error('findIndex completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..b468b62ee4 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.findlast +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.findLast, + 'function', + 'implements TypedArray.prototype.findLast' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.findLast(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.findLast(() => {}); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the findLast operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.findLast(() => {}); + throw new Test262Error('findLast completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..927efcf5d7 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 Microsoft. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.findLastIndex, + 'function', + 'implements TypedArray.prototype.findLastIndex' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.findLastIndex(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.findLastIndex(() => {}); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the findLastIndex operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.findLastIndex(() => {}); + throw new Test262Error('findLastIndex completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..25d6647938 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.foreach +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.forEach, + 'function', + 'implements TypedArray.prototype.forEach' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.forEach(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.forEach(() => {}); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the forEach operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.forEach(() => {}); + throw new Test262Error('forEach completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..a76b0a8958 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.includes +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.includes, + 'function', + 'implements TypedArray.prototype.includes' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.includes(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.includes(0); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the includes operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.includes(0); + throw new Test262Error('includes completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..078955e783 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.indexOf, + 'function', + 'implements TypedArray.prototype.indexOf' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.indexOf(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.indexOf(0); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the indexOf operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.indexOf(0); + throw new Test262Error('indexOf completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..15ed9ed763 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.join +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.join, + 'function', + 'implements TypedArray.prototype.join' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.join(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.join(0); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the join operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.join(0); + throw new Test262Error('join completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..cd9d237609 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.keys +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.keys, + 'function', + 'implements TypedArray.prototype.keys' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.keys(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.keys(); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the keys operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.keys(); + throw new Test262Error('keys completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..839780b06f --- /dev/null +++ b/test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.lastIndexOf, + 'function', + 'implements TypedArray.prototype.lastIndexOf' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.lastIndexOf(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.lastIndexOf(0); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the lastIndexOf operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.lastIndexOf(0); + throw new Test262Error('lastIndexOf completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js index 7a74732264..a731bd403b 100644 --- a/test/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js +++ b/test/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js @@ -4,7 +4,7 @@ esid: sec-%typedarray%.prototype.lastindexof description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [TypedArray, resizable-arraybuffer] +features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js b/test/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js new file mode 100644 index 0000000000..a1f191a103 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the dynamically-sized TypedArray instance +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE); + var expected = 3; + + assert.sameValue(array.length, expected, "initial value"); + + try { + ab.resize(BPE * 5); + expected = 4; + } catch (_) {} + + assert.sameValue(array.length, expected, "following grow"); + + try { + ab.resize(BPE * 3); + expected = 2; + } catch (_) {} + + assert.sameValue(array.length, expected, "following shrink (within bounds)"); + + try { + ab.resize(BPE); + expected = 0; + } catch (_) {} + + assert.sameValue(array.length, expected, "following shrink (out of bounds)"); +}); diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js b/test/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js new file mode 100644 index 0000000000..77cf35ccf2 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the fixed-sized TypedArray instance +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + assert.sameValue(array.length, 2, "initial value"); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.length, 2, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.length, 2, "following shrink (within bounds)"); + + var expected; + try { + ab.resize(BPE * 2); + expected = 0; + } catch (_) { + expected = 2; + } + + assert.sameValue(array.length, expected, "following shrink (out of bounds)"); +}); diff --git a/test/built-ins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..94e0090933 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.map +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.map, + 'function', + 'implements TypedArray.prototype.map' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.map(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.map(() => {}); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the map operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.map(() => {}); + throw new Test262Error('map completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js index 60b9a73cc1..3eda7c6b0b 100644 --- a/test/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js +++ b/test/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js @@ -4,7 +4,7 @@ esid: sec-%typedarray%.prototype.map description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [TypedArray, resizable-arraybuffer] +features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..beeddc1b53 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.reduce +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.reduce, + 'function', + 'implements TypedArray.prototype.reduce' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.reduce(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.reduce(() => {}); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reduce operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.reduce(() => {}); + throw new Test262Error('reduce completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js index d40679bf63..c273af402c 100644 --- a/test/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js +++ b/test/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js @@ -4,7 +4,7 @@ esid: sec-%typedarray%.prototype.reduce description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [TypedArray, resizable-arraybuffer] +features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..0cf00b3c5e --- /dev/null +++ b/test/built-ins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.reduceRight, + 'function', + 'implements TypedArray.prototype.reduceRight' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.reduceRight(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.reduceRight(() => {}); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reduceRight operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.reduceRight(() => {}); + throw new Test262Error('reduceRight completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js index 99222b8465..b6b2075266 100644 --- a/test/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js +++ b/test/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js @@ -4,7 +4,7 @@ esid: sec-%typedarray%.prototype.reduceright description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [TypedArray, resizable-arraybuffer] +features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..884c548e55 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.reverse, + 'function', + 'implements TypedArray.prototype.reverse' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.reverse(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.reverse(); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reverse operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.reverse(); + throw new Test262Error('reverse completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js b/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js new file mode 100644 index 0000000000..d3433ab2dc --- /dev/null +++ b/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js @@ -0,0 +1,45 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the same buffer and same + constructor when underlying ArrayBuffer has been resized +includes: [testBigIntTypedArray.js, compareArray.js] +features: [BigInt, TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var source = new TA(ab); + var target = new TA(ab); + var expected = [10, 20, 30, 40]; + + source[0] = 10; + source[1] = 20; + source[2] = 30; + source[3] = 40; + + try { + ab.resize(BPE * 5); + expected = [10, 20, 30, 40, 0]; + } catch (_) {} + + target.set(source); + assert(compareArray(target, expected), 'following grow'); + + try { + ab.resize(BPE * 3); + expected = [10, 20, 30]; + } catch (_) {} + + target.set(source); + assert(compareArray(target, expected), 'following shrink'); +}); diff --git a/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js b/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js new file mode 100644 index 0000000000..8058ab5442 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js @@ -0,0 +1,43 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: Error when target TypedArray fails boundary checks +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.set, + 'function', + 'implements TypedArray.prototype.set' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 4}); + var target = new TA(ab, 0, 4); + var source = new TA(new ArrayBuffer(BPE * 4)); + + var expectedError; + try { + ab.resize(BPE * 3); + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reverse operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + target.set(source, 0); + throw new Test262Error('The `set` operation completed successfully.'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..7b572c6687 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.slice, + 'function', + 'implements TypedArray.prototype.slice' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.slice(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.slice(0); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the slice operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.slice(0); + throw new Test262Error('slice completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js index f445156c52..ef331ac718 100644 --- a/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js +++ b/test/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js @@ -4,7 +4,7 @@ esid: sec-%typedarray%.prototype.slice description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [TypedArray, resizable-arraybuffer] +features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..52bdaa60b3 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.some +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.some, + 'function', + 'implements TypedArray.prototype.some' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.some(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.some(() => {}); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the some operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.some(() => {}); + throw new Test262Error('some completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js index e8b4b7aaa7..c36e9071e0 100644 --- a/test/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js +++ b/test/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js @@ -4,7 +4,7 @@ esid: sec-%typedarray%.prototype.some description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [TypedArray, resizable-arraybuffer] +features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..7e12d3da2d --- /dev/null +++ b/test/built-ins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.sort +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.sort, + 'function', + 'implements TypedArray.prototype.sort' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.sort(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.sort(); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the sort operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.sort(); + throw new Test262Error('sort completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js index 7f7ad2f108..f4843fddae 100644 --- a/test/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js +++ b/test/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js @@ -4,7 +4,7 @@ esid: sec-%typedarray%.prototype.sort description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [TypedArray, resizable-arraybuffer] +features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..79cd14013d --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.toLocaleString, + 'function', + 'implements TypedArray.prototype.toLocaleString' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.toLocaleString(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.toLocaleString(); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the toLocaleString operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.toLocaleString(); + throw new Test262Error('toLocaleString completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js index 5148f67a5c..4e28e28083 100644 --- a/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js +++ b/test/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js @@ -4,7 +4,7 @@ esid: sec-%typedarray%.prototype.tolocalestring description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [TypedArray, resizable-arraybuffer] +features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 0000000000..b199f30375 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,59 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.values +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntTypedArray.js] +features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof TypedArray.prototype.values, + 'function', + 'implements TypedArray.prototype.values' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.values(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.values(); + + var expectedError; + try { + ab.resize(BPE * 2); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the values operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.values(); + throw new Test262Error('values completed successfully'); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js b/test/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js index 57002a987f..0ff26bc4e9 100644 --- a/test/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js +++ b/test/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js @@ -4,7 +4,7 @@ esid: sec-%typedarray%.prototype.values description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [TypedArray, resizable-arraybuffer] +features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue(