diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArray/prototype/with')
14 files changed, 74 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js index bf38eb2556..c08f33a890 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js index 044707a6f0..46cfb0d9f4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js index 0b46dfd28a..61c10de916 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js index c96c2e2005..2e5e069a0f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js index 19e0a1625d..7d28553524 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js index 640a49736c..a8335d2bd7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js index f5481fff1e..2ebb4e5fe6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-validated-against-current-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-validated-against-current-length.js new file mode 100644 index 0000000000..db6c1b534e --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-validated-against-current-length.js @@ -0,0 +1,61 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + The index is validated against the current length. +info: | + %TypedArray%.prototype.with ( index, value ) + + 1. Let O be the this value. + 2. Let taRecord be ? ValidateTypedArray(O, SEQ-CST). + 3. Let len be TypedArrayLength(taRecord). + ... + 8. Else, let numericValue be ? ToNumber(value). + ... + 10. Let A be ? TypedArrayCreateSameType(O, « 𝔽(len) »). + ... + 13. Return A. + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(2, {maxByteLength: 5}); +let ta = new Int8Array(rab); + +ta[0] = 11; +ta[1] = 22; + +// Ensure typed array is correctly initialised. +assert.sameValue(ta.length, 2); +assert.sameValue(ta[0], 11); +assert.sameValue(ta[1], 22); + +// Index is initially out-of-bounds. +let index = 4; + +let value = { + valueOf() { + rab.resize(5); + return 123; + } +}; + +let result = ta.with(index, value); + +// Typed array has been resized. +assert.sameValue(ta.length, 5); +assert.sameValue(ta[0], 11); +assert.sameValue(ta[1], 22); +assert.sameValue(ta[2], 0); +assert.sameValue(ta[3], 0); +assert.sameValue(ta[4], 0); + +// Result is correctly initialised. +assert.sameValue(result.length, 2); +assert.sameValue(result[0], 11); +assert.sameValue(result[1], 22); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js index 1a81148015..4d3040bb42 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js index 3fddf24a14..7cbad184b5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js index 095d7161a9..f99f833bf8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js index 8d8c1368a8..d024db6aa0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js index 09f4c4b144..d498709d0a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js index 92bb51bb46..bc27053107 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. |