diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js')
-rw-r--r-- | js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js new file mode 100644 index 0000000000..d2fe88d0d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js @@ -0,0 +1,51 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Primitive `array` argument is coerced to an object. +info: | + %TypedArray%.prototype.set ( typedArray [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object + with a [[TypedArrayName]] internal slot. If it is such an Object, + the definition in 22.2.3.23.2 applies. + [...] + 14. Let src be ? ToObject(array). + 15. Let srcLength be ? LengthOfArrayLike(src). + [...] + 19. Let limit be targetByteIndex + targetElementSize × srcLength. + 20. Repeat, while targetByteIndex < limit, + a. Let Pk be ! ToString(k). + b. Let value be ? Get(src, Pk). + c. If target.[[ContentType]] is BigInt, set value to ? ToBigInt(value). + [...] + f. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, Unordered). + [...] +includes: [testBigIntTypedArray.js, compareArray.js] +features: [BigInt, TypedArray, Symbol] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var ta1 = new TA([1n, 2n, 3n, 4n]); + ta1.set("567"); + assert.compareArray(ta1, [5n, 6n, 7n, 4n], "string"); + + var ta2 = new TA([1n, 2n, 3n]); + ta2.set(-10, 2); + assert.compareArray(ta2, [1n, 2n, 3n], "number"); + + var ta3 = new TA([1n]); + ta3.set(false); + assert.compareArray(ta3, [1n], "boolean"); + + var ta4 = new TA([1n, 2n]); + ta4.set(Symbol("desc"), 0); + assert.compareArray(ta4, [1n, 2n], "symbol"); + + var ta5 = new TA([1n, 2n]); + ta5.set(4n, 1); + assert.compareArray(ta5, [1n, 2n], "bigint"); +}); + +reportCompare(0, 0); |