mirror of
https://github.com/tc39/test262.git
synced 2025-07-29 08:54:35 +02:00
Add coverage for converting negative fractional index to zero in (Typed)Array.prototype.with
JSC doesn't handle this correctly for `TypedArray.prototype.with`.
This commit is contained in:
parent
7c9314b06b
commit
88c5b410aa
26
test/built-ins/Array/prototype/with/negative-fractional-index-truncated-to-zero.js
vendored
Normal file
26
test/built-ins/Array/prototype/with/negative-fractional-index-truncated-to-zero.js
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2025 André Bargull. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-array.prototype.with
|
||||
description: >
|
||||
Negative fractional index which is truncated to zero.
|
||||
info: |
|
||||
Array.prototype.with ( index, value )
|
||||
|
||||
...
|
||||
3. Let relativeIndex be ? ToIntegerOrInfinity(index).
|
||||
...
|
||||
|
||||
ToIntegerOrInfinity ( argument )
|
||||
|
||||
1. Let number be ? ToNumber(argument).
|
||||
2. If number is one of NaN, +0𝔽, or -0𝔽, return 0.
|
||||
3. If number is +∞𝔽, return +∞.
|
||||
4. If number is -∞𝔽, return -∞.
|
||||
5. Return truncate(ℝ(number)).
|
||||
features: [change-array-by-copy]
|
||||
---*/
|
||||
|
||||
var result = [0].with(-0.5, 123);
|
||||
assert.sameValue(result[0], 123);
|
30
test/built-ins/TypedArray/prototype/with/negative-fractional-index-truncated-to-zero.js
vendored
Normal file
30
test/built-ins/TypedArray/prototype/with/negative-fractional-index-truncated-to-zero.js
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// 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 fractional index which is truncated to zero.
|
||||
info: |
|
||||
%TypedArray%.prototype.with ( index, value )
|
||||
|
||||
...
|
||||
4. Let relativeIndex be ? ToIntegerOrInfinity(index).
|
||||
...
|
||||
|
||||
ToIntegerOrInfinity ( argument )
|
||||
|
||||
1. Let number be ? ToNumber(argument).
|
||||
2. If number is one of NaN, +0𝔽, or -0𝔽, return 0.
|
||||
3. If number is +∞𝔽, return +∞.
|
||||
4. If number is -∞𝔽, return -∞.
|
||||
5. Return truncate(ℝ(number)).
|
||||
features: [TypedArray, change-array-by-copy]
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var ta = new TA(1);
|
||||
var result = ta.with(-0.5, 123);
|
||||
assert.sameValue(result[0], 123);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user