mirror of
https://github.com/tc39/test262.git
synced 2025-07-21 04:54:44 +02:00
Add coverage for negative indices with resizable typed arrays to TA.prototype.with
V8 doesn't handle this case correctly.
This commit is contained in:
parent
88c5b410aa
commit
17bfbc8783
37
test/built-ins/TypedArray/prototype/with/negative-index-resize-to-in-bounds.js
vendored
Normal file
37
test/built-ins/TypedArray/prototype/with/negative-index-resize-to-in-bounds.js
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2025 André Bargull. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-%typedarray%.prototype.with
|
||||
description: >
|
||||
Negative index is relative to the original typed array length.
|
||||
info: |
|
||||
%TypedArray%.prototype.with ( index, value )
|
||||
|
||||
...
|
||||
4. Let relativeIndex be ? ToIntegerOrInfinity(index).
|
||||
5. If relativeIndex ≥ 0, let actualIndex be relativeIndex.
|
||||
6. Else, let actualIndex be len + relativeIndex.
|
||||
...
|
||||
9. If IsValidIntegerIndex(O, 𝔽(actualIndex)) is false, throw a RangeError exception.
|
||||
...
|
||||
features: [TypedArray, change-array-by-copy, resizable-arraybuffer]
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var byteLength = 4 * TA.BYTES_PER_ELEMENT;
|
||||
var rab = new ArrayBuffer(0, {maxByteLength: byteLength});
|
||||
var ta = new TA(rab);
|
||||
|
||||
var value = {
|
||||
valueOf() {
|
||||
rab.resize(byteLength);
|
||||
return 123;
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
ta.with(-1, value);
|
||||
});
|
||||
});
|
37
test/built-ins/TypedArray/prototype/with/negative-index-resize-to-out-of-bounds.js
vendored
Normal file
37
test/built-ins/TypedArray/prototype/with/negative-index-resize-to-out-of-bounds.js
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2025 André Bargull. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-%typedarray%.prototype.with
|
||||
description: >
|
||||
Negative index is relative to the original typed array length.
|
||||
info: |
|
||||
%TypedArray%.prototype.with ( index, value )
|
||||
|
||||
...
|
||||
4. Let relativeIndex be ? ToIntegerOrInfinity(index).
|
||||
5. If relativeIndex ≥ 0, let actualIndex be relativeIndex.
|
||||
6. Else, let actualIndex be len + relativeIndex.
|
||||
...
|
||||
9. If IsValidIntegerIndex(O, 𝔽(actualIndex)) is false, throw a RangeError exception.
|
||||
...
|
||||
features: [TypedArray, change-array-by-copy, resizable-arraybuffer]
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var byteLength = 4 * TA.BYTES_PER_ELEMENT;
|
||||
var rab = new ArrayBuffer(byteLength, {maxByteLength: byteLength});
|
||||
var ta = new TA(rab);
|
||||
|
||||
var value = {
|
||||
valueOf() {
|
||||
rab.resize(TA.BYTES_PER_ELEMENT);
|
||||
return 123;
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
ta.with(-1, value);
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user