mirror of
https://github.com/tc39/test262.git
synced 2025-07-24 06:25:30 +02:00
Bigint typedarray conversion (#1469)
* BigInt: add tests for TypedArray(typedArray) constructor of mixed 'Big'/'not Big' element types * BigInt: update info text on tests of ToBigInt * BigInt: conversion to big int on creation of Big(U)Int64 TypedArray * BigInt: Add tests for ToBigInt64 and ToBigUint64 wrapping
This commit is contained in:
parent
3854fc38dd
commit
3c69133cc4
@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
Return abrupt on undefined
|
||||||
|
info: |
|
||||||
|
TypedArray ( object )
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
...
|
||||||
|
8. Repeat, while k < len
|
||||||
|
...
|
||||||
|
b. Let kValue be ? Get(arrayLike, Pk).
|
||||||
|
c. Perform ? Set(O, Pk, kValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
[[Set]] ( P, V, Receiver)
|
||||||
|
...
|
||||||
|
2. If Type(P) is String and if SameValue(O, Receiver) is true, then
|
||||||
|
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||||
|
...
|
||||||
|
|
||||||
|
IntegerIndexedElementSet ( O, index, value )
|
||||||
|
...
|
||||||
|
5. If arrayTypeName is "BigUint64Array" or "BigInt64Array",
|
||||||
|
let numValue be ? ToBigInt(value).
|
||||||
|
...
|
||||||
|
|
||||||
|
ToBigInt ( argument )
|
||||||
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
|
2. Return the value that prim corresponds to in Table [BigInt Conversions]
|
||||||
|
|
||||||
|
BigInt Conversions
|
||||||
|
Argument Type: Undefined
|
||||||
|
Result: Throw a TypeError exception.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA([undefined]);
|
||||||
|
}, "abrupt completion from undefined");
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,98 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
Behavior for input array of BigInts
|
||||||
|
info: |
|
||||||
|
TypedArray ( object )
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
...
|
||||||
|
8. Repeat, while k < len
|
||||||
|
...
|
||||||
|
b. Let kValue be ? Get(arrayLike, Pk).
|
||||||
|
c. Perform ? Set(O, Pk, kValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
[[Set]] ( P, V, Receiver)
|
||||||
|
...
|
||||||
|
2. If Type(P) is String and if SameValue(O, Receiver) is true, then
|
||||||
|
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||||
|
...
|
||||||
|
|
||||||
|
IntegerIndexedElementSet ( O, index, value )
|
||||||
|
...
|
||||||
|
5. If arrayTypeName is "BigUint64Array" or "BigInt64Array",
|
||||||
|
let numValue be ? ToBigInt(value).
|
||||||
|
...
|
||||||
|
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, "Unordered").
|
||||||
|
// NOTE: type will be set to BigInt64 in this test
|
||||||
|
16. Return true.
|
||||||
|
|
||||||
|
SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )
|
||||||
|
...
|
||||||
|
8. Let rawBytes be NumberToRawBytes(type, value, isLittleEndian).
|
||||||
|
...
|
||||||
|
|
||||||
|
NumberToRawBytes( type, value, isLittleEndian )
|
||||||
|
...
|
||||||
|
3. Else,
|
||||||
|
a. Let n be the Number value of the Element Size specified in Table
|
||||||
|
[The TypedArray Constructors] for Element Type type.
|
||||||
|
b. Let convOp be the abstract operation named in the Conversion Operation
|
||||||
|
column in Table 9 for Element Type type.
|
||||||
|
|
||||||
|
The TypedArray Constructors
|
||||||
|
Element Type: BigInt64
|
||||||
|
Conversion Operation: ToBigInt64
|
||||||
|
|
||||||
|
ToBigInt64 ( argument )
|
||||||
|
The abstract operation ToBigInt64 converts argument to one of 264 integer
|
||||||
|
values in the range -2^63 through 2^63-1, inclusive.
|
||||||
|
This abstract operation functions as follows:
|
||||||
|
1. Let n be ? ToBigInt(argument).
|
||||||
|
2. Let int64bit be n modulo 2^64.
|
||||||
|
3. If int64bit ≥ 2^63, return int64bit - 2^64; otherwise return int64bit.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var vals = [
|
||||||
|
18446744073709551618n, // 2n ** 64n + 2n
|
||||||
|
9223372036854775810n, // 2n ** 63n + 2n
|
||||||
|
2n,
|
||||||
|
0n,
|
||||||
|
-2n,
|
||||||
|
-9223372036854775810n, // -(2n ** 63n) - 2n
|
||||||
|
-18446744073709551618n, // -(2n ** 64n) - 2n
|
||||||
|
];
|
||||||
|
|
||||||
|
var typedArray = new BigInt64Array(vals);
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[0], 2n,
|
||||||
|
"ToBigInt64(2n ** 64n + 2n) => 2n");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[1], -9223372036854775806n, // 2n - 2n ** 63n
|
||||||
|
"ToBigInt64(2n ** 63n + 2n) => -9223372036854775806n");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[2], 2n,
|
||||||
|
"ToBigInt64(2n) => 2n");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[3], 0n,
|
||||||
|
"ToBigInt64(0n) => 0n");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[4], -2n,
|
||||||
|
"ToBigInt64( -2n) => -2n");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[5], 9223372036854775806n, // 2n ** 63n - 2
|
||||||
|
"ToBigInt64( -(2n ** 64n) - 2n) => 9223372036854775806n");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[6], -2n,
|
||||||
|
"ToBigInt64( -(2n ** 64n) - 2n) => -2n");
|
||||||
|
|
@ -0,0 +1,98 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
Behavior for input array of BigInts
|
||||||
|
info: |
|
||||||
|
TypedArray ( object )
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
...
|
||||||
|
8. Repeat, while k < len
|
||||||
|
...
|
||||||
|
b. Let kValue be ? Get(arrayLike, Pk).
|
||||||
|
c. Perform ? Set(O, Pk, kValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
[[Set]] ( P, V, Receiver)
|
||||||
|
...
|
||||||
|
2. If Type(P) is String and if SameValue(O, Receiver) is true, then
|
||||||
|
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||||
|
...
|
||||||
|
|
||||||
|
IntegerIndexedElementSet ( O, index, value )
|
||||||
|
...
|
||||||
|
5. If arrayTypeName is "BigUint64Array" or "BigInt64Array",
|
||||||
|
let numValue be ? ToBigInt(value).
|
||||||
|
...
|
||||||
|
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, "Unordered").
|
||||||
|
// NOTE: type will be set to BigUint64 in this test
|
||||||
|
16. Return true.
|
||||||
|
|
||||||
|
SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )
|
||||||
|
...
|
||||||
|
8. Let rawBytes be NumberToRawBytes(type, value, isLittleEndian).
|
||||||
|
...
|
||||||
|
|
||||||
|
NumberToRawBytes( type, value, isLittleEndian )
|
||||||
|
...
|
||||||
|
3. Else,
|
||||||
|
a. Let n be the Number value of the Element Size specified in Table
|
||||||
|
[The TypedArray Constructors] for Element Type type.
|
||||||
|
b. Let convOp be the abstract operation named in the Conversion Operation
|
||||||
|
column in Table 9 for Element Type type.
|
||||||
|
|
||||||
|
The TypedArray Constructors
|
||||||
|
Element Type: BigUint64
|
||||||
|
Conversion Operation: ToBigUint64
|
||||||
|
|
||||||
|
ToBigUint64 ( argument )
|
||||||
|
The abstract operation ToBigInt64 converts argument to one of 264 integer
|
||||||
|
values in the range -2^63 through 2^63-1, inclusive.
|
||||||
|
This abstract operation functions as follows:
|
||||||
|
1. Let n be ? ToBigInt(argument).
|
||||||
|
2. Let int64bit be n modulo 2^64.
|
||||||
|
3. Return int64bit.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var vals = [
|
||||||
|
18446744073709551618n, // 2n ** 64n + 2n
|
||||||
|
9223372036854775810n, // 2n ** 63n + 2n
|
||||||
|
2n,
|
||||||
|
0n,
|
||||||
|
-2n,
|
||||||
|
-9223372036854775810n, // -(2n ** 63n) - 2n
|
||||||
|
-18446744073709551618n, // -(2n ** 64n) - 2n
|
||||||
|
];
|
||||||
|
|
||||||
|
var typedArray = new BigUint64Array(vals);
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[0], 2n,
|
||||||
|
"ToBigUint64(2n ** 64n + 2n) => 2n");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[1], 9223372036854775810n, // 2n ** 63n + 2n
|
||||||
|
"ToBigUint64(2n ** 63n + 2n) => 9223372036854775810");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[2], 2n,
|
||||||
|
"ToBigUint64(2n) => 2n");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[3], 0n,
|
||||||
|
"ToBigUint64(0n) => 0n");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[4], 18446744073709551614n, // 2n ** 64n - 2n
|
||||||
|
"ToBigUint64( -2n) => 18446744073709551614n");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[5], 9223372036854775806n, // 2n ** 63n - 2n
|
||||||
|
"ToBigUint64( -(2n ** 63n) - 2n) => 9223372036854775806n");
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[6], 18446744073709551614n, // 2n ** 64n - 2n
|
||||||
|
"ToBigUint64( -(2n ** 64n) - 2n) => 18446744073709551614n");
|
@ -0,0 +1,52 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
Behavior for input array of Booleans
|
||||||
|
info: |
|
||||||
|
TypedArray ( object )
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
...
|
||||||
|
8. Repeat, while k < len
|
||||||
|
...
|
||||||
|
b. Let kValue be ? Get(arrayLike, Pk).
|
||||||
|
c. Perform ? Set(O, Pk, kValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
[[Set]] ( P, V, Receiver)
|
||||||
|
...
|
||||||
|
2. If Type(P) is String and if SameValue(O, Receiver) is true, then
|
||||||
|
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||||
|
...
|
||||||
|
|
||||||
|
IntegerIndexedElementSet ( O, index, value )
|
||||||
|
...
|
||||||
|
5. If arrayTypeName is "BigUint64Array" or "BigInt64Array",
|
||||||
|
let numValue be ? ToBigInt(value).
|
||||||
|
...
|
||||||
|
|
||||||
|
ToBigInt ( argument )
|
||||||
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
|
2. Return the value that prim corresponds to in Table [BigInt Conversions]
|
||||||
|
|
||||||
|
BigInt Conversions
|
||||||
|
Argument Type: Boolean
|
||||||
|
Result: Return 1n if prim is true and 0n if prim is false.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
|
var typedArray = new TA([false, true]);
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[0], 0n);
|
||||||
|
assert.sameValue(typedArray[1], 1n);
|
||||||
|
});
|
@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
Return abrupt on null
|
||||||
|
info: |
|
||||||
|
TypedArray ( object )
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
...
|
||||||
|
8. Repeat, while k < len
|
||||||
|
...
|
||||||
|
b. Let kValue be ? Get(arrayLike, Pk).
|
||||||
|
c. Perform ? Set(O, Pk, kValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
[[Set]] ( P, V, Receiver)
|
||||||
|
...
|
||||||
|
2. If Type(P) is String and if SameValue(O, Receiver) is true, then
|
||||||
|
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||||
|
...
|
||||||
|
|
||||||
|
IntegerIndexedElementSet ( O, index, value )
|
||||||
|
...
|
||||||
|
5. If arrayTypeName is "BigUint64Array" or "BigInt64Array",
|
||||||
|
let numValue be ? ToBigInt(value).
|
||||||
|
...
|
||||||
|
|
||||||
|
ToBigInt ( argument )
|
||||||
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
|
2. Return the value that prim corresponds to in Table [BigInt Conversions]
|
||||||
|
|
||||||
|
BigInt Conversions
|
||||||
|
Argument Type: Null
|
||||||
|
Result: Throw a TypeError exception.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA([null]);
|
||||||
|
}, "abrupt completion from Null");
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,82 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
Return abrupt on Number
|
||||||
|
info: |
|
||||||
|
22.2.4.4 TypedArray ( object )
|
||||||
|
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
|
||||||
|
...
|
||||||
|
8. Repeat, while k < len
|
||||||
|
...
|
||||||
|
b. Let kValue be ? Get(arrayLike, Pk).
|
||||||
|
c. Perform ? Set(O, Pk, kValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||||
|
|
||||||
|
...
|
||||||
|
2. If Type(P) is String and if SameValue(O, Receiver) is true, then
|
||||||
|
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If arrayTypeName is "BigUint64Array" or "BigInt64Array",
|
||||||
|
let numValue be ? ToBigInt(value).
|
||||||
|
...
|
||||||
|
|
||||||
|
ToBigInt ( argument )
|
||||||
|
|
||||||
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
|
2. Return the value that prim corresponds to in Table [BigInt Conversions]
|
||||||
|
|
||||||
|
BigInt Conversions
|
||||||
|
Argument Type: Number
|
||||||
|
Result: Throw a TypeError exception.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA([1]);
|
||||||
|
}, "abrupt completion from Number: 1");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA([Math.pow(2, 63)]);
|
||||||
|
}, "abrupt completion from Number: 2**63");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA([+0]);
|
||||||
|
}, "abrupt completion from Number: +0");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA([-0]);
|
||||||
|
}, "abrupt completion from Number: -0");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA([Infinity]);
|
||||||
|
}, "abrupt completion from Number: Infinity");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA([-Infinity]);
|
||||||
|
}, "abrupt completion from Number: -Infinity");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA([NaN]);
|
||||||
|
}, "abrupt completion from Number: NaN");
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
Return abrupt String, when StringToBigInt returns NaN
|
||||||
|
info: |
|
||||||
|
22.2.4.4 TypedArray ( object )
|
||||||
|
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
|
||||||
|
...
|
||||||
|
8. Repeat, while k < len
|
||||||
|
...
|
||||||
|
b. Let kValue be ? Get(arrayLike, Pk).
|
||||||
|
c. Perform ? Set(O, Pk, kValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||||
|
|
||||||
|
...
|
||||||
|
2. If Type(P) is String and if SameValue(O, Receiver) is true, then
|
||||||
|
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If arrayTypeName is "BigUint64Array" or "BigInt64Array",
|
||||||
|
let numValue be ? ToBigInt(value).
|
||||||
|
...
|
||||||
|
|
||||||
|
ToBigInt ( argument )
|
||||||
|
|
||||||
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
|
2. Return the value that prim corresponds to in Table [BigInt Conversions]
|
||||||
|
|
||||||
|
BigInt Conversions
|
||||||
|
Argument Type: String
|
||||||
|
Result:
|
||||||
|
1. Let n be StringToBigInt(prim).
|
||||||
|
2. If n is NaN, throw a SyntaxError exception.
|
||||||
|
3. Return n.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
|
|
||||||
|
assert.throws(SyntaxError, function() {
|
||||||
|
new TA(["definately not a number"]);
|
||||||
|
}, "StringToBigInt(prim) == NaN");
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,77 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
Behavior for input array of Strings, successful conversion
|
||||||
|
info: |
|
||||||
|
22.2.4.4 TypedArray ( object )
|
||||||
|
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
|
||||||
|
...
|
||||||
|
8. Repeat, while k < len
|
||||||
|
...
|
||||||
|
b. Let kValue be ? Get(arrayLike, Pk).
|
||||||
|
c. Perform ? Set(O, Pk, kValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||||
|
|
||||||
|
...
|
||||||
|
2. If Type(P) is String and if SameValue(O, Receiver) is true, then
|
||||||
|
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If arrayTypeName is "BigUint64Array" or "BigInt64Array",
|
||||||
|
let numValue be ? ToBigInt(value).
|
||||||
|
...
|
||||||
|
|
||||||
|
ToBigInt ( argument )
|
||||||
|
|
||||||
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
|
2. Return the value that prim corresponds to in Table [BigInt Conversions]
|
||||||
|
|
||||||
|
BigInt Conversions
|
||||||
|
Argument Type: String
|
||||||
|
Result:
|
||||||
|
1. Let n be StringToBigInt(prim).
|
||||||
|
2. If n is NaN, throw a SyntaxError exception.
|
||||||
|
3. Return n.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
|
var typedArray = new TA(['', '1']);
|
||||||
|
|
||||||
|
assert.sameValue(typedArray[0], 0n);
|
||||||
|
assert.sameValue(typedArray[1], 1n);
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA(["1n"]);
|
||||||
|
}, "A StringNumericLiteral may not include a BigIntLiteralSuffix.");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA(["Infinity"]);
|
||||||
|
}, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity..");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA(["1.1"]);
|
||||||
|
}, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow... decimal points...");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA(["1e7"]);
|
||||||
|
}, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow... exponents...");
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,60 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
Return abrupt on Symbol
|
||||||
|
info: |
|
||||||
|
22.2.4.4 TypedArray ( object )
|
||||||
|
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
|
||||||
|
...
|
||||||
|
8. Repeat, while k < len
|
||||||
|
...
|
||||||
|
b. Let kValue be ? Get(arrayLike, Pk).
|
||||||
|
c. Perform ? Set(O, Pk, kValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.5 [[Set]] ( P, V, Receiver)
|
||||||
|
|
||||||
|
...
|
||||||
|
2. If Type(P) is String and if SameValue(O, Receiver) is true, then
|
||||||
|
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If arrayTypeName is "BigUint64Array" or "BigInt64Array",
|
||||||
|
let numValue be ? ToBigInt(value).
|
||||||
|
...
|
||||||
|
|
||||||
|
ToBigInt ( argument )
|
||||||
|
|
||||||
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
|
2. Return the value that prim corresponds to in Table [BigInt Conversions]
|
||||||
|
|
||||||
|
BigInt Conversions
|
||||||
|
Argument Type: Symbol
|
||||||
|
Result: Throw a TypeError exception.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray, Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var s = Symbol()
|
||||||
|
|
||||||
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA([s]);
|
||||||
|
}, "abrupt completion from Symbol");
|
||||||
|
|
||||||
|
});
|
@ -31,15 +31,15 @@ info: |
|
|||||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
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).
|
||||||
...
|
...
|
||||||
|
|
||||||
7.1.3 ToNumber ( argument )
|
ToBigInt ( argument )
|
||||||
|
|
||||||
Object, Apply the following steps:
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
1. Let primValue be ? ToPrimitive(argument, hint Number).
|
2. Return the value that prim corresponds to in Table 10.
|
||||||
2. Return ? ToNumber(primValue).
|
|
||||||
|
|
||||||
7.1.1 ToPrimitive ( input [ , PreferredType ] )
|
7.1.1 ToPrimitive ( input [ , PreferredType ] )
|
||||||
|
|
||||||
|
@ -31,15 +31,15 @@ info: |
|
|||||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
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).
|
||||||
...
|
...
|
||||||
|
|
||||||
7.1.3 ToNumber ( argument )
|
ToBigInt ( argument )
|
||||||
|
|
||||||
Object, Apply the following steps:
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
1. Let primValue be ? ToPrimitive(argument, hint Number).
|
2. Return the value that prim corresponds to in Table 10.
|
||||||
2. Return ? ToNumber(primValue).
|
|
||||||
|
|
||||||
7.1.1 ToPrimitive ( input [ , PreferredType ] )
|
7.1.1 ToPrimitive ( input [ , PreferredType ] )
|
||||||
|
|
||||||
|
@ -31,15 +31,15 @@ info: |
|
|||||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
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).
|
||||||
...
|
...
|
||||||
|
|
||||||
7.1.3 ToNumber ( argument )
|
ToBigInt ( argument )
|
||||||
|
|
||||||
Object, Apply the following steps:
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
1. Let primValue be ? ToPrimitive(argument, hint Number).
|
2. Return the value that prim corresponds to in Table 10.
|
||||||
2. Return ? ToNumber(primValue).
|
|
||||||
|
|
||||||
7.1.1 ToPrimitive ( input [ , PreferredType ] )
|
7.1.1 ToPrimitive ( input [ , PreferredType ] )
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
assert.throws(Test262Error, function() {
|
||||||
new TA([8n, sample]);
|
new TA([8n, sample]);
|
||||||
}, "abrupt completion from ToNumber(sample)");
|
}, "abrupt completion from ToBigInt(sample)");
|
||||||
|
|
||||||
assert.sameValue(valueOf, 1, "valueOf called once");
|
assert.sameValue(valueOf, 1, "valueOf called once");
|
||||||
assert.sameValue(toString, 1, "toString called once");
|
assert.sameValue(toString, 1, "toString called once");
|
||||||
|
@ -31,15 +31,15 @@ info: |
|
|||||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
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).
|
||||||
...
|
...
|
||||||
|
|
||||||
7.1.3 ToNumber ( argument )
|
ToBigInt ( argument )
|
||||||
|
|
||||||
Object, Apply the following steps:
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
1. Let primValue be ? ToPrimitive(argument, hint Number).
|
2. Return the value that prim corresponds to in Table 10.
|
||||||
2. Return ? ToNumber(primValue).
|
|
||||||
|
|
||||||
7.1.1 ToPrimitive ( input [ , PreferredType ] )
|
7.1.1 ToPrimitive ( input [ , PreferredType ] )
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
new TA([8n, sample]);
|
new TA([8n, sample]);
|
||||||
}, "abrupt completion from ToNumber(sample)");
|
}, "abrupt completion from ToBigInt(sample)");
|
||||||
|
|
||||||
assert.sameValue(valueOf, 1, "valueOf called once");
|
assert.sameValue(valueOf, 1, "valueOf called once");
|
||||||
assert.sameValue(toString, 1, "toString called once");
|
assert.sameValue(toString, 1, "toString called once");
|
||||||
|
@ -31,15 +31,15 @@ info: |
|
|||||||
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
|
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).
|
||||||
...
|
...
|
||||||
|
|
||||||
7.1.3 ToNumber ( argument )
|
ToBigInt ( argument )
|
||||||
|
|
||||||
Object, Apply the following steps:
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
1. Let primValue be ? ToPrimitive(argument, hint Number).
|
2. Return the value that prim corresponds to in Table 10.
|
||||||
2. Return ? ToNumber(primValue).
|
|
||||||
|
|
||||||
7.1.1 ToPrimitive ( input [ , PreferredType ] )
|
7.1.1 ToPrimitive ( input [ , PreferredType ] )
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
assert.throws(Test262Error, function() {
|
||||||
new TA([8n, sample]);
|
new TA([8n, sample]);
|
||||||
}, "abrupt completion from ToNumber(sample)");
|
}, "abrupt completion from ToBigInt(sample)");
|
||||||
|
|
||||||
assert.sameValue(valueOf, 1, "valueOf called once");
|
assert.sameValue(valueOf, 1, "valueOf called once");
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
Return abrupt on undefined
|
||||||
|
info: |
|
||||||
|
TypedArray ( object )
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
|
||||||
|
internal slot.
|
||||||
|
...
|
||||||
|
8. Repeat, while k < len
|
||||||
|
...
|
||||||
|
b. Let kValue be ? Get(arrayLike, Pk).
|
||||||
|
c. Perform ? Set(O, Pk, kValue, true).
|
||||||
|
...
|
||||||
|
|
||||||
|
[[Set]] ( P, V, Receiver)
|
||||||
|
...
|
||||||
|
2. If Type(P) is String and if SameValue(O, Receiver) is true, then
|
||||||
|
a. Let numericIndex be ! CanonicalNumericIndexString(P).
|
||||||
|
b. If numericIndex is not undefined, then
|
||||||
|
i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
|
||||||
|
...
|
||||||
|
|
||||||
|
IntegerIndexedElementSet ( O, index, value )
|
||||||
|
...
|
||||||
|
5. If arrayTypeName is "BigUint64Array" or "BigInt64Array",
|
||||||
|
let numValue be ? ToBigInt(value).
|
||||||
|
...
|
||||||
|
|
||||||
|
ToBigInt ( argument )
|
||||||
|
Object, Apply the following steps:
|
||||||
|
1. Let prim be ? ToPrimitive(argument, hint Number).
|
||||||
|
2. Return the value that prim corresponds to in Table [BigInt Conversions]
|
||||||
|
|
||||||
|
BigInt Conversions
|
||||||
|
Argument Type: Undefined
|
||||||
|
Result: Throw a TypeError exception.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA([undefined]);
|
||||||
|
}, "abrupt completion from undefined");
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-typedarray
|
||||||
|
description: >
|
||||||
|
If typedArray constructor argument is not a Big(U)Int, throw
|
||||||
|
info: |
|
||||||
|
22.2.4.3 TypedArray ( typedArray )
|
||||||
|
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object has a [[TypedArrayName]] internal slot.
|
||||||
|
|
||||||
|
...
|
||||||
|
19. Else,
|
||||||
|
...
|
||||||
|
c. If one of srcType and elementType contains the substring "Big" and the other
|
||||||
|
does not, throw a TypeError exception.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js, testTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var notBigTypedArray;
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
|
|
||||||
|
notBigTypedArray = new TA(16);
|
||||||
|
|
||||||
|
testWithBigIntTypedArrayConstructors(function(BTA) {
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new BTA(notBigTypedArray);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (C) 2018 Valerie Young. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-typedarray
|
||||||
|
description: >
|
||||||
|
If typedArray constructor argument is a Big(U)Int, throw
|
||||||
|
info: |
|
||||||
|
22.2.4.3 TypedArray ( typedArray )
|
||||||
|
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is Object and that
|
||||||
|
object has a [[TypedArrayName]] internal slot.
|
||||||
|
|
||||||
|
...
|
||||||
|
19. Else,
|
||||||
|
...
|
||||||
|
c. If one of srcType and elementType contains the substring "Big" and the other
|
||||||
|
does not, throw a TypeError exception.
|
||||||
|
|
||||||
|
includes: [testBigIntTypedArray.js, testTypedArray.js]
|
||||||
|
features: [BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var bigTypedArray;
|
||||||
|
|
||||||
|
testWithBigIntTypedArrayConstructors(function(BTA) {
|
||||||
|
|
||||||
|
bigTypedArray = new BTA(16);
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new TA(bigTypedArray);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user