diff --git a/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js b/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js index c87b864f9341bedee465f11c311c3fc80c1f98ef..47033ccce6a5b642c4dd04120006ad77bc675ff3 100644 --- a/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js +++ b/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js @@ -8,7 +8,8 @@ info: | 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) ... - 3. Let _value_ be ? ToNumber(_value_). + 3. If O.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", + let value be ? ToBigInt(value). ... includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] @@ -20,7 +21,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { var n = 1n; sample.fill({ valueOf() { return n++; } }); - assert.sameValue(n, 2n, "additional unexpected ToNumber() calls"); + assert.sameValue(n, 2n, "additional unexpected ToBigInt() calls"); assert.sameValue(sample[0], 1n, "incorrect ToNumber result in index 0"); assert.sameValue(sample[1], 1n, "incorrect ToNumber result in index 1"); }); diff --git a/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js b/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e091e0f09cfbd735a9baf021f2e9e5e532738a78 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js @@ -0,0 +1,57 @@ +// Copyright (C) 2016 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: > + Fills all the elements with non numeric values values. +info: | + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %TypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. Repeat, while k < final + a. Let Pk be ! ToString(k). + b. Perform ? Set(O, Pk, value, true). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 5. If arrayTypeName is "BigUint64Array" or "BigInt64Array", + let numValue be ? ToBigInt(value). + ... + +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n]); + + assert.throws(TypeError, function() { + sample.fill(undefined); + }, "abrupt completion from undefined"); + + assert.throws(TypeError, function() { + sample.fill(null); + }, "abrupt completion from null"); + + assert.throws(SyntaxError, function() { + sample.fill("nonsense"); + }, "abrupt completion from string"); + +}); diff --git a/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js b/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js index 4719ac67e6e999d4c22bc365da9d32ad0e03ca73..e7f9175eb38a10606c4c908f201045b2f762a184 100644 --- a/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js +++ b/test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js @@ -29,7 +29,8 @@ info: | 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) ... - 3. Let numValue be ? ToNumber(value). + 5. If arrayTypeName is "BigUint64Array" or "BigInt64Array", + let numValue be ? ToBigInt(value). ... includes: [testBigIntTypedArray.js] @@ -69,4 +70,5 @@ testWithBigIntTypedArrayConstructors(function(TA) { } }); assert.sameValue(sample[0], 7n, "object toString when valueOf is absent"); + }); diff --git a/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js b/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js index a5896d24b4da3baa3e7150568475b65830f1f6a4..18de4d017b43c238a0c1eb0054454e3b6bfcf234 100644 --- a/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js +++ b/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js @@ -22,14 +22,14 @@ testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(4); assert.throws(RangeError, function() { - sample.set([1], -1); + sample.set([1n], -1); }, "-1"); assert.throws(RangeError, function() { - sample.set([1], -1.00001); + sample.set([1n], -1.00001); }, "-1.00001"); assert.throws(RangeError, function() { - sample.set([1], -Infinity); + sample.set([1n], -Infinity); }, "-Infinity"); }); diff --git a/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js index f9d8699ab54a90239eab907f660518666ac5ad37..63b3095ac556b630a2fd578fc324c8835988aa8d 100644 --- a/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -22,6 +22,6 @@ testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); assert.throws(TypeError, function() { - sample.set([1], s); + sample.set([1n], s); }); }); diff --git a/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js index a25113b5a2f2bd6ece9a3fd79f6d46b57a018a20..a3747af9a2a7fe392decdd60e9b6bb055672afde 100644 --- a/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js +++ b/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js @@ -32,7 +32,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { }; assert.throws(TypeError, function() { - sample.set([1], obj); + sample.set([1n], obj); }); assert.sameValue(calledOffset, 1); diff --git a/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js b/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js index 9a2bd25315a1a4a8ece0e65f71f5f0287504d981..0b54b20cf1a58c4e832383e4f180ff00fcb7c201 100644 --- a/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js +++ b/test/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js @@ -34,7 +34,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { - sample.set([1]); + sample.set([1n]); }, "regular check"); assert.throws(TypeError, function() {