add Float16Array to all generic TypedArray tests (#3849)

This commit is contained in:
Kevin Gibbons 2024-01-10 05:07:57 -08:00 committed by GitHub
parent 211195bb08
commit 67a5153cf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 177 additions and 262 deletions

View File

@ -4,22 +4,23 @@
description: | description: |
Collection of functions used to assert the correctness of TypedArray objects. Collection of functions used to assert the correctness of TypedArray objects.
defines: defines:
- typedArrayConstructors
- floatArrayConstructors - floatArrayConstructors
- intArrayConstructors - intArrayConstructors
- typedArrayConstructors
- TypedArray - TypedArray
- testWithTypedArrayConstructors - testWithTypedArrayConstructors
- nonAtomicsFriendlyTypedArrayConstructors
- testWithAtomicsFriendlyTypedArrayConstructors - testWithAtomicsFriendlyTypedArrayConstructors
- testWithNonAtomicsFriendlyTypedArrayConstructors - testWithNonAtomicsFriendlyTypedArrayConstructors
- testTypedArrayConversions - testTypedArrayConversions
---*/ ---*/
/** var floatArrayConstructors = [
* Array containing every typed array constructor.
*/
var typedArrayConstructors = [
Float64Array, Float64Array,
Float32Array, Float32Array
];
var intArrayConstructors = [
Int32Array, Int32Array,
Int16Array, Int16Array,
Int8Array, Int8Array,
@ -29,8 +30,17 @@ var typedArrayConstructors = [
Uint8ClampedArray Uint8ClampedArray
]; ];
var floatArrayConstructors = typedArrayConstructors.slice(0, 2); // Float16Array is a newer feature
var intArrayConstructors = typedArrayConstructors.slice(2, 7); // adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it
if (typeof Float16Array !== 'undefined') {
floatArrayConstructors.push(Float16Array);
}
/**
* Array containing every non-bigint typed array constructor.
*/
var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors);
/** /**
* The %TypedArray% intrinsic constructor function. * The %TypedArray% intrinsic constructor function.
@ -63,6 +73,7 @@ function testWithTypedArrayConstructors(f, selected) {
} }
} }
var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]);
/** /**
* Calls the provided function for every non-"Atomics Friendly" typed array constructor. * Calls the provided function for every non-"Atomics Friendly" typed array constructor.
* *
@ -70,11 +81,7 @@ function testWithTypedArrayConstructors(f, selected) {
* @param {Array} selected - An optional Array with filtered typed arrays * @param {Array} selected - An optional Array with filtered typed arrays
*/ */
function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { function testWithNonAtomicsFriendlyTypedArrayConstructors(f) {
testWithTypedArrayConstructors(f, [ testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors);
Float64Array,
Float32Array,
Uint8ClampedArray
]);
} }
/** /**
@ -120,3 +127,31 @@ function testTypedArrayConversions(byteConversionValues, fn) {
}); });
}); });
} }
/**
* Checks if the given argument is one of the float-based TypedArray constructors.
*
* @param {constructor} ctor - the value to check
* @returns {boolean}
*/
function isFloatTypedArrayConstructor(arg) {
return floatArrayConstructors.indexOf(arg) !== -1;
}
/**
* Determines the precision of the given float-based TypedArray constructor.
*
* @param {constructor} ctor - the value to check
* @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively.
*/
function floatTypedArrayConstructorPrecision(FA) {
if (typeof Float16Array !== "undefined" && FA === Float16Array) {
return "half";
} else if (FA === Float32Array) {
return "single";
} else if (FA === Float64Array) {
return "double";
} else {
throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray");
}
}

View File

@ -37,6 +37,7 @@ function concatTypedArray(type, elems, modulo) {
assert.compareArray([].concat(ta), expected); assert.compareArray([].concat(ta), expected);
} }
// Float16Array cannot be included in this because it cannot precisely represent integers above 2048
var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false]; var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false];
[ [
Uint8Array, Uint8Array,

View File

@ -37,12 +37,18 @@ function concatTypedArray(type, elems, modulo) {
assert.compareArray([].concat(ta), expected); assert.compareArray([].concat(ta), expected);
} }
var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false]; var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false];
[ var TAs = [
Uint8Array, Uint8Array,
Uint16Array, Uint16Array,
Uint32Array, Uint32Array,
Float32Array, Float32Array,
Float64Array Float64Array
].forEach(function(ctor, i) { ];
if (typeof Float16Array !== 'undefined') {
max.push(false);
TAs.push(Float16Array);
}
TAs.forEach(function(ctor, i) {
concatTypedArray(ctor, 1, max[i]); concatTypedArray(ctor, 1, max[i]);
}); });

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var index = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.add(typedArray, index, 0); Atomics.add(typedArray, index, 0);

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var value = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.add(typedArray, 0, value); Atomics.add(typedArray, 0, value);

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var index = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.and(typedArray, index, 0); Atomics.and(typedArray, index, 0);

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var value = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.and(typedArray, 0, value); Atomics.and(typedArray, 0, value);

View File

@ -19,6 +19,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -28,11 +29,7 @@ var expectedValue = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.compareExchange(typedArray, 0, expectedValue, 0); Atomics.compareExchange(typedArray, 0, expectedValue, 0);

View File

@ -19,6 +19,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -28,11 +29,7 @@ var index = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.compareExchange(typedArray, index, 0, 0); Atomics.compareExchange(typedArray, index, 0, 0);

View File

@ -19,6 +19,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -28,11 +29,7 @@ var replacementValue = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.compareExchange(typedArray, 0, 0, replacementValue); Atomics.compareExchange(typedArray, 0, 0, replacementValue);

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var index = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.exchange(typedArray, index, 0); Atomics.exchange(typedArray, index, 0);

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var value = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.exchange(typedArray, 0, value); Atomics.exchange(typedArray, 0, value);

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var index = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.load(typedArray, index); Atomics.load(typedArray, index);

View File

@ -35,6 +35,15 @@ assert.throws(TypeError, function() {
Atomics.notify(view, poisoned, poisoned); Atomics.notify(view, poisoned, poisoned);
}, '`const view = new Float32Array( new SharedArrayBuffer(Float32Array.BYTES_PER_ELEMENT * 4) ); Atomics.notify(view, poisoned, poisoned)` throws TypeError'); }, '`const view = new Float32Array( new SharedArrayBuffer(Float32Array.BYTES_PER_ELEMENT * 4) ); Atomics.notify(view, poisoned, poisoned)` throws TypeError');
if (typeof Float16Array !== 'undefined') {
assert.throws(TypeError, function() {
const view = new Float16Array(
new SharedArrayBuffer(Float16Array.BYTES_PER_ELEMENT * 2)
);
Atomics.notify(view, poisoned, poisoned);
}, '`const view = new Float16Array( new SharedArrayBuffer(Float16Array.BYTES_PER_ELEMENT * 2) ); Atomics.notify(view, poisoned, poisoned)` throws TypeError');
}
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
const view = new Int16Array( const view = new Int16Array(
new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2) new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2)

View File

@ -19,6 +19,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -28,10 +29,7 @@ var count = {
} }
}; };
var badArrayTypes = [ var badArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; });
Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) { for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));

View File

@ -19,6 +19,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -28,10 +29,7 @@ var index = {
} }
}; };
var badArrayTypes = [ var badArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; });
Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) { for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var index = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.or(typedArray, index, 0); Atomics.or(typedArray, index, 0);

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var value = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.or(typedArray, 0, value); Atomics.or(typedArray, 0, value);

View File

@ -19,6 +19,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -28,11 +29,7 @@ var index = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.store(typedArray, index, 0); Atomics.store(typedArray, index, 0);

View File

@ -19,6 +19,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -28,11 +29,7 @@ var value = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.store(typedArray, 0, value); Atomics.store(typedArray, 0, value);

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var index = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.sub(typedArray, index, 0); Atomics.sub(typedArray, index, 0);

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var value = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.sub(typedArray, 0, value); Atomics.sub(typedArray, 0, value);

View File

@ -35,6 +35,15 @@ assert.throws(TypeError, function() {
Atomics.wait(view, poisoned, poisoned, poisoned); Atomics.wait(view, poisoned, poisoned, poisoned);
}, '`const view = new Float32Array( new SharedArrayBuffer(Float32Array.BYTES_PER_ELEMENT * 4) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError'); }, '`const view = new Float32Array( new SharedArrayBuffer(Float32Array.BYTES_PER_ELEMENT * 4) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError');
if (typeof Float16Array !== 'undefined') {
assert.throws(TypeError, function() {
const view = new Float16Array(
new SharedArrayBuffer(Float16Array.BYTES_PER_ELEMENT * 2)
);
Atomics.wait(view, poisoned, poisoned, poisoned);
}, '`const view = new Float16Array( new SharedArrayBuffer(Float16Array.BYTES_PER_ELEMENT * 2) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError');
}
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
const view = new Int16Array( const view = new Int16Array(
new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2) new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2)

View File

@ -19,6 +19,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -28,10 +29,7 @@ var index = {
} }
}; };
var badArrayTypes = [ var badArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; });
Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) { for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));

View File

@ -19,6 +19,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -28,10 +29,7 @@ var timeout = {
} }
}; };
var badArrayTypes = [ var badArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; });
Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) { for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));

View File

@ -19,6 +19,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -28,10 +29,7 @@ var value = {
} }
}; };
var badArrayTypes = [ var badArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; });
Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) { for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));

View File

@ -42,6 +42,15 @@ assert.throws(TypeError, () => {
Atomics.waitAsync(view, poisoned, poisoned, poisoned); Atomics.waitAsync(view, poisoned, poisoned, poisoned);
}, '`const view = new Float32Array( new SharedArrayBuffer(Float32Array.BYTES_PER_ELEMENT * 4) ); Atomics.waitAsync(view, poisoned, poisoned, poisoned)` throws a TypeError exception'); }, '`const view = new Float32Array( new SharedArrayBuffer(Float32Array.BYTES_PER_ELEMENT * 4) ); Atomics.waitAsync(view, poisoned, poisoned, poisoned)` throws a TypeError exception');
if (typeof Float16Array !== 'undefined') {
assert.throws(TypeError, function() {
const view = new Float16Array(
new SharedArrayBuffer(Float16Array.BYTES_PER_ELEMENT * 2)
);
Atomics.waitAsync(view, poisoned, poisoned, poisoned);
}, '`const view = new Float16Array( new SharedArrayBuffer(Float16Array.BYTES_PER_ELEMENT * 2) ); Atomics.waitAsync(view, poisoned, poisoned, poisoned)` throws a TypeError exception');
}
assert.throws(TypeError, () => { assert.throws(TypeError, () => {
const view = new Int16Array( const view = new Int16Array(
new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2) new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2)

View File

@ -27,6 +27,7 @@ info: |
9. If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception. 9. If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
10. Return buffer. 10. Return buffer.
includes: [testTypedArray.js]
features: [Atomics.waitAsync, Atomics, TypedArray, SharedArrayBuffer] features: [Atomics.waitAsync, Atomics, TypedArray, SharedArrayBuffer]
---*/ ---*/
assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"'); assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
@ -37,10 +38,7 @@ const index = {
} }
}; };
const nonSharedArrayTypes = [ var nonSharedArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; });
Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
Uint8ClampedArray, Float32Array, Float64Array
];
for (const nonSharedArrayType of nonSharedArrayTypes) { for (const nonSharedArrayType of nonSharedArrayTypes) {
const typedArray = new nonSharedArrayType(new SharedArrayBuffer(8)); const typedArray = new nonSharedArrayType(new SharedArrayBuffer(8));

View File

@ -27,6 +27,7 @@ info: |
9. If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception. 9. If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
10. Return buffer. 10. Return buffer.
includes: [testTypedArray.js]
features: [Atomics.waitAsync, Atomics, TypedArray, SharedArrayBuffer] features: [Atomics.waitAsync, Atomics, TypedArray, SharedArrayBuffer]
---*/ ---*/
assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"'); assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
@ -37,10 +38,7 @@ const value = {
} }
}; };
const nonSharedArrayTypes = [ var nonSharedArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; });
Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
Uint8ClampedArray, Float32Array, Float64Array
];
for (const nonSharedArrayType of nonSharedArrayTypes) { for (const nonSharedArrayType of nonSharedArrayTypes) {
const typedArray = new nonSharedArrayType(new SharedArrayBuffer(8)); const typedArray = new nonSharedArrayType(new SharedArrayBuffer(8));

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var index = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.xor(typedArray, index, 0); Atomics.xor(typedArray, index, 0);

View File

@ -22,6 +22,7 @@ info: |
a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array",
or "Uint32Array", throw a TypeError exception. or "Uint32Array", throw a TypeError exception.
... ...
includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, TypedArray]
---*/ ---*/
@ -31,11 +32,7 @@ var value = {
} }
}; };
var badArrayTypes = [ for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) {
Uint8ClampedArray, Float32Array, Float64Array
];
for (var badArrayType of badArrayTypes) {
var typedArray = new badArrayType(new SharedArrayBuffer(8)); var typedArray = new badArrayType(new SharedArrayBuffer(8));
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.xor(typedArray, 0, value); Atomics.xor(typedArray, 0, value);

View File

@ -61,6 +61,7 @@ let properties = [
'Error', 'Error',
'EvalError', 'EvalError',
'FinalizationRegistry', 'FinalizationRegistry',
'Float16Array',
'Float32Array', 'Float32Array',
'Float64Array', 'Float64Array',
'Function', 'Function',

View File

@ -41,4 +41,4 @@ function body(FloatArray) {
assert(compareArray(originalBytes, copiedBytes)); assert(compareArray(originalBytes, copiedBytes));
} }
testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); testWithTypedArrayConstructors(body, floatArrayConstructors);

View File

@ -73,7 +73,7 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(FA) { testWithTypedArrayConstructors(function(FA) {
var precision = FA === Float32Array ? "single" : "double"; var precision = floatTypedArrayConstructorPrecision(FA);
var samples = new FA(3); var samples = new FA(3);
var controls, idx, aNaN; var controls, idx, aNaN;
@ -98,4 +98,4 @@ testWithTypedArrayConstructors(function(FA) {
); );
} }
} }
}, [Float32Array, Float64Array]); }, floatArrayConstructors);

View File

@ -15,7 +15,7 @@ assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var BPE = TA.BYTES_PER_ELEMENT; var BPE = TA.BYTES_PER_ELEMENT;
var NaNvalue = (TA === Float32Array || TA === Float64Array) ? NaN : 0; var NaNvalue = isFloatTypedArrayConstructor(TA) ? NaN : 0;
var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
var sample = new TA(buffer); var sample = new TA(buffer);
var finalElement, finalResult, expectedElements, expectedIndices, expectedArrays; var finalElement, finalResult, expectedElements, expectedIndices, expectedArrays;

View File

@ -41,4 +41,4 @@ testWithTypedArrayConstructors(function(TA) {
testWithTypedArrayConstructors(function(FloatArray) { testWithTypedArrayConstructors(function(FloatArray) {
var sample = new FloatArray([42, 0, 1, undefined, NaN]); var sample = new FloatArray([42, 0, 1, undefined, NaN]);
assert.sameValue(sample.includes(NaN), true, "NaN"); assert.sameValue(sample.includes(NaN), true, "NaN");
}, [Float32Array, Float64Array]); }, floatArrayConstructors);

View File

@ -15,7 +15,7 @@ assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var BPE = TA.BYTES_PER_ELEMENT; var BPE = TA.BYTES_PER_ELEMENT;
var NaNvalue = (TA === Float32Array || TA === Float64Array) ? NaN : 0; var NaNvalue = isFloatTypedArrayConstructor(TA) ? NaN : 0;
var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
var sample = new TA(buffer); var sample = new TA(buffer);
var finalElement, expectedElements, expectedIndices, expectedArrays; var finalElement, expectedElements, expectedIndices, expectedArrays;

View File

@ -68,4 +68,4 @@ function body(FloatArray) {
assert(compareArray(sampleBytes, resultBytes)); assert(compareArray(sampleBytes, resultBytes));
} }
testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); testWithTypedArrayConstructors(body, floatArrayConstructors);

View File

@ -32,4 +32,4 @@ function body(FA) {
assert(compareArray(sourceBytes, targetBytes)) assert(compareArray(sourceBytes, targetBytes))
} }
testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); testWithTypedArrayConstructors(body, floatArrayConstructors);

View File

@ -11,7 +11,7 @@ features: [SharedArrayBuffer]
---*/ ---*/
testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
if (TA === Float64Array || TA === Float32Array || TA === Uint8ClampedArray) { if (TA === Float64Array || TA === Float32Array || (typeof Float16Array !== 'undefined' && TA === Float16Array) || TA === Uint8ClampedArray) {
return; return;
} }
if (TA === Int32Array) { if (TA === Int32Array) {

View File

@ -34,6 +34,7 @@ features: [TypedArray]
var expected = { var expected = {
Float64Array: [1.0000002464512363, 42, 1.875, 4, 5, 6, 7, 8], Float64Array: [1.0000002464512363, 42, 1.875, 4, 5, 6, 7, 8],
Float32Array: [0, 42, 512.0001220703125, 4, 5, 6, 7, 8], Float32Array: [0, 42, 512.0001220703125, 4, 5, 6, 7, 8],
Float16Array: [0, 42, 513, 4, 5, 6, 7, 8],
Int32Array: [1109917696, 42, 0, 4, 5, 6, 7, 8], Int32Array: [1109917696, 42, 0, 4, 5, 6, 7, 8],
Int16Array: [0, 42, 0, 4, 5, 6, 7, 8], Int16Array: [0, 42, 0, 4, 5, 6, 7, 8],
Int8Array: [0, 42, 0, 66, 5, 6, 7, 8], Int8Array: [0, 42, 0, 66, 5, 6, 7, 8],

View File

@ -36,4 +36,4 @@ function body(FloatArray) {
assert(compareArray(subjectBytes, slicedBytes)); assert(compareArray(subjectBytes, slicedBytes));
} }
testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); testWithTypedArrayConstructors(body, floatArrayConstructors);

View File

@ -35,4 +35,4 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(sample[4], Infinity, "#2 [4]"); assert.sameValue(sample[4], Infinity, "#2 [4]");
assert.sameValue(sample[5], NaN, "#2 [5]"); assert.sameValue(sample[5], NaN, "#2 [5]");
assert.sameValue(sample[6], NaN, "#2 [6]"); assert.sameValue(sample[6], NaN, "#2 [6]");
}, [Float64Array, Float32Array]); }, floatArrayConstructors);

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(function(TA) {
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = new TA([-4, 3, 4, -3, 2, -2, 1, 0]).sort(); var sample = new TA([-4, 3, 4, -3, 2, -2, 1, 0]).sort();
assert(compareArray(sample, [-4, -3, -2, 0, 1, 2, 3, 4]), "negative values"); assert(compareArray(sample, [-4, -3, -2, 0, 1, 2, 3, 4]), "negative values");
}, [Float64Array, Float32Array, Int8Array, Int16Array, Int32Array]); }, floatArrayConstructors.concat([Int8Array, Int16Array, Int32Array]));
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample; var sample;
@ -54,4 +54,4 @@ testWithTypedArrayConstructors(function(TA) {
sample = new TA([3, 4, Infinity, -Infinity, 1, 2]).sort(); sample = new TA([3, 4, Infinity, -Infinity, 1, 2]).sort();
assert(compareArray(sample, [-Infinity, 1, 2, 3, 4, Infinity]), "infinities"); assert(compareArray(sample, [-Infinity, 1, 2, 3, 4, Infinity]), "infinities");
}, [Float64Array, Float32Array]); }, floatArrayConstructors);

View File

@ -35,4 +35,4 @@ testWithTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(buffer, 0, undefined); new TA(buffer, 0, undefined);
}); });
}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); }, floatArrayConstructors.concat([ Int32Array, Int16Array, Uint32Array, Uint16Array ]));

View File

@ -29,4 +29,4 @@ testWithTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(buffer, 0, undefined); new TA(buffer, 0, undefined);
}); });
}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); }, floatArrayConstructors.concat([ Int32Array, Int16Array, Uint32Array, Uint16Array ]));

View File

@ -31,5 +31,5 @@ testWithTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(buffer, 7); new TA(buffer, 7);
}); });
}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); }, floatArrayConstructors.concat([ Int32Array, Int16Array, Uint32Array, Uint16Array ]));

View File

@ -24,4 +24,4 @@ testWithTypedArrayConstructors(function(TA) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {
new TA(buffer, 7); new TA(buffer, 7);
}); });
}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); }, floatArrayConstructors.concat([ Int32Array, Int16Array, Uint32Array, Uint16Array ]));

View File

@ -67,4 +67,4 @@ function body(FloatArray) {
assert(compareArray(firstBytes, secondBytes)); assert(compareArray(firstBytes, secondBytes));
} }
testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); testWithTypedArrayConstructors(body, floatArrayConstructors);

View File

@ -35,7 +35,7 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(typedArray.constructor, TA); assert.sameValue(typedArray.constructor, TA);
assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
if (TA === Float32Array || TA === Float64Array) { if (isFloatTypedArrayConstructor(TA)) {
assert.sameValue(typedArray[1], NaN); assert.sameValue(typedArray[1], NaN);
assert.sameValue(typedArray[4], NaN); assert.sameValue(typedArray[4], NaN);
} else { } else {

View File

@ -33,10 +33,7 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ floatArrayConstructors);
Float32Array,
Float64Array
]);
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var result = TA.from([NaN, undefined]); var result = TA.from([NaN, undefined]);
@ -46,13 +43,4 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ intArrayConstructors);
Int8Array,
Int32Array,
Int16Array,
Int8Array,
Uint32Array,
Uint16Array,
Uint8Array,
Uint8ClampedArray
]);

View File

@ -25,10 +25,7 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ floatArrayConstructors);
Float32Array,
Float64Array
]);
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var result = TA.from(source); var result = TA.from(source);
@ -41,13 +38,4 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ intArrayConstructors);
Int8Array,
Int32Array,
Int16Array,
Int8Array,
Uint32Array,
Uint16Array,
Uint8Array,
Uint8ClampedArray
]);

View File

@ -23,10 +23,7 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ floatArrayConstructors);
Float32Array,
Float64Array
]);
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var result = TA.from(source); var result = TA.from(source);
@ -41,13 +38,4 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ intArrayConstructors);
Int8Array,
Int32Array,
Int16Array,
Int8Array,
Uint32Array,
Uint16Array,
Uint8Array,
Uint8ClampedArray
]);

View File

@ -16,10 +16,7 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ floatArrayConstructors);
Float32Array,
Float64Array
]);
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var result = TA.from([-0, +0]); var result = TA.from([-0, +0]);
@ -29,12 +26,4 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ intArrayConstructors);
Int16Array,
Int32Array,
Int8Array,
Uint16Array,
Uint32Array,
Uint8Array,
Uint8ClampedArray
]);

View File

@ -69,7 +69,7 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(FA) { testWithTypedArrayConstructors(function(FA) {
var precision = FA === Float32Array ? "single" : "double"; var precision = floatTypedArrayConstructorPrecision(FA);
var samples = new FA(1); var samples = new FA(1);
var controls, idx, aNaN; var controls, idx, aNaN;
@ -94,5 +94,5 @@ testWithTypedArrayConstructors(function(FA) {
); );
} }
} }
}, [Float32Array, Float64Array]); }, floatArrayConstructors);

View File

@ -76,7 +76,7 @@ features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(FA) { testWithTypedArrayConstructors(function(FA) {
var precision = FA === Float32Array ? "single" : "double"; var precision = floatTypedArrayConstructorPrecision(FA);
var samples = new FA(1); var samples = new FA(1);
var controls, idx, aNaN; var controls, idx, aNaN;
@ -92,14 +92,14 @@ testWithTypedArrayConstructors(function(FA) {
assert( assert(
samples[i] !== samples[i], samples[i] !== samples[i],
'The result of `(samples[i] !== samples[i])` is true' `The result of \`(samples[i] !== samples[i])\` is true (${precision} precision)`
); );
assert( assert(
controls[i] !== controls[i], controls[i] !== controls[i],
'The result of `(controls[i] !== controls[i])` is true' `The result of \`(controls[i] !== controls[i])\` is true (${precision} precision)`
); );
} }
} }
}, [Float32Array, Float64Array]); }, floatArrayConstructors);

View File

@ -34,10 +34,7 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ floatArrayConstructors);
Float32Array,
Float64Array
]);
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var result = TA.of(NaN, undefined); var result = TA.of(NaN, undefined);
@ -47,13 +44,4 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ intArrayConstructors);
Int8Array,
Int32Array,
Int16Array,
Int8Array,
Uint32Array,
Uint16Array,
Uint8Array,
Uint8ClampedArray
]);

View File

@ -16,10 +16,7 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ floatArrayConstructors);
Float32Array,
Float64Array
]);
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var result = TA.of(-0, +0); var result = TA.of(-0, +0);
@ -29,12 +26,4 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(result.constructor, TA); assert.sameValue(result.constructor, TA);
assert.sameValue(Object.getPrototypeOf(result), TA.prototype); assert.sameValue(Object.getPrototypeOf(result), TA.prototype);
}, },
[ intArrayConstructors);
Int16Array,
Int32Array,
Int8Array,
Uint16Array,
Uint32Array,
Uint8Array,
Uint8ClampedArray
]);

View File

@ -14,20 +14,11 @@ info: |
call to the TypedArray constructor to create and initialize the subclass call to the TypedArray constructor to create and initialize the subclass
instance with the internal state necessary to support the instance with the internal state necessary to support the
%TypedArray%.prototype built-in methods. %TypedArray%.prototype built-in methods.
includes: [testTypedArray.js]
features: [TypedArray] features: [TypedArray]
---*/ ---*/
[ testWithTypedArrayConstructors(function(Constructor) {
Int8Array,
Uint8Array,
Uint8ClampedArray,
Int16Array,
Uint16Array,
Int32Array,
Uint32Array,
Float32Array,
Float64Array
].forEach(function(Constructor) {
class Typed extends Constructor {} class Typed extends Constructor {}
var arr = new Typed(2); var arr = new Typed(2);

View File

@ -14,20 +14,11 @@ info: |
call to the TypedArray constructor to create and initialize the subclass call to the TypedArray constructor to create and initialize the subclass
instance with the internal state necessary to support the instance with the internal state necessary to support the
%TypedArray%.prototype built-in methods. %TypedArray%.prototype built-in methods.
includes: [testTypedArray.js]
features: [TypedArray] features: [TypedArray]
---*/ ---*/
[ testWithTypedArrayConstructors(function(Constructor) {
Int8Array,
Uint8Array,
Uint8ClampedArray,
Int16Array,
Uint16Array,
Int32Array,
Uint32Array,
Float32Array,
Float64Array
].forEach(function(Constructor) {
class Typed extends Constructor { class Typed extends Constructor {
constructor() {} constructor() {}
} }