Fix errors recently introduced. (#1448)

* Fix bad references on tests for BigInt TypedArrays

* Remove bad conversions for BigInt TypedArray

* Cleanup the BigInt TypedArray harness file

Remove non used code (testBigIntTypedArrayConversions)

Move the constructors list to inside the exposed function, this prevents early implementations to fail before the function is called.

* Fix bad references in TypedArrays.of (BigInt)

* Remove BigInt tests from typedarray harness test

* Use BigInt for BigInt typedArrays

* Apply last fixings on BigInt TypedArray tests

* Apply fixes to last revision from @anba
This commit is contained in:
Leo Balter 2018-02-27 14:58:56 -05:00 committed by GitHub
parent 173e98e00b
commit 2712807027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
167 changed files with 306 additions and 1311 deletions

View File

@ -5,34 +5,26 @@ description: |
Collection of functions used to assert the correctness of BigInt TypedArray objects. Collection of functions used to assert the correctness of BigInt TypedArray objects.
---*/ ---*/
/**
* Array containing every typed array constructor.
*/
var BigIntTypedArrayConstructors = [
BigInt64Array,
BigUint64Array
];
/** /**
* The %TypedArray% intrinsic constructor function. * The %TypedArray% intrinsic constructor function.
*/ */
var TypedArray = Object.getPrototypeOf(Int8Array); var TypedArray = Object.getPrototypeOf(Int8Array);
/**
* Callback for testing a typed array constructor.
*
* @callback typedArrayConstructorCallback
* @param {Function} Constructor the constructor object to test with.
*/
/** /**
* Calls the provided function for every typed array constructor. * Calls the provided function for every typed array constructor.
* *
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays * @param {Array} selected - An optional Array with filtered typed arrays
*/ */
function testWithBigIntTypedArrayConstructors(f, selected) { function testWithBigIntTypedArrayConstructors(f) {
var constructors = selected || BigIntTypedArrayConstructors; /**
* Array containing every BigInt typed array constructor.
*/
var constructors = [
BigInt64Array,
BigUint64Array
];
for (var i = 0; i < constructors.length; ++i) { for (var i = 0; i < constructors.length; ++i) {
var constructor = constructors[i]; var constructor = constructors[i];
try { try {
@ -43,30 +35,3 @@ function testWithBigIntTypedArrayConstructors(f, selected) {
} }
} }
} }
/**
* Helper for conversion operations on TypedArrays, the expected values
* properties are indexed in order to match the respective value for each
* TypedArray constructor
* @param {Function} fn - the function to call for each constructor and value.
* will be called with the constructor, value, expected
* value, and a initial value that can be used to avoid
* a false positive with an equivalent expected value.
*/
function testBigIntTypedArrayConversions(byteConversionValues, fn) {
var values = byteConversionValues.values;
var expected = byteConversionValues.expected;
testWithBigIntTypedArrayConstructors(function(TA) {
var name = TA.name.slice(0, -5);
return values.forEach(function(value, index) {
var exp = expected[name][index];
var initial = 0;
if (exp === 0) {
initial = 1;
}
fn(TA, value, exp, initial);
});
});
}

View File

@ -1,70 +0,0 @@
// 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: Consistent canonicalization of NaN 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).
...
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
isLittleEndian ] )
...
8. If type is "Float32", then
a. Set rawBytes to a List containing the 4 bytes that are the result
of converting value to IEEE 754-2008 binary32 format using Round to
nearest, ties to even rounding mode. If isLittleEndian is false, the
bytes are arranged in big endian order. Otherwise, the bytes are
arranged in little endian order. If value is NaN, rawValue may be set
to any implementation chosen IEEE 754-2008 binary64 format Not-a-Number
encoding. An implementation must always choose the same encoding for
each implementation distinguishable NaN value.
9. Else, if type is "Float64", then
a. Set rawBytes to a List containing the 8 bytes that are the IEEE
754-2008 binary64 format encoding of value. If isLittleEndian is false,
the bytes are arranged in big endian order. Otherwise, the bytes are
arranged in little endian order. If value is NaN, rawValue may be set
to any implementation chosen IEEE 754-2008 binary32 format Not-a-Number
encoding. An implementation must always choose the same encoding for
each implementation distinguishable NaN value.
...
includes: [nans.js, testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray]
---*/
function body(FloatArray) {
var sample = new FloatArray(3);
var control, idx, someNaN, sampleBytes, controlBytes;
for (idx = 0; idx < distinctNaNs.length; ++idx) {
someNaN = distinctNaNs[idx];
control = new FloatArray([someNaN, someNaN, someNaN]);
sample.fill(someNaN);
sampleBytes = new Uint8Array(sample.buffer);
controlBytes = new Uint8Array(control.buffer);
assert(compareArray(sampleBytes, controlBytes), 'NaN value #' + idx);
}
}
testWithBigIntTypedArrayConstructors(body, [Float32Array, Float64Array]);

View File

@ -1,56 +0,0 @@
// 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).
...
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
isLittleEndian ] )
...
8. If type is "Float32", then
...
9. Else, if type is "Float64", then
...
10. Else,
...
b. Let convOp be the abstract operation named in the Conversion Operation
column in Table 50 for Element Type type.
c. Let intValue be convOp(value).
d. If intValue 0, then
...
e. Else,
...
includes: [byteConversionValues.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
var sample = new TA([initial]);
sample.fill(value);
assert.sameValue(sample[0], expected, value + " converts to " + expected);
});

View File

@ -38,8 +38,8 @@ features: [BigInt, Symbol.species, TypedArray]
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA([40n]); var sample = new TA([40n]);
var otherTA = TA === Int8Array ? Int16Array : Int8Array; var otherTA = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
var other = new otherTA([1, 0, 1]); var other = new otherTA([1n, 0n, 1n]);
var result; var result;
sample.constructor = {}; sample.constructor = {};
@ -50,5 +50,5 @@ testWithBigIntTypedArrayConstructors(function(TA) {
result = sample.filter(function() {}); result = sample.filter(function() {});
assert.sameValue(result, other, "returned another typedarray"); assert.sameValue(result, other, "returned another typedarray");
assert(compareArray(result, [1, 0, 1]), "the returned object is preserved"); assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved");
}); });

View File

@ -1,62 +0,0 @@
// 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.map
description: Consistent canonicalization of NaN values
info: |
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
...
8. Repeat, while k < len
...
d. Perform ? Set(A, Pk, mappedValue, true).
...
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
...
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
...
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
isLittleEndian ] )
...
8. If type is "Float32", then
a. Set rawBytes to a List containing the 4 bytes that are the result
of converting value to IEEE 754-2008 binary32 format using Round to
nearest, ties to even rounding mode. If isLittleEndian is false, the
bytes are arranged in big endian order. Otherwise, the bytes are
arranged in little endian order. If value is NaN, rawValue may be set
to any implementation chosen IEEE 754-2008 binary64 format Not-a-Number
encoding. An implementation must always choose the same encoding for
each implementation distinguishable NaN value.
9. Else, if type is "Float64", then
a. Set rawBytes to a List containing the 8 bytes that are the IEEE
754-2008 binary64 format encoding of value. If isLittleEndian is false,
the bytes are arranged in big endian order. Otherwise, the bytes are
arranged in little endian order. If value is NaN, rawValue may be set
to any implementation chosen IEEE 754-2008 binary32 format Not-a-Number
encoding. An implementation must always choose the same encoding for
each implementation distinguishable NaN value.
...
includes: [nans.js, testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray]
---*/
function body(FloatArray) {
var sample = new FloatArray(distinctNaNs);
var sampleBytes, resultBytes;
var i = 0;
var result = sample.map(function() {
return distinctNaNs[i++];
});
sampleBytes = new Uint8Array(sample.buffer);
resultBytes = new Uint8Array(result.buffer);
assert(compareArray(sampleBytes, resultBytes));
}
testWithBigIntTypedArrayConstructors(body, [Float32Array, Float64Array]);

View File

@ -1,52 +0,0 @@
// 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.map
description: >
Verify conversion values on returned instance
info: |
22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
...
8. Repeat, while k < len
...
d. Perform ? Set(A, Pk, mappedValue, true).
...
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
...
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
...
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
isLittleEndian ] )
...
8. If type is "Float32", then
...
9. Else, if type is "Float64", then
...
10. Else,
...
b. Let convOp be the abstract operation named in the Conversion Operation
column in Table 50 for Element Type type.
c. Let intValue be convOp(value).
d. If intValue 0, then
...
e. Else,
...
includes: [byteConversionValues.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
var sample = new TA([initial]);
var result = sample.map(function() {
return value;
});
assert.sameValue(result[0], expected, value + " converts to " + expected);
});

View File

@ -1,31 +0,0 @@
// 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.set-array-offset
description: >
Values conversions on ToNumber(src property value)
info: |
22.2.3.23.1 %TypedArray%.prototype.set (array [ , 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.
...
21. Repeat, while targetByteIndex < limit
a. Let Pk be ! ToString(k).
b. Let kNumber be ? ToNumber(? Get(src, Pk)).
c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
kNumber).
...
includes: [byteConversionValues.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
var sample = new TA([initial]);
sample.set([value]);
assert.sameValue(sample[0], expected, "["+value+"] => ["+expected +"]");
});

View File

@ -1,35 +0,0 @@
// 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.set.2
description: Preservation of bit-level encoding
info: |
[...]
28. Else,
a. NOTE: If srcType and targetType are the same, the transfer must be
performed in a manner that preserves the bit-level encoding of the
source data.
b. Repeat, while targetByteIndex < limit
i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8").
ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8",
value).
iii. Set srcByteIndex to srcByteIndex + 1.
iv. Set targetByteIndex to targetByteIndex + 1.
includes: [nans.js, compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
function body(FloatArray) {
var source = new FloatArray(distinctNaNs);
var target = new FloatArray(distinctNaNs.length);
var sourceBytes, targetBytes;
target.set(source);
sourceBytes = new Uint8Array(source.buffer);
targetBytes = new Uint8Array(target.buffer);
assert(compareArray(sourceBytes, targetBytes))
}
testWithBigIntTypedArrayConstructors(body, [Float32Array, Float64Array]);

View File

@ -1,51 +0,0 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.set-typedarray-offset
description: >
Set converted values from different buffer of different types and different type instances
includes: [byteConversionValues.js, testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer]
---*/
testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
if (TA === Float64Array || TA === Float32Array || TA === Uint8ClampedArray) {
return;
}
if (TA === Int32Array) {
return;
}
var sab, src, target;
sab = new SharedArrayBuffer(4);
src = new Int32Array(sab);
src[0] = value;
target = new TA([initial]);
target.set(src);
assert.sameValue(target[0], expected, "src is SAB-backed");
sab = new SharedArrayBuffer(4);
src = new Int32Array([value]);
target = new TA(sab);
target[0] = initial;
target.set(src);
assert.sameValue(target[0], expected, "target is SAB-backed");
var sab1 = new SharedArrayBuffer(4);
var sab2 = new SharedArrayBuffer(4);
src = new Int32Array(sab1);
src[0] = value;
target = new TA(sab2);
target[0] = initial;
target.set(src);
assert.sameValue(target[0], expected, "src and target are SAB-backed");
});

View File

@ -1,38 +0,0 @@
// 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.set-typedarray-offset
description: >
Set converted values from different buffer and different type instances
info: |
22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
the definition in 22.2.3.23.1 applies.
...
23. If SameValue(srcBuffer, targetBuffer) is true, then
...
24. Else, let srcByteIndex be srcByteOffset.
...
27. If SameValue(srcType, targetType) is true, then,
...
28. Else,
a. Repeat, while targetByteIndex < limit
i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType).
ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
value).
includes: [byteConversionValues.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
if (TA === Float64Array) {
return;
}
var src = new Float64Array([value]);
var target = new TA([initial]);
target.set(src);
assert.sameValue(target[0], expected);
});

View File

@ -11,97 +11,93 @@ includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var other = Int32Array; var sab = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT);
var sab = new SharedArrayBuffer(2 * other.BYTES_PER_ELEMENT); var src = new BigInt64Array(sab);
var src = new other(sab); src[0] = 42n;
src[0] = 42; src[1] = 43n;
src[1] = 43;
var sample, result; var sample, result;
sample = new TA([1, 2, 3, 4]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(src, 0); result = sample.set(src, 0);
assert(compareArray(sample, [42, 43, 3, 4]), "src is SAB-backed, offset: 0, result: " + sample); assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src is SAB-backed, offset: 0, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sample = new TA([1, 2, 3, 4]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(src, 1); result = sample.set(src, 1);
assert(compareArray(sample, [1, 42, 43, 4]), "src is SAB-backed, offset: 1, result: " + sample); assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src is SAB-backed, offset: 1, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sample = new TA([1, 2, 3, 4]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(src, 2); result = sample.set(src, 2);
assert(compareArray(sample, [1, 2, 42, 43]), "src is SAB-backed, offset: 2, result: " + sample); assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src is SAB-backed, offset: 2, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
src = new BigInt64Array([42n, 43n]);
src = new other([42, 43]);
sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab); sample = new TA(sab);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 0); result = sample.set(src, 0);
assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample); assert(compareArray(sample, [42n, 43n, 3n, 4n]), "sample is SAB-backed, offset: 0, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab); sample = new TA(sab);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 1); result = sample.set(src, 1);
assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample); assert(compareArray(sample, [1n, 42n, 43n, 4n]), "sample is SAB-backed, offset: 1, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab); sample = new TA(sab);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 2); result = sample.set(src, 2);
assert(compareArray(sample, [1, 2, 42, 43]), "sample is SAB-backed, offset: 2, result: " + sample); assert(compareArray(sample, [1n, 2n, 42n, 43n]), "sample is SAB-backed, offset: 2, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
var sab1 = new SharedArrayBuffer(2 * other.BYTES_PER_ELEMENT); var sab1 = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT);
src = new other(sab1); src = new BigInt64Array(sab1);
src[0] = 42; src[0] = 42n;
src[1] = 43; src[1] = 43n;
var sab2; var sab2;
sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab2); sample = new TA(sab2);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 0); result = sample.set(src, 0);
assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample); assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src and sample are SAB-backed, offset: 0, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab2); sample = new TA(sab2);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 1); result = sample.set(src, 1);
assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample); assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src and sample are SAB-backed, offset: 1, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab2); sample = new TA(sab2);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 2); result = sample.set(src, 2);
assert(compareArray(sample, [1, 2, 42, 43]), "src and sample are SAB-backed, offset: 2, result: " + sample); assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src and sample are SAB-backed, offset: 2, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
}, int_views); });

View File

@ -10,98 +10,95 @@ includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample, result; var sample, result;
var sab = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); var sab = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT);
var src = new TA(sab); var src = new TA(sab);
src[0] = 42; src[0] = 42n;
src[1] = 43; src[1] = 43n;
sample = new TA([1, 2, 3, 4]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(src, 1); result = sample.set(src, 1);
assert(compareArray(sample, [1, 42, 43, 4]), "src is SAB-backed, offset: 1, result: " + sample); assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src is SAB-backed, offset: 1, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sample = new TA([1, 2, 3, 4]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(src, 0); result = sample.set(src, 0);
assert(compareArray(sample, [42, 43, 3, 4]), "src is SAB-backed, offset: 0, result: " + sample); assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src is SAB-backed, offset: 0, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sample = new TA([1, 2, 3, 4]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(src, 2); result = sample.set(src, 2);
assert(compareArray(sample, [1, 2, 42, 43]), "src is SAB-backed, offset: 2, result: " + sample); assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src is SAB-backed, offset: 2, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
src = new TA([42n, 43n]);
src = new TA([42, 43]);
sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab); sample = new TA(sab);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 1); result = sample.set(src, 1);
assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample); assert(compareArray(sample, [1n, 42n, 43n, 4n]), "sample is SAB-backed, offset: 1, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab); sample = new TA(sab);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 0); result = sample.set(src, 0);
assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample); assert(compareArray(sample, [42n, 43n, 3n, 4n]), "sample is SAB-backed, offset: 0, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab); sample = new TA(sab);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 2); result = sample.set(src, 2);
assert(compareArray(sample, [1, 2, 42, 43]), "sample is SAB-backed, offset: 2, result: " + sample); assert(compareArray(sample, [1n, 2n, 42n, 43n]), "sample is SAB-backed, offset: 2, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT);
src = new TA(sab1); src = new TA(sab1);
src[0] = 42; src[0] = 42n;
src[1] = 43; src[1] = 43n;
var sab2; var sab2;
sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab2); sample = new TA(sab2);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 1); result = sample.set(src, 1);
assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample); assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src and sample are SAB-backed, offset: 1, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab2); sample = new TA(sab2);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 0); result = sample.set(src, 0);
assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample); assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src and sample are SAB-backed, offset: 0, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab2); sample = new TA(sab2);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
result = sample.set(src, 2); result = sample.set(src, 2);
assert(compareArray(sample, [1, 2, 42, 43]), "src and sample are SAB-backed, offset: 2, result: " + sample); assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src and sample are SAB-backed, offset: 2, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
}, int_views); });

View File

@ -11,41 +11,39 @@ includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample, src, result, sab; var sample, src, result, sab;
sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab); sample = new TA(sab);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
src = new TA(sample.buffer, 0, 2); src = new TA(sample.buffer, 0, 2);
result = sample.set(src, 0); result = sample.set(src, 0);
assert(compareArray(sample, [1, 2, 3, 4]), "offset: 0, result: " + sample); assert(compareArray(sample, [1n, 2n, 3n, 4n]), "offset: 0, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab); sample = new TA(sab);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
src = new TA(sample.buffer, 0, 2); src = new TA(sample.buffer, 0, 2);
result = sample.set(src, 1); result = sample.set(src, 1);
assert(compareArray(sample, [1, 1, 2, 4]), "offset: 1, result: " + sample); assert(compareArray(sample, [1n, 1n, 2n, 4n]), "offset: 1, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
sample = new TA(sab); sample = new TA(sab);
sample[0] = 1; sample[0] = 1n;
sample[1] = 2; sample[1] = 2n;
sample[2] = 3; sample[2] = 3n;
sample[3] = 4; sample[3] = 4n;
src = new TA(sample.buffer, 0, 2); src = new TA(sample.buffer, 0, 2);
result = sample.set(src, 2); result = sample.set(src, 2);
assert(compareArray(sample, [1, 2, 1, 2]), "offset: 2, result: " + sample); assert(compareArray(sample, [1n, 2n, 1n, 2n]), "offset: 2, result: " + sample);
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, "returns undefined");
}, int_views); });

View File

@ -1,39 +0,0 @@
// 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.slice
description: Preservation of bit-level encoding
info: |
[...]
15. Else if count > 0, then
[...]
e. NOTE: If srcType and targetType are the same, the transfer must be
performed in a manner that preserves the bit-level encoding of the
source data.
f. Let srcByteOffet be the value of O's [[ByteOffset]] internal slot.
g. Let targetByteIndex be A's [[ByteOffset]] internal slot.
h. Let srcByteIndex be (k × elementSize) + srcByteOffet.
i. Let limit be targetByteIndex + count × elementSize.
j. Repeat, while targetByteIndex < limit
i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8").
ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8",
value).
iii. Increase srcByteIndex by 1.
iv. Increase targetByteIndex by 1.
includes: [nans.js, compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
function body(FloatArray) {
var subject = new FloatArray(distinctNaNs);
var sliced, subjectBytes, slicedBytes;
sliced = subject.slice();
subjectBytes = new Uint8Array(subject.buffer);
slicedBytes = new Uint8Array(sliced.buffer);
assert(compareArray(subjectBytes, slicedBytes));
}
testWithBigIntTypedArrayConstructors(body, [Float32Array, Float64Array]);

View File

@ -27,7 +27,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
sample.constructor = {}; sample.constructor = {};
sample.constructor[Symbol.species] = function(count) { sample.constructor[Symbol.species] = function(count) {
var other = TA === Int8Array ? Int16Array : Int8Array; var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
$DETACHBUFFER(sample.buffer); $DETACHBUFFER(sample.buffer);
return new other(count); return new other(count);
}; };

View File

@ -27,7 +27,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var sample, result, other; var sample, result, other;
var ctor = {}; var ctor = {};
ctor[Symbol.species] = function(count) { ctor[Symbol.species] = function(count) {
other = TA === Int8Array ? Int16Array : Int8Array; other = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
$DETACHBUFFER(sample.buffer); $DETACHBUFFER(sample.buffer);
return new other(count); return new other(count);
}; };

View File

@ -38,7 +38,7 @@ features: [BigInt, Symbol.species, TypedArray]
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA([40n]); var sample = new TA([40n]);
var other = new Int8Array([1, 0, 1]); var other = new BigInt64Array([1n, 0n, 1n]);
var result; var result;
sample.constructor = {}; sample.constructor = {};
@ -49,5 +49,5 @@ testWithBigIntTypedArrayConstructors(function(TA) {
result = sample.slice(0, 0); result = sample.slice(0, 0);
assert.sameValue(result, other, "returned another typedarray"); assert.sameValue(result, other, "returned another typedarray");
assert(compareArray(result, [1, 0, 1]), "the returned object is preserved"); assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved");
}); });

View File

@ -1,38 +0,0 @@
// 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.sort
description: Sort values to numeric ascending order
info: |
22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
When the TypedArray SortCompare abstract operation is called with two
arguments x and y, the following steps are taken:
...
NOTE: Because NaN always compares greater than any other value, NaN property
values always sort to the end of the result when comparefn is not provided.
includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample;
sample = new TA([2, NaN, NaN, 0, 1]).sort();
assert.sameValue(sample[0], 0, "#1 [0]");
assert.sameValue(sample[1], 1, "#1 [1]");
assert.sameValue(sample[2], 2, "#1 [2]");
assert.sameValue(sample[3], NaN, "#1 [3]");
assert.sameValue(sample[4], NaN, "#1 [4]");
sample = new TA([3, NaN, NaN, Infinity, 0, -Infinity, 2]).sort();
assert.sameValue(sample[0], -Infinity, "#2 [0]");
assert.sameValue(sample[1], 0, "#2 [1]");
assert.sameValue(sample[2], 2, "#2 [2]");
assert.sameValue(sample[3], 3, "#2 [3]");
assert.sameValue(sample[4], Infinity, "#2 [4]");
assert.sameValue(sample[5], NaN, "#2 [5]");
assert.sameValue(sample[6], NaN, "#2 [6]");
}, [Float64Array, Float32Array]);

View File

@ -25,29 +25,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
sample = new TA([3n, 4n, 3n, 1n, 0n, 1n, 2n]).sort(); sample = new TA([3n, 4n, 3n, 1n, 0n, 1n, 2n]).sort();
assert(compareArray(sample, [0n, 1n, 1n, 2n, 3n, 3n, 4n]), "repeating numbers"); assert(compareArray(sample, [0n, 1n, 1n, 2n, 3n, 3n, 4n]), "repeating numbers");
sample = new TA([1n, 0n, -0n, 2n]).sort();
assert(compareArray(sample, [0n, 0n, 1n, 2n]), "0s");
}); });
testWithBigIntTypedArrayConstructors(function(TA) { var sample = new BigInt64Array([-4n, 3n, 4n, -3n, 2n, -2n, 1n, 0n]).sort();
var sample = new TA([-4, 3, 4, -3, 2, -2, 1, 0]).sort(); assert(compareArray(sample, [-4n, -3n, -2n, 0n, 1n, 2n, 3n, 4n]), "negative values");
assert(compareArray(sample, [-4, -3, -2, 0, 1, 2, 3, 4]), "negative values");
}, [Float64Array, Float32Array, Int8Array, Int16Array, Int32Array]);
testWithBigIntTypedArrayConstructors(function(TA) {
var sample;
sample = new TA([0.5, 0, 1.5, 1]).sort();
assert(compareArray(sample, [0, 0.5, 1, 1.5]), "non integers");
sample = new TA([0.5, 0, 1.5, -0.5, -1, -1.5, 1]).sort();
assert(compareArray(sample, [-1.5, -1, -0.5, 0, 0.5, 1, 1.5]), "non integers + negatives");
sample = new TA([1, 0, -0, 2]).sort();
assert(compareArray(sample, [0, 0, 1, 2]), "0 and -0");
sample = new TA([3, 4, Infinity, -Infinity, 1, 2]).sort();
assert(compareArray(sample, [-Infinity, 1, 2, 3, 4, Infinity]), "infinities");
}, [Float64Array, Float32Array]);

View File

@ -37,7 +37,7 @@ features: [BigInt, Symbol.species, TypedArray]
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA([40n]); var sample = new TA([40n]);
var other = new Int8Array([1, 0, 1]); var other = new BigInt64Array([1n, 0n, 1n]);
var result; var result;
sample.constructor = {}; sample.constructor = {};
@ -48,5 +48,5 @@ testWithBigIntTypedArrayConstructors(function(TA) {
result = sample.subarray(0, 0); result = sample.subarray(0, 0);
assert.sameValue(result, other, "returned another typedarray"); assert.sameValue(result, other, "returned another typedarray");
assert(compareArray(result, [1, 0, 1]), "the returned object is preserved"); assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved");
}); });

View File

@ -22,7 +22,7 @@ features: [BigInt, SharedArrayBuffer, TypedArray]
var buffer = new SharedArrayBuffer(1); var buffer = new SharedArrayBuffer(1);
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
if (TA.BYTES_PER_ELEMENT === 1) { if (TA.BYTES_PER_ELEMENT === 1) {
// Impossible to trigger this step here. // Impossible to trigger this step here.
return; return;

View File

@ -21,7 +21,7 @@ features: [BigInt, TypedArray]
var buffer = new ArrayBuffer(1); var buffer = new ArrayBuffer(1);
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
if (TA.BYTES_PER_ELEMENT === 1) { if (TA.BYTES_PER_ELEMENT === 1) {
// Impossible to trigger this step here. // Impossible to trigger this step here.
return; return;

View File

@ -22,7 +22,7 @@ features: [BigInt, SharedArrayBuffer, TypedArray]
var buffer = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(buffer, -1); new TA(buffer, -1);
}); });

View File

@ -21,7 +21,7 @@ features: [BigInt, TypedArray]
var buffer = new ArrayBuffer(8); var buffer = new ArrayBuffer(8);
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(buffer, -1); new TA(buffer, -1);
}); });

View File

@ -17,7 +17,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TAConstructor) { testWithBigIntTypedArrayConstructors(function(TAConstructor) {
var typedArray = new TAConstructor(new SharedArrayBuffer(8), -0); var typedArray = new TAConstructor(new SharedArrayBuffer(8), -0);
assert.sameValue(typedArray.byteOffset, +0); assert.sameValue(typedArray.byteOffset, +0);
}); });

View File

@ -17,7 +17,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TAConstructor) { testWithBigIntTypedArrayConstructors(function(TAConstructor) {
var typedArray = new TAConstructor(new ArrayBuffer(8), -0); var typedArray = new TAConstructor(new ArrayBuffer(8), -0);
assert.sameValue(typedArray.byteOffset, +0); assert.sameValue(typedArray.byteOffset, +0);
}); });

View File

@ -22,7 +22,7 @@ features: [BigInt, Symbol, SharedArrayBuffer, TypedArray]
var byteOffset = Symbol("1"); var byteOffset = Symbol("1");
var buffer = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
new TA(buffer, byteOffset); new TA(buffer, byteOffset);
}); });

View File

@ -21,7 +21,7 @@ features: [BigInt, Symbol, TypedArray]
var byteOffset = Symbol("1"); var byteOffset = Symbol("1");
var buffer = new ArrayBuffer(8); var buffer = new ArrayBuffer(8);
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
new TA(buffer, byteOffset); new TA(buffer, byteOffset);
}); });

View File

@ -21,7 +21,7 @@ features: [BigInt, SharedArrayBuffer, TypedArray]
var buffer = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
if (TA.BYTES_PER_ELEMENT === 1) { if (TA.BYTES_PER_ELEMENT === 1) {
// Impossible to trigger this step here. // Impossible to trigger this step here.
return; return;

View File

@ -20,7 +20,7 @@ features: [BigInt, TypedArray]
var buffer = new ArrayBuffer(8); var buffer = new ArrayBuffer(8);
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
if (TA.BYTES_PER_ELEMENT === 1) { if (TA.BYTES_PER_ELEMENT === 1) {
// Impossible to trigger this step here. // Impossible to trigger this step here.
return; return;

View File

@ -13,7 +13,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var offset = TA.BYTES_PER_ELEMENT; var offset = TA.BYTES_PER_ELEMENT;
var buffer = new ArrayBuffer(3 * offset); var buffer = new ArrayBuffer(3 * offset);
var byteOffset = { valueOf() { $DETACHBUFFER(buffer); return offset; } }; var byteOffset = { valueOf() { $DETACHBUFFER(buffer); return offset; } };

View File

@ -26,7 +26,7 @@ var byteOffset = {
} }
}; };
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
new TA(buffer, byteOffset); new TA(buffer, byteOffset);
}); });

View File

@ -25,7 +25,7 @@ var byteOffset = {
} }
}; };
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
new TA(buffer, byteOffset); new TA(buffer, byteOffset);
}); });

View File

@ -41,7 +41,7 @@ Object.defineProperty(newTarget, "prototype", {
} }
}); });
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
Reflect.construct(TA, [buffer], newTarget); Reflect.construct(TA, [buffer], newTarget);
}); });

View File

@ -40,7 +40,7 @@ Object.defineProperty(newTarget, "prototype", {
} }
}); });
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
Reflect.construct(TA, [buffer], newTarget); Reflect.construct(TA, [buffer], newTarget);
}); });

View File

@ -15,7 +15,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var offset = TA.BYTES_PER_ELEMENT; var offset = TA.BYTES_PER_ELEMENT;
var buffer = new SharedArrayBuffer(3 * offset); var buffer = new SharedArrayBuffer(3 * offset);

View File

@ -14,7 +14,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var offset = TA.BYTES_PER_ELEMENT; var offset = TA.BYTES_PER_ELEMENT;
var buffer = new ArrayBuffer(3 * offset); var buffer = new ArrayBuffer(3 * offset);

View File

@ -16,7 +16,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var length = 4; var length = 4;
var buffer = new SharedArrayBuffer(bpe * length * 4); var buffer = new SharedArrayBuffer(bpe * length * 4);

View File

@ -15,7 +15,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var length = 4; var length = 4;
var buffer = new ArrayBuffer(bpe * length * 4); var buffer = new ArrayBuffer(bpe * length * 4);

View File

@ -18,7 +18,7 @@ features: [BigInt, SharedArrayBuffer, TypedArray]
var buffer = new SharedArrayBuffer(16); var buffer = new SharedArrayBuffer(16);
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(buffer, 0, -1); new TA(buffer, 0, -1);
}); });

View File

@ -17,7 +17,7 @@ features: [BigInt, TypedArray]
var buffer = new ArrayBuffer(16); var buffer = new ArrayBuffer(16);
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(buffer, 0, -1); new TA(buffer, 0, -1);
}); });

View File

@ -15,7 +15,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var buffer = new SharedArrayBuffer(bpe * 4); var buffer = new SharedArrayBuffer(bpe * 4);

View File

@ -14,7 +14,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var buffer = new ArrayBuffer(bpe * 4); var buffer = new ArrayBuffer(bpe * 4);

View File

@ -13,7 +13,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var offset = TA.BYTES_PER_ELEMENT; var offset = TA.BYTES_PER_ELEMENT;
var buffer = new ArrayBuffer(3 * offset); var buffer = new ArrayBuffer(3 * offset);
$DETACHBUFFER(buffer); $DETACHBUFFER(buffer);

View File

@ -22,7 +22,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var buffer = new SharedArrayBuffer(bpe); var buffer = new SharedArrayBuffer(bpe);

View File

@ -21,7 +21,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var buffer = new ArrayBuffer(bpe); var buffer = new ArrayBuffer(bpe);

View File

@ -22,7 +22,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var buffer = new SharedArrayBuffer(bpe); var buffer = new SharedArrayBuffer(bpe);

View File

@ -21,7 +21,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var buffer = new ArrayBuffer(bpe); var buffer = new ArrayBuffer(bpe);

View File

@ -19,7 +19,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var buffer = new SharedArrayBuffer(4); var buffer = new SharedArrayBuffer(4);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
TA(buffer); TA(buffer);

View File

@ -18,7 +18,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var buffer = new ArrayBuffer(4); var buffer = new ArrayBuffer(4);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
TA(buffer); TA(buffer);

View File

@ -19,7 +19,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var buffer = new SharedArrayBuffer(bpe); var buffer = new SharedArrayBuffer(bpe);

View File

@ -18,7 +18,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var buffer = new ArrayBuffer(bpe); var buffer = new ArrayBuffer(bpe);

View File

@ -27,7 +27,7 @@ var len = {
} }
}; };
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
new TA(buffer, 0, len); new TA(buffer, 0, len);
}); });

View File

@ -26,7 +26,7 @@ var len = {
} }
}; };
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
new TA(buffer, 0, len); new TA(buffer, 0, len);
}); });

View File

@ -23,7 +23,7 @@ features: [BigInt, Symbol, SharedArrayBuffer, TypedArray]
var buffer = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
var s = Symbol("1"); var s = Symbol("1");
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
new TA(buffer, 0, s); new TA(buffer, 0, s);
}); });

View File

@ -22,7 +22,7 @@ features: [BigInt, Symbol, TypedArray]
var buffer = new ArrayBuffer(8); var buffer = new ArrayBuffer(8);
var s = Symbol("1"); var s = Symbol("1");
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
new TA(buffer, 0, s); new TA(buffer, 0, s);
}); });

View File

@ -13,7 +13,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var offset = TA.BYTES_PER_ELEMENT; var offset = TA.BYTES_PER_ELEMENT;
var buffer = new ArrayBuffer(3 * offset); var buffer = new ArrayBuffer(3 * offset);
var length = { valueOf() { $DETACHBUFFER(buffer); return 1; } }; var length = { valueOf() { $DETACHBUFFER(buffer); return 1; } };

View File

@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var buffer = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
var sample = new TA(buffer); var sample = new TA(buffer);

View File

@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var buffer = new ArrayBuffer(8); var buffer = new ArrayBuffer(8);
var sample = new TA(buffer); var sample = new TA(buffer);

View File

@ -31,7 +31,7 @@ var other = $262.createRealm().global;
var C = new other.Function(); var C = new other.Function();
C.prototype = null; C.prototype = null;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [new SharedArrayBuffer(8)], C); var ta = Reflect.construct(TA, [new SharedArrayBuffer(8)], C);
assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);

View File

@ -30,7 +30,7 @@ var other = $262.createRealm().global;
var C = new other.Function(); var C = new other.Function();
C.prototype = null; C.prototype = null;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [new ArrayBuffer(8)], C); var ta = Reflect.construct(TA, [new ArrayBuffer(8)], C);
assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);

View File

@ -15,7 +15,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var buffer1 = new SharedArrayBuffer(bpe * 4); var buffer1 = new SharedArrayBuffer(bpe * 4);

View File

@ -14,7 +14,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var bpe = TA.BYTES_PER_ELEMENT; var bpe = TA.BYTES_PER_ELEMENT;
var buffer1 = new ArrayBuffer(bpe * 4); var buffer1 = new ArrayBuffer(bpe * 4);

View File

@ -55,7 +55,7 @@ var items = [
[-0.99999, 0, "-0.99999"] [-0.99999, 0, "-0.99999"]
]; ];
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
items.forEach(function(item) { items.forEach(function(item) {
var len = item[0]; var len = item[0];
var expected = item[1]; var expected = item[1];

View File

@ -54,7 +54,7 @@ var items = [
[-0.99999, 0, "-0.99999"] [-0.99999, 0, "-0.99999"]
]; ];
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
items.forEach(function(item) { items.forEach(function(item) {
var len = item[0]; var len = item[0];
var expected = item[1]; var expected = item[1];

View File

@ -53,7 +53,7 @@ var items = [
[-0.99999, 0, "-0.99999"] [-0.99999, 0, "-0.99999"]
]; ];
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
items.forEach(function(item) { items.forEach(function(item) {
var offset = item[0]; var offset = item[0];
var expected = item[1]; var expected = item[1];

View File

@ -52,7 +52,7 @@ var items = [
[-0.99999, 0, "-0.99999"] [-0.99999, 0, "-0.99999"]
]; ];
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
items.forEach(function(item) { items.forEach(function(item) {
var offset = item[0]; var offset = item[0];
var expected = item[1]; var expected = item[1];

View File

@ -10,14 +10,16 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, SharedArrayBuffer, TypedArray] features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(4); var sab = new SharedArrayBuffer(8);
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
testWithTypedArrayConstructors(function(View1) { testWithBigIntTypedArrayConstructors(function(View1) {
var ta1 = new View1(sab); var ta1 = new View1(sab);
testWithTypedArrayConstructors(function(View2) { testWithBigIntTypedArrayConstructors(function(View2) {
var ta2 = new View2(ta1); var ta2 = new View2(ta1);
assert.sameValue(ta2.buffer.constructor, ArrayBuffer, assert.sameValue(
"TypedArray of SharedArrayBuffer-backed TypedArray is ArrayBuffer-backed"); ta2.buffer.constructor,
}, int_views); ArrayBuffer,
}, int_views); "TypedArray of SharedArrayBuffer-backed TypedArray is ArrayBuffer-backed"
);
});
});

View File

@ -41,7 +41,7 @@ function newTarget() {}
var proto = {}; var proto = {};
newTarget.prototype = proto; newTarget.prototype = proto;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [buffer], newTarget); var ta = Reflect.construct(TA, [buffer], newTarget);
assert.sameValue(ta.constructor, Object); assert.sameValue(ta.constructor, Object);

View File

@ -40,7 +40,7 @@ function newTarget() {}
var proto = {}; var proto = {};
newTarget.prototype = proto; newTarget.prototype = proto;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [buffer], newTarget); var ta = Reflect.construct(TA, [buffer], newTarget);
assert.sameValue(ta.constructor, Object); assert.sameValue(ta.constructor, Object);

View File

@ -40,7 +40,7 @@ var buffer = new SharedArrayBuffer(8);
function newTarget() {} function newTarget() {}
newTarget.prototype = null; newTarget.prototype = null;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [buffer], newTarget); var ta = Reflect.construct(TA, [buffer], newTarget);
assert.sameValue(ta.constructor, TA); assert.sameValue(ta.constructor, TA);

View File

@ -39,7 +39,7 @@ var buffer = new ArrayBuffer(8);
function newTarget() {} function newTarget() {}
newTarget.prototype = null; newTarget.prototype = null;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [buffer], newTarget); var ta = Reflect.construct(TA, [buffer], newTarget);
assert.sameValue(ta.constructor, TA); assert.sameValue(ta.constructor, TA);

View File

@ -36,7 +36,7 @@ Object.defineProperty(newTarget, "prototype", {
} }
}); });
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
Reflect.construct(TA, [1], newTarget); Reflect.construct(TA, [1], newTarget);
}); });

View File

@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var subject = new TA(9); var subject = new TA(9);
assert.sameValue(subject[0], 0n, 'index 0'); assert.sameValue(subject[0], 0n, 'index 0');

View File

@ -20,7 +20,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(Infinity); new TA(Infinity);
}); });

View File

@ -26,7 +26,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(-1); new TA(-1);
}); });

View File

@ -19,7 +19,7 @@ features: [BigInt, Symbol, TypedArray]
var s = Symbol('1'); var s = Symbol('1');
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
new TA(s); new TA(s);
}); });

View File

@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(4); var sample = new TA(4);
assert(Object.isExtensible(sample)); assert(Object.isExtensible(sample));

View File

@ -29,7 +29,7 @@ var other = $262.createRealm().global;
var C = new other.Function(); var C = new other.Function();
C.prototype = null; C.prototype = null;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [0], C); var ta = Reflect.construct(TA, [0], C);
assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);

View File

@ -23,7 +23,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var typedArray = new TA(4); var typedArray = new TA(4);
var length = typedArray.length; var length = typedArray.length;

View File

@ -35,7 +35,7 @@ var items = [
[-0.99999, 0, "-0.99999"] [-0.99999, 0, "-0.99999"]
]; ];
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
items.forEach(function(item) { items.forEach(function(item) {
var len = item[0]; var len = item[0];
var expected = item[1]; var expected = item[1];

View File

@ -17,7 +17,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
TA(0); TA(0);
}); });

View File

@ -36,7 +36,7 @@ function newTarget() {}
var proto = {}; var proto = {};
newTarget.prototype = proto; newTarget.prototype = proto;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [1], newTarget); var ta = Reflect.construct(TA, [1], newTarget);
assert.sameValue(ta.constructor, Object); assert.sameValue(ta.constructor, Object);

View File

@ -35,7 +35,7 @@ features: [BigInt, TypedArray]
function newTarget() {} function newTarget() {}
newTarget.prototype = null; newTarget.prototype = null;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [1], newTarget); var ta = Reflect.construct(TA, [1], newTarget);
assert.sameValue(ta.constructor, TA); assert.sameValue(ta.constructor, TA);

View File

@ -36,7 +36,7 @@ Object.defineProperty(newTarget, "prototype", {
} }
}); });
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
Reflect.construct(TA, [], newTarget); Reflect.construct(TA, [], newTarget);
}); });

View File

@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(); var sample = new TA();
assert(Object.isExtensible(sample)); assert(Object.isExtensible(sample));

View File

@ -29,7 +29,7 @@ var other = $262.createRealm().global;
var C = new other.Function(); var C = new other.Function();
C.prototype = null; C.prototype = null;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [], C); var ta = Reflect.construct(TA, [], C);
assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);

View File

@ -23,7 +23,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var typedArray = new TA(); var typedArray = new TA();
assert.sameValue(typedArray.length, 0); assert.sameValue(typedArray.length, 0);

View File

@ -16,7 +16,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
TA(); TA();
}); });

View File

@ -36,7 +36,7 @@ function newTarget() {}
var proto = {}; var proto = {};
newTarget.prototype = proto; newTarget.prototype = proto;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [], newTarget); var ta = Reflect.construct(TA, [], newTarget);
assert.sameValue(ta.constructor, Object); assert.sameValue(ta.constructor, Object);

View File

@ -35,7 +35,7 @@ features: [BigInt, TypedArray]
function newTarget() {} function newTarget() {}
newTarget.prototype = null; newTarget.prototype = null;
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var ta = Reflect.construct(TA, [], newTarget); var ta = Reflect.construct(TA, [], newTarget);
assert.sameValue(ta.constructor, TA); assert.sameValue(ta.constructor, TA);

View File

@ -16,7 +16,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var typedArray = new TA([7n, 42n]); var typedArray = new TA([7n, 42n]);
assert.sameValue(typedArray.length, 2); assert.sameValue(typedArray.length, 2);
assert.sameValue(typedArray[0], 7n); assert.sameValue(typedArray[0], 7n);

View File

@ -16,7 +16,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var obj = (function *() { var obj = (function *() {
yield 7n; yield 42n; yield 7n; yield 42n;
})(); })();

View File

@ -1,61 +0,0 @@
// 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-object
description: Consistent canonicalization of NaN values
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.
...
9. Repeat, while k < len
...
c. Perform ? Set(O, Pk, kValue, true).
...
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
...
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
...
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
isLittleEndian ] )
...
8. If type is "Float32", then
a. Set rawBytes to a List containing the 4 bytes that are the result
of converting value to IEEE 754-2008 binary32 format using Round to
nearest, ties to even rounding mode. If isLittleEndian is false, the
bytes are arranged in big endian order. Otherwise, the bytes are
arranged in little endian order. If value is NaN, rawValue may be set
to any implementation chosen IEEE 754-2008 binary64 format Not-a-Number
encoding. An implementation must always choose the same encoding for
each implementation distinguishable NaN value.
9. Else, if type is "Float64", then
a. Set rawBytes to a List containing the 8 bytes that are the IEEE
754-2008 binary64 format encoding of value. If isLittleEndian is false,
the bytes are arranged in big endian order. Otherwise, the bytes are
arranged in little endian order. If value is NaN, rawValue may be set
to any implementation chosen IEEE 754-2008 binary32 format Not-a-Number
encoding. An implementation must always choose the same encoding for
each implementation distinguishable NaN value.
...
includes: [nans.js, testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray]
---*/
function body(FloatArray) {
var first = new FloatArray(distinctNaNs);
var second = new FloatArray(distinctNaNs);
var firstBytes = new Uint8Array(first.buffer);
var secondBytes = new Uint8Array(second.buffer);
assert(compareArray(firstBytes, secondBytes));
}
testWithTypedArrayConstructors(body, [Float32Array, Float64Array]);

View File

@ -1,53 +0,0 @@
// 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-object
description: >
Verify conversion values on returned instance
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.
...
9. Repeat, while k < len
...
c. Perform ? Set(O, Pk, kValue, true).
...
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
...
15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
...
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
isLittleEndian ] )
...
8. If type is "Float32", then
...
9. Else, if type is "Float64", then
...
10. Else,
...
b. Let convOp be the abstract operation named in the Conversion Operation
column in Table 50 for Element Type type.
c. Let intValue be convOp(value).
d. If intValue 0, then
...
e. Else,
...
includes: [byteConversionValues.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testTypedArrayConversions(byteConversionValues, function(TA, value, expected) {
var sample = new TA([value]);
assert.sameValue(sample[0], expected, value + " converts to " + expected);
});

View File

@ -41,7 +41,7 @@ Object.defineProperty(newTarget, "prototype", {
var o = {}; var o = {};
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
Reflect.construct(TA, [o], newTarget); Reflect.construct(TA, [o], newTarget);
}); });

View File

@ -19,7 +19,7 @@ includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var obj = (function *() { var obj = (function *() {
yield 0; yield 0;
throw new Test262Error(); throw new Test262Error();

View File

@ -21,7 +21,7 @@ features: [BigInt, Symbol.iterator, TypedArray]
var obj = function () {}; var obj = function () {};
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
obj[Symbol.iterator] = {}; obj[Symbol.iterator] = {};
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
new TA(obj); new TA(obj);

View File

@ -27,7 +27,7 @@ Object.defineProperty(obj, Symbol.iterator, {
} }
}); });
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
new TA(obj); new TA(obj);
}); });

View File

@ -23,7 +23,7 @@ var obj = {
length: Math.pow(2, 53) length: Math.pow(2, 53)
}; };
testWithTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(obj); new TA(obj);
}); });

Some files were not shown because too many files have changed in this diff Show More