mirror of https://github.com/tc39/test262.git
test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js - Should refer to BigInt conversion instead of ToNumber test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js - Missing coverage for non-convertable values like undefined or null? - added fill-values-non-numeric-throw.js test/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-tointeger-offset-symbol.js - Change [1] to [1n] to avoid possible false-positives because ToBigInt(1) also throws a TypeError. - Issue also present in other set() tests.
This commit is contained in:
parent
985c439c94
commit
b1bbf08bdc
|
@ -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");
|
||||
});
|
||||
|
|
57
test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js
vendored
Normal file
57
test/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js
vendored
Normal file
|
@ -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");
|
||||
|
||||
});
|
|
@ -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");
|
||||
|
||||
});
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
|
|
|
@ -22,6 +22,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
var sample = new TA(2);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.set([1], s);
|
||||
sample.set([1n], s);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.set([1], obj);
|
||||
sample.set([1n], obj);
|
||||
});
|
||||
|
||||
assert.sameValue(calledOffset, 1);
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue