From bdca54a447626b4e1a37fa5e00284b16a68803d6 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Sun, 11 Jun 2023 15:04:24 -0700 Subject: [PATCH 1/5] add Float16Array to all generic TypedArray tests --- harness/testTypedArray.js | 33 +++++++++++-------- ...rray.prototype.concat_large-typed-array.js | 1 + ...rray.prototype.concat_small-typed-array.js | 10 ++++-- ...alidate-arraytype-before-index-coercion.js | 7 ++-- ...alidate-arraytype-before-value-coercion.js | 7 ++-- ...alidate-arraytype-before-index-coercion.js | 7 ++-- ...alidate-arraytype-before-value-coercion.js | 7 ++-- ...arraytype-before-expectedValue-coercion.js | 7 ++-- ...alidate-arraytype-before-index-coercion.js | 7 ++-- ...aytype-before-replacementValue-coercion.js | 7 ++-- ...alidate-arraytype-before-index-coercion.js | 7 ++-- ...alidate-arraytype-before-value-coercion.js | 7 ++-- ...alidate-arraytype-before-index-coercion.js | 7 ++-- .../notify/non-int32-typedarray-throws.js | 9 +++++ ...alidate-arraytype-before-count-coercion.js | 6 ++-- ...alidate-arraytype-before-index-coercion.js | 6 ++-- ...alidate-arraytype-before-index-coercion.js | 7 ++-- ...alidate-arraytype-before-value-coercion.js | 7 ++-- ...alidate-arraytype-before-index-coercion.js | 7 ++-- ...alidate-arraytype-before-value-coercion.js | 7 ++-- ...alidate-arraytype-before-index-coercion.js | 7 ++-- ...alidate-arraytype-before-value-coercion.js | 7 ++-- .../wait/non-int32-typedarray-throws.js | 9 +++++ ...alidate-arraytype-before-index-coercion.js | 6 ++-- ...idate-arraytype-before-timeout-coercion.js | 6 ++-- ...alidate-arraytype-before-value-coercion.js | 6 ++-- .../waitAsync/non-int32-typedarray-throws.js | 9 +++++ ...alidate-arraytype-before-index-coercion.js | 6 ++-- ...alidate-arraytype-before-value-coercion.js | 6 ++-- ...alidate-arraytype-before-index-coercion.js | 7 ++-- ...alidate-arraytype-before-value-coercion.js | 7 ++-- .../globalthis-available-properties.js | 1 + .../prototype/copyWithin/bit-precision.js | 2 +- ...es-conversion-operations-consistent-nan.js | 9 +++-- .../prototype/filter/callbackfn-resize.js | 2 +- .../prototype/includes/samevaluezero.js | 2 +- .../prototype/map/callbackfn-resize.js | 2 +- ...ray-conversion-operation-consistent-nan.js | 2 +- .../TypedArray/prototype/set/bit-precision.js | 2 +- ...-diff-buffer-other-type-conversions-sab.js | 2 +- ...y-arg-set-values-same-buffer-other-type.js | 5 +++ .../prototype/slice/bit-precision.js | 2 +- .../prototype/sort/sorted-values-nan.js | 2 +- .../prototype/sort/sorted-values.js | 4 +-- ...set-throws-from-modulo-element-size-sab.js | 2 +- ...eoffset-throws-from-modulo-element-size.js | 2 +- ...set-throws-from-modulo-element-size-sab.js | 2 +- ...eoffset-throws-from-modulo-element-size.js | 2 +- .../conversion-operation-consistent-nan.js | 2 +- .../ctors/object-arg/returns.js | 2 +- .../from/nan-conversion.js | 16 ++------- .../from/new-instance-from-ordinary-object.js | 16 ++------- .../from/new-instance-from-sparse-array.js | 16 ++------- .../from/new-instance-from-zero.js | 15 ++------- .../conversion-operation-consistent-nan.js | 9 +++-- .../conversion-operation-consistent-nan.js | 9 +++-- .../of/nan-conversion.js | 16 ++------- .../of/new-instance-from-zero.js | 15 ++------- .../TypedArray/regular-subclassing.js | 13 ++------ .../TypedArray/super-must-be-called.js | 13 ++------ 60 files changed, 166 insertions(+), 260 deletions(-) diff --git a/harness/testTypedArray.js b/harness/testTypedArray.js index 27ca2ceae97..efb21f317b9 100644 --- a/harness/testTypedArray.js +++ b/harness/testTypedArray.js @@ -4,22 +4,23 @@ description: | Collection of functions used to assert the correctness of TypedArray objects. defines: - - typedArrayConstructors - floatArrayConstructors - intArrayConstructors + - typedArrayConstructors - TypedArray - testWithTypedArrayConstructors + - nonAtomicsFriendlyTypedArrayConstructors - testWithAtomicsFriendlyTypedArrayConstructors - testWithNonAtomicsFriendlyTypedArrayConstructors - testTypedArrayConversions ---*/ -/** - * Array containing every typed array constructor. - */ -var typedArrayConstructors = [ +var floatArrayConstructors = [ Float64Array, - Float32Array, + Float32Array +]; + +var intArrayConstructors = [ Int32Array, Int16Array, Int8Array, @@ -29,8 +30,17 @@ var typedArrayConstructors = [ Uint8ClampedArray ]; -var floatArrayConstructors = typedArrayConstructors.slice(0, 2); -var intArrayConstructors = typedArrayConstructors.slice(2, 7); +// Float16Array is a newer feature +// 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. @@ -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. * @@ -70,11 +81,7 @@ function testWithTypedArrayConstructors(f, selected) { * @param {Array} selected - An optional Array with filtered typed arrays */ function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { - testWithTypedArrayConstructors(f, [ - Float64Array, - Float32Array, - Uint8ClampedArray - ]); + testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors); } /** diff --git a/test/built-ins/Array/prototype/concat/Array.prototype.concat_large-typed-array.js b/test/built-ins/Array/prototype/concat/Array.prototype.concat_large-typed-array.js index a7e0beca810..b3d02938386 100644 --- a/test/built-ins/Array/prototype/concat/Array.prototype.concat_large-typed-array.js +++ b/test/built-ins/Array/prototype/concat/Array.prototype.concat_large-typed-array.js @@ -37,6 +37,7 @@ function concatTypedArray(type, elems, modulo) { 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]; [ Uint8Array, diff --git a/test/built-ins/Array/prototype/concat/Array.prototype.concat_small-typed-array.js b/test/built-ins/Array/prototype/concat/Array.prototype.concat_small-typed-array.js index bca9ae16415..e4a32a3706c 100644 --- a/test/built-ins/Array/prototype/concat/Array.prototype.concat_small-typed-array.js +++ b/test/built-ins/Array/prototype/concat/Array.prototype.concat_small-typed-array.js @@ -37,12 +37,18 @@ function concatTypedArray(type, elems, modulo) { assert.compareArray([].concat(ta), expected); } var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false]; -[ +var TAs = [ Uint8Array, Uint16Array, Uint32Array, Float32Array, 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]); }); diff --git a/test/built-ins/Atomics/add/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/add/validate-arraytype-before-index-coercion.js index 17897da3e9c..2c38f448657 100644 --- a/test/built-ins/Atomics/add/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/add/validate-arraytype-before-index-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var index = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.add(typedArray, index, 0); diff --git a/test/built-ins/Atomics/add/validate-arraytype-before-value-coercion.js b/test/built-ins/Atomics/add/validate-arraytype-before-value-coercion.js index 2f16c5723e4..09b93d29636 100644 --- a/test/built-ins/Atomics/add/validate-arraytype-before-value-coercion.js +++ b/test/built-ins/Atomics/add/validate-arraytype-before-value-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var value = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.add(typedArray, 0, value); diff --git a/test/built-ins/Atomics/and/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/and/validate-arraytype-before-index-coercion.js index a1a30aacaa7..346070959a4 100644 --- a/test/built-ins/Atomics/and/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/and/validate-arraytype-before-index-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var index = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.and(typedArray, index, 0); diff --git a/test/built-ins/Atomics/and/validate-arraytype-before-value-coercion.js b/test/built-ins/Atomics/and/validate-arraytype-before-value-coercion.js index 44100eff337..961ad1fa3ad 100644 --- a/test/built-ins/Atomics/and/validate-arraytype-before-value-coercion.js +++ b/test/built-ins/Atomics/and/validate-arraytype-before-value-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var value = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.and(typedArray, 0, value); diff --git a/test/built-ins/Atomics/compareExchange/validate-arraytype-before-expectedValue-coercion.js b/test/built-ins/Atomics/compareExchange/validate-arraytype-before-expectedValue-coercion.js index 7a383e39cb9..319db4e2b31 100644 --- a/test/built-ins/Atomics/compareExchange/validate-arraytype-before-expectedValue-coercion.js +++ b/test/built-ins/Atomics/compareExchange/validate-arraytype-before-expectedValue-coercion.js @@ -19,6 +19,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -28,11 +29,7 @@ var expectedValue = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.compareExchange(typedArray, 0, expectedValue, 0); diff --git a/test/built-ins/Atomics/compareExchange/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/compareExchange/validate-arraytype-before-index-coercion.js index c573b5fff24..f73a105a94d 100644 --- a/test/built-ins/Atomics/compareExchange/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/compareExchange/validate-arraytype-before-index-coercion.js @@ -19,6 +19,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -28,11 +29,7 @@ var index = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.compareExchange(typedArray, index, 0, 0); diff --git a/test/built-ins/Atomics/compareExchange/validate-arraytype-before-replacementValue-coercion.js b/test/built-ins/Atomics/compareExchange/validate-arraytype-before-replacementValue-coercion.js index 561e44c2eda..2547bc85412 100644 --- a/test/built-ins/Atomics/compareExchange/validate-arraytype-before-replacementValue-coercion.js +++ b/test/built-ins/Atomics/compareExchange/validate-arraytype-before-replacementValue-coercion.js @@ -19,6 +19,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -28,11 +29,7 @@ var replacementValue = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.compareExchange(typedArray, 0, 0, replacementValue); diff --git a/test/built-ins/Atomics/exchange/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/exchange/validate-arraytype-before-index-coercion.js index fc0f77b0769..0f2320d5133 100644 --- a/test/built-ins/Atomics/exchange/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/exchange/validate-arraytype-before-index-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var index = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.exchange(typedArray, index, 0); diff --git a/test/built-ins/Atomics/exchange/validate-arraytype-before-value-coercion.js b/test/built-ins/Atomics/exchange/validate-arraytype-before-value-coercion.js index a43661679ea..32af772f443 100644 --- a/test/built-ins/Atomics/exchange/validate-arraytype-before-value-coercion.js +++ b/test/built-ins/Atomics/exchange/validate-arraytype-before-value-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var value = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.exchange(typedArray, 0, value); diff --git a/test/built-ins/Atomics/load/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/load/validate-arraytype-before-index-coercion.js index 4d8364161dd..3870c1d0b71 100644 --- a/test/built-ins/Atomics/load/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/load/validate-arraytype-before-index-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var index = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.load(typedArray, index); diff --git a/test/built-ins/Atomics/notify/non-int32-typedarray-throws.js b/test/built-ins/Atomics/notify/non-int32-typedarray-throws.js index 34b2abe662d..9d701c30d95 100644 --- a/test/built-ins/Atomics/notify/non-int32-typedarray-throws.js +++ b/test/built-ins/Atomics/notify/non-int32-typedarray-throws.js @@ -35,6 +35,15 @@ assert.throws(TypeError, function() { Atomics.notify(view, poisoned, poisoned); }, '`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() { const view = new Int16Array( new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2) diff --git a/test/built-ins/Atomics/notify/validate-arraytype-before-count-coercion.js b/test/built-ins/Atomics/notify/validate-arraytype-before-count-coercion.js index 7ddcc1bb365..a83a99ec817 100644 --- a/test/built-ins/Atomics/notify/validate-arraytype-before-count-coercion.js +++ b/test/built-ins/Atomics/notify/validate-arraytype-before-count-coercion.js @@ -19,6 +19,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -28,10 +29,7 @@ var count = { } }; -var badArrayTypes = [ - Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array, - Uint8ClampedArray, Float32Array, Float64Array -]; +var badArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; }); for (var badArrayType of badArrayTypes) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); diff --git a/test/built-ins/Atomics/notify/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/notify/validate-arraytype-before-index-coercion.js index 5330a843de6..2f0fcf4b683 100644 --- a/test/built-ins/Atomics/notify/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/notify/validate-arraytype-before-index-coercion.js @@ -19,6 +19,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -28,10 +29,7 @@ var index = { } }; -var badArrayTypes = [ - Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array, - Uint8ClampedArray, Float32Array, Float64Array -]; +var badArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; }); for (var badArrayType of badArrayTypes) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); diff --git a/test/built-ins/Atomics/or/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/or/validate-arraytype-before-index-coercion.js index 32ef88dfdcd..31425fa5afb 100644 --- a/test/built-ins/Atomics/or/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/or/validate-arraytype-before-index-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var index = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.or(typedArray, index, 0); diff --git a/test/built-ins/Atomics/or/validate-arraytype-before-value-coercion.js b/test/built-ins/Atomics/or/validate-arraytype-before-value-coercion.js index 27fd0d828b9..4702e92a57b 100644 --- a/test/built-ins/Atomics/or/validate-arraytype-before-value-coercion.js +++ b/test/built-ins/Atomics/or/validate-arraytype-before-value-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var value = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.or(typedArray, 0, value); diff --git a/test/built-ins/Atomics/store/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/store/validate-arraytype-before-index-coercion.js index 6eb4292530a..bd40a4b3f48 100644 --- a/test/built-ins/Atomics/store/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/store/validate-arraytype-before-index-coercion.js @@ -19,6 +19,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -28,11 +29,7 @@ var index = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.store(typedArray, index, 0); diff --git a/test/built-ins/Atomics/store/validate-arraytype-before-value-coercion.js b/test/built-ins/Atomics/store/validate-arraytype-before-value-coercion.js index 6cec7450556..76f5a0a3b89 100644 --- a/test/built-ins/Atomics/store/validate-arraytype-before-value-coercion.js +++ b/test/built-ins/Atomics/store/validate-arraytype-before-value-coercion.js @@ -19,6 +19,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -28,11 +29,7 @@ var value = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.store(typedArray, 0, value); diff --git a/test/built-ins/Atomics/sub/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/sub/validate-arraytype-before-index-coercion.js index a2c4380745d..4fbb6b1c752 100644 --- a/test/built-ins/Atomics/sub/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/sub/validate-arraytype-before-index-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var index = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.sub(typedArray, index, 0); diff --git a/test/built-ins/Atomics/sub/validate-arraytype-before-value-coercion.js b/test/built-ins/Atomics/sub/validate-arraytype-before-value-coercion.js index 92351752a07..89a08036f3b 100644 --- a/test/built-ins/Atomics/sub/validate-arraytype-before-value-coercion.js +++ b/test/built-ins/Atomics/sub/validate-arraytype-before-value-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var value = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.sub(typedArray, 0, value); diff --git a/test/built-ins/Atomics/wait/non-int32-typedarray-throws.js b/test/built-ins/Atomics/wait/non-int32-typedarray-throws.js index fd9df6169fa..83294bd838c 100644 --- a/test/built-ins/Atomics/wait/non-int32-typedarray-throws.js +++ b/test/built-ins/Atomics/wait/non-int32-typedarray-throws.js @@ -35,6 +35,15 @@ assert.throws(TypeError, function() { 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'); +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() { const view = new Int16Array( new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2) diff --git a/test/built-ins/Atomics/wait/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/wait/validate-arraytype-before-index-coercion.js index 46dd7e19467..87887d295b6 100644 --- a/test/built-ins/Atomics/wait/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/wait/validate-arraytype-before-index-coercion.js @@ -19,6 +19,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -28,10 +29,7 @@ var index = { } }; -var badArrayTypes = [ - Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array, - Uint8ClampedArray, Float32Array, Float64Array -]; +var badArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; }); for (var badArrayType of badArrayTypes) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); diff --git a/test/built-ins/Atomics/wait/validate-arraytype-before-timeout-coercion.js b/test/built-ins/Atomics/wait/validate-arraytype-before-timeout-coercion.js index 6a6a03fc9ed..4c3d1a8ed2e 100644 --- a/test/built-ins/Atomics/wait/validate-arraytype-before-timeout-coercion.js +++ b/test/built-ins/Atomics/wait/validate-arraytype-before-timeout-coercion.js @@ -19,6 +19,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -28,10 +29,7 @@ var timeout = { } }; -var badArrayTypes = [ - Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array, - Uint8ClampedArray, Float32Array, Float64Array -]; +var badArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; }); for (var badArrayType of badArrayTypes) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); diff --git a/test/built-ins/Atomics/wait/validate-arraytype-before-value-coercion.js b/test/built-ins/Atomics/wait/validate-arraytype-before-value-coercion.js index d85a6b314fd..dc947b68f47 100644 --- a/test/built-ins/Atomics/wait/validate-arraytype-before-value-coercion.js +++ b/test/built-ins/Atomics/wait/validate-arraytype-before-value-coercion.js @@ -19,6 +19,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -28,10 +29,7 @@ var value = { } }; -var badArrayTypes = [ - Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array, - Uint8ClampedArray, Float32Array, Float64Array -]; +var badArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; }); for (var badArrayType of badArrayTypes) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); diff --git a/test/built-ins/Atomics/waitAsync/non-int32-typedarray-throws.js b/test/built-ins/Atomics/waitAsync/non-int32-typedarray-throws.js index bdffdd79f3b..c032e637cd0 100644 --- a/test/built-ins/Atomics/waitAsync/non-int32-typedarray-throws.js +++ b/test/built-ins/Atomics/waitAsync/non-int32-typedarray-throws.js @@ -42,6 +42,15 @@ assert.throws(TypeError, () => { 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'); +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, () => { const view = new Int16Array( new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2) diff --git a/test/built-ins/Atomics/waitAsync/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/waitAsync/validate-arraytype-before-index-coercion.js index f39dd80f14a..c3cdb737092 100644 --- a/test/built-ins/Atomics/waitAsync/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/waitAsync/validate-arraytype-before-index-coercion.js @@ -27,6 +27,7 @@ info: | 9. If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception. 10. Return buffer. +includes: [testTypedArray.js] features: [Atomics.waitAsync, Atomics, TypedArray, SharedArrayBuffer] ---*/ assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"'); @@ -37,10 +38,7 @@ const index = { } }; -const nonSharedArrayTypes = [ - Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array, - Uint8ClampedArray, Float32Array, Float64Array -]; +var nonSharedArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; }); for (const nonSharedArrayType of nonSharedArrayTypes) { const typedArray = new nonSharedArrayType(new SharedArrayBuffer(8)); diff --git a/test/built-ins/Atomics/waitAsync/validate-arraytype-before-value-coercion.js b/test/built-ins/Atomics/waitAsync/validate-arraytype-before-value-coercion.js index e56742991df..037814d0e18 100644 --- a/test/built-ins/Atomics/waitAsync/validate-arraytype-before-value-coercion.js +++ b/test/built-ins/Atomics/waitAsync/validate-arraytype-before-value-coercion.js @@ -27,6 +27,7 @@ info: | 9. If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception. 10. Return buffer. +includes: [testTypedArray.js] features: [Atomics.waitAsync, Atomics, TypedArray, SharedArrayBuffer] ---*/ assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"'); @@ -37,10 +38,7 @@ const value = { } }; -const nonSharedArrayTypes = [ - Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array, - Uint8ClampedArray, Float32Array, Float64Array -]; +var nonSharedArrayTypes = typedArrayConstructors.filter(function(TA) { return TA !== Int32Array; }); for (const nonSharedArrayType of nonSharedArrayTypes) { const typedArray = new nonSharedArrayType(new SharedArrayBuffer(8)); diff --git a/test/built-ins/Atomics/xor/validate-arraytype-before-index-coercion.js b/test/built-ins/Atomics/xor/validate-arraytype-before-index-coercion.js index 847a848d8d0..47c164f0d78 100644 --- a/test/built-ins/Atomics/xor/validate-arraytype-before-index-coercion.js +++ b/test/built-ins/Atomics/xor/validate-arraytype-before-index-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var index = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.xor(typedArray, index, 0); diff --git a/test/built-ins/Atomics/xor/validate-arraytype-before-value-coercion.js b/test/built-ins/Atomics/xor/validate-arraytype-before-value-coercion.js index 8ed0fe2585f..a053282c708 100644 --- a/test/built-ins/Atomics/xor/validate-arraytype-before-value-coercion.js +++ b/test/built-ins/Atomics/xor/validate-arraytype-before-value-coercion.js @@ -22,6 +22,7 @@ info: | a. If typeName is not "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", or "Uint32Array", throw a TypeError exception. ... +includes: [testTypedArray.js] features: [Atomics, TypedArray] ---*/ @@ -31,11 +32,7 @@ var value = { } }; -var badArrayTypes = [ - Uint8ClampedArray, Float32Array, Float64Array -]; - -for (var badArrayType of badArrayTypes) { +for (var badArrayType of nonAtomicsFriendlyTypedArrayConstructors) { var typedArray = new badArrayType(new SharedArrayBuffer(8)); assert.throws(TypeError, function() { Atomics.xor(typedArray, 0, value); diff --git a/test/built-ins/ShadowRealm/prototype/evaluate/globalthis-available-properties.js b/test/built-ins/ShadowRealm/prototype/evaluate/globalthis-available-properties.js index dacf40776d8..2793e231247 100644 --- a/test/built-ins/ShadowRealm/prototype/evaluate/globalthis-available-properties.js +++ b/test/built-ins/ShadowRealm/prototype/evaluate/globalthis-available-properties.js @@ -61,6 +61,7 @@ let properties = [ 'Error', 'EvalError', 'FinalizationRegistry', + 'Float16Array', 'Float32Array', 'Float64Array', 'Function', diff --git a/test/built-ins/TypedArray/prototype/copyWithin/bit-precision.js b/test/built-ins/TypedArray/prototype/copyWithin/bit-precision.js index 399cda2dcdf..9cc36e87a5d 100644 --- a/test/built-ins/TypedArray/prototype/copyWithin/bit-precision.js +++ b/test/built-ins/TypedArray/prototype/copyWithin/bit-precision.js @@ -41,4 +41,4 @@ function body(FloatArray) { assert(compareArray(originalBytes, copiedBytes)); } -testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); +testWithTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js b/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js index 2194ba61af2..ffc8d5678bc 100644 --- a/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js +++ b/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js @@ -73,7 +73,12 @@ features: [TypedArray] ---*/ testWithTypedArrayConstructors(function(FA) { - var precision = FA === Float32Array ? "single" : "double"; + var precision = + FA === Float32Array + ? "single" + : (typeof Float16Array !== "undefined" && TA === Float16Array) + ? "half" + : "double"; var samples = new FA(3); var controls, idx, aNaN; @@ -98,4 +103,4 @@ testWithTypedArrayConstructors(function(FA) { ); } } -}, [Float32Array, Float64Array]); +}, floatArrayConstructors); diff --git a/test/built-ins/TypedArray/prototype/filter/callbackfn-resize.js b/test/built-ins/TypedArray/prototype/filter/callbackfn-resize.js index 3f12d03ac81..c2288aa0707 100644 --- a/test/built-ins/TypedArray/prototype/filter/callbackfn-resize.js +++ b/test/built-ins/TypedArray/prototype/filter/callbackfn-resize.js @@ -15,7 +15,7 @@ assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var NaNvalue = (TA === Float32Array || TA === Float64Array) ? NaN : 0; + var NaNvalue = (TA === Float32Array || TA === Float64Array || (typeof Float16Array !== 'undefined' && TA === Float16Array)) ? NaN : 0; var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, finalResult, expectedElements, expectedIndices, expectedArrays; diff --git a/test/built-ins/TypedArray/prototype/includes/samevaluezero.js b/test/built-ins/TypedArray/prototype/includes/samevaluezero.js index c6ad3785bec..c7acea1cc68 100644 --- a/test/built-ins/TypedArray/prototype/includes/samevaluezero.js +++ b/test/built-ins/TypedArray/prototype/includes/samevaluezero.js @@ -41,4 +41,4 @@ testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(FloatArray) { var sample = new FloatArray([42, 0, 1, undefined, NaN]); assert.sameValue(sample.includes(NaN), true, "NaN"); -}, [Float32Array, Float64Array]); +}, floatArrayConstructors); diff --git a/test/built-ins/TypedArray/prototype/map/callbackfn-resize.js b/test/built-ins/TypedArray/prototype/map/callbackfn-resize.js index 0f403c805a1..5927819659b 100644 --- a/test/built-ins/TypedArray/prototype/map/callbackfn-resize.js +++ b/test/built-ins/TypedArray/prototype/map/callbackfn-resize.js @@ -15,7 +15,7 @@ assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var NaNvalue = (TA === Float32Array || TA === Float64Array) ? NaN : 0; + var NaNvalue = (TA === Float32Array || TA === Float64Array || (typeof Float16Array !== 'undefined' && TA === Float16Array)) ? NaN : 0; var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; diff --git a/test/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js b/test/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js index 44fab4529e3..63ff87afc50 100644 --- a/test/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js +++ b/test/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js @@ -68,4 +68,4 @@ function body(FloatArray) { assert(compareArray(sampleBytes, resultBytes)); } -testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); +testWithTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/built-ins/TypedArray/prototype/set/bit-precision.js b/test/built-ins/TypedArray/prototype/set/bit-precision.js index e0a9b814d4b..e023189d3de 100644 --- a/test/built-ins/TypedArray/prototype/set/bit-precision.js +++ b/test/built-ins/TypedArray/prototype/set/bit-precision.js @@ -32,4 +32,4 @@ function body(FA) { assert(compareArray(sourceBytes, targetBytes)) } -testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); +testWithTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js index 4960a32d43a..741d9f0f510 100644 --- a/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js +++ b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js @@ -11,7 +11,7 @@ features: [SharedArrayBuffer] ---*/ 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; } if (TA === Int32Array) { diff --git a/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js index 45d648c1a20..5ede3b86792 100644 --- a/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js +++ b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js @@ -44,6 +44,11 @@ var expected = { }; testWithTypedArrayConstructors(function(TA) { + if (typeof Float16Array !== 'undefined' && TA === Float16Array) { + // TODO(bakkot) work out bit patterns here + return; + } + var other = TA === Float32Array ? Float64Array : Float32Array; var sample = new TA([1, 2, 3, 4, 5, 6, 7, 8]); diff --git a/test/built-ins/TypedArray/prototype/slice/bit-precision.js b/test/built-ins/TypedArray/prototype/slice/bit-precision.js index fb3074b0bf2..41770bc2592 100644 --- a/test/built-ins/TypedArray/prototype/slice/bit-precision.js +++ b/test/built-ins/TypedArray/prototype/slice/bit-precision.js @@ -36,4 +36,4 @@ function body(FloatArray) { assert(compareArray(subjectBytes, slicedBytes)); } -testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); +testWithTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/built-ins/TypedArray/prototype/sort/sorted-values-nan.js b/test/built-ins/TypedArray/prototype/sort/sorted-values-nan.js index 917c3135a51..1f3ea0be097 100644 --- a/test/built-ins/TypedArray/prototype/sort/sorted-values-nan.js +++ b/test/built-ins/TypedArray/prototype/sort/sorted-values-nan.js @@ -35,4 +35,4 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(sample[4], Infinity, "#2 [4]"); assert.sameValue(sample[5], NaN, "#2 [5]"); assert.sameValue(sample[6], NaN, "#2 [6]"); -}, [Float64Array, Float32Array]); +}, floatArrayConstructors); diff --git a/test/built-ins/TypedArray/prototype/sort/sorted-values.js b/test/built-ins/TypedArray/prototype/sort/sorted-values.js index 5693c6d577a..5b8c0bc13ce 100644 --- a/test/built-ins/TypedArray/prototype/sort/sorted-values.js +++ b/test/built-ins/TypedArray/prototype/sort/sorted-values.js @@ -40,7 +40,7 @@ testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) { 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"); -}, [Float64Array, Float32Array, Int8Array, Int16Array, Int32Array]); +}, floatArrayConstructors.concat([Int8Array, Int16Array, Int32Array]); testWithTypedArrayConstructors(function(TA) { var sample; @@ -54,4 +54,4 @@ testWithTypedArrayConstructors(function(TA) { sample = new TA([3, 4, Infinity, -Infinity, 1, 2]).sort(); assert(compareArray(sample, [-Infinity, 1, 2, 3, 4, Infinity]), "infinities"); -}, [Float64Array, Float32Array]); +}, floatArrayConstructors); diff --git a/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js index 8baba4efa30..30338d17195 100644 --- a/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js +++ b/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js @@ -35,4 +35,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(RangeError, function() { new TA(buffer, 0, undefined); }); -}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); +}, floatArrayConstructors.concat([ Int32Array, Int16Array, Uint32Array, Uint16Array ])); diff --git a/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js index 3b59f050913..c8d4572ea66 100644 --- a/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js +++ b/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js @@ -29,4 +29,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(RangeError, function() { new TA(buffer, 0, undefined); }); -}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); +}, floatArrayConstructors.concat([ Int32Array, Int16Array, Uint32Array, Uint16Array ])); diff --git a/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js index d67216a0cf4..3e15e180f71 100644 --- a/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js +++ b/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js @@ -31,5 +31,5 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(RangeError, function() { new TA(buffer, 7); }); -}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); +}, floatArrayConstructors.concat([ Int32Array, Int16Array, Uint32Array, Uint16Array ])); diff --git a/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.js index 53b6a707abf..dba57e8025a 100644 --- a/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.js +++ b/test/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.js @@ -24,4 +24,4 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(RangeError, function() { new TA(buffer, 7); }); -}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); +}, floatArrayConstructors.concat([ Int32Array, Int16Array, Uint32Array, Uint16Array ])); diff --git a/test/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation-consistent-nan.js b/test/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation-consistent-nan.js index d4400719467..cba697f882c 100644 --- a/test/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation-consistent-nan.js +++ b/test/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation-consistent-nan.js @@ -67,4 +67,4 @@ function body(FloatArray) { assert(compareArray(firstBytes, secondBytes)); } -testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); +testWithTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js b/test/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js index 57eec9720cd..757f5733d59 100644 --- a/test/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js +++ b/test/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js @@ -35,7 +35,7 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(typedArray.constructor, TA); assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); - if (TA === Float32Array || TA === Float64Array) { + if (TA === Float32Array || TA === Float64Array || (typeof Float16Array !== 'undefined' && TA === Float16Array)) { assert.sameValue(typedArray[1], NaN); assert.sameValue(typedArray[4], NaN); } else { diff --git a/test/built-ins/TypedArrayConstructors/from/nan-conversion.js b/test/built-ins/TypedArrayConstructors/from/nan-conversion.js index 68fcdb49176..5ce3ec6e4b0 100644 --- a/test/built-ins/TypedArrayConstructors/from/nan-conversion.js +++ b/test/built-ins/TypedArrayConstructors/from/nan-conversion.js @@ -33,10 +33,7 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Float32Array, - Float64Array -]); +floatArrayConstructors); testWithTypedArrayConstructors(function(TA) { var result = TA.from([NaN, undefined]); @@ -46,13 +43,4 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Int8Array, - Int32Array, - Int16Array, - Int8Array, - Uint32Array, - Uint16Array, - Uint8Array, - Uint8ClampedArray -]); +floatArrayConstructors); diff --git a/test/built-ins/TypedArrayConstructors/from/new-instance-from-ordinary-object.js b/test/built-ins/TypedArrayConstructors/from/new-instance-from-ordinary-object.js index b29d4de6ff9..159f4cf2e14 100644 --- a/test/built-ins/TypedArrayConstructors/from/new-instance-from-ordinary-object.js +++ b/test/built-ins/TypedArrayConstructors/from/new-instance-from-ordinary-object.js @@ -25,10 +25,7 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Float32Array, - Float64Array -]); +floatArrayConstructors); testWithTypedArrayConstructors(function(TA) { var result = TA.from(source); @@ -41,13 +38,4 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Int8Array, - Int32Array, - Int16Array, - Int8Array, - Uint32Array, - Uint16Array, - Uint8Array, - Uint8ClampedArray -]); +intArrayConstructors); diff --git a/test/built-ins/TypedArrayConstructors/from/new-instance-from-sparse-array.js b/test/built-ins/TypedArrayConstructors/from/new-instance-from-sparse-array.js index 2eef7a2a84a..9d16823857d 100644 --- a/test/built-ins/TypedArrayConstructors/from/new-instance-from-sparse-array.js +++ b/test/built-ins/TypedArrayConstructors/from/new-instance-from-sparse-array.js @@ -23,10 +23,7 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Float32Array, - Float64Array -]); +floatArrayConstructors); testWithTypedArrayConstructors(function(TA) { var result = TA.from(source); @@ -41,13 +38,4 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Int8Array, - Int32Array, - Int16Array, - Int8Array, - Uint32Array, - Uint16Array, - Uint8Array, - Uint8ClampedArray -]); +intArrayConstructors); diff --git a/test/built-ins/TypedArrayConstructors/from/new-instance-from-zero.js b/test/built-ins/TypedArrayConstructors/from/new-instance-from-zero.js index 2850dfcdeb7..c311eff35be 100644 --- a/test/built-ins/TypedArrayConstructors/from/new-instance-from-zero.js +++ b/test/built-ins/TypedArrayConstructors/from/new-instance-from-zero.js @@ -16,10 +16,7 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Float32Array, - Float64Array -]); +floatArrayConstructors); testWithTypedArrayConstructors(function(TA) { var result = TA.from([-0, +0]); @@ -29,12 +26,4 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Int16Array, - Int32Array, - Int8Array, - Uint16Array, - Uint32Array, - Uint8Array, - Uint8ClampedArray -]); +intArrayConstructors); diff --git a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js index b861866230f..bfffaed006d 100644 --- a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js +++ b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js @@ -69,7 +69,12 @@ features: [TypedArray] ---*/ testWithTypedArrayConstructors(function(FA) { - var precision = FA === Float32Array ? "single" : "double"; + var precision = + FA === Float32Array + ? "single" + : (typeof Float16Array !== "undefined" && TA === Float16Array) + ? "half" + : "double"; var samples = new FA(1); var controls, idx, aNaN; @@ -94,5 +99,5 @@ testWithTypedArrayConstructors(function(FA) { ); } } -}, [Float32Array, Float64Array]); +}, floatArrayConstructors); diff --git a/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js b/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js index cfc365def78..546a57b358d 100644 --- a/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js +++ b/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js @@ -76,7 +76,12 @@ features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ testWithTypedArrayConstructors(function(FA) { - var precision = FA === Float32Array ? "single" : "double"; + var precision = + FA === Float32Array + ? "single" + : (typeof Float16Array !== "undefined" && TA === Float16Array) + ? "half" + : "double"; var samples = new FA(1); var controls, idx, aNaN; @@ -101,5 +106,5 @@ testWithTypedArrayConstructors(function(FA) { ); } } -}, [Float32Array, Float64Array]); +}, floatArrayConstructors); diff --git a/test/built-ins/TypedArrayConstructors/of/nan-conversion.js b/test/built-ins/TypedArrayConstructors/of/nan-conversion.js index dc12be8b70f..452c2e965bd 100644 --- a/test/built-ins/TypedArrayConstructors/of/nan-conversion.js +++ b/test/built-ins/TypedArrayConstructors/of/nan-conversion.js @@ -34,10 +34,7 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Float32Array, - Float64Array -]); +floatArrayConstructors); testWithTypedArrayConstructors(function(TA) { var result = TA.of(NaN, undefined); @@ -47,13 +44,4 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Int8Array, - Int32Array, - Int16Array, - Int8Array, - Uint32Array, - Uint16Array, - Uint8Array, - Uint8ClampedArray -]); +intArrayConstructors); diff --git a/test/built-ins/TypedArrayConstructors/of/new-instance-from-zero.js b/test/built-ins/TypedArrayConstructors/of/new-instance-from-zero.js index ecffd9c36f2..bba815645e3 100644 --- a/test/built-ins/TypedArrayConstructors/of/new-instance-from-zero.js +++ b/test/built-ins/TypedArrayConstructors/of/new-instance-from-zero.js @@ -16,10 +16,7 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Float32Array, - Float64Array -]); +floatArrayConstructors); testWithTypedArrayConstructors(function(TA) { var result = TA.of(-0, +0); @@ -29,12 +26,4 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -[ - Int16Array, - Int32Array, - Int8Array, - Uint16Array, - Uint32Array, - Uint8Array, - Uint8ClampedArray -]); +intArrayConstructors); diff --git a/test/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js b/test/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js index dac5e2f7695..61b4e132c63 100644 --- a/test/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js +++ b/test/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js @@ -14,20 +14,11 @@ info: | call to the TypedArray constructor to create and initialize the subclass instance with the internal state necessary to support the %TypedArray%.prototype built-in methods. +includes: [testTypedArray.js] features: [TypedArray] ---*/ -[ - Int8Array, - Uint8Array, - Uint8ClampedArray, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array -].forEach(function(Constructor) { +testWithTypedArrayConstructors(function(Constructor) { class Typed extends Constructor {} var arr = new Typed(2); diff --git a/test/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js b/test/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js index 04997029868..de27fb8852e 100644 --- a/test/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js +++ b/test/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js @@ -14,20 +14,11 @@ info: | call to the TypedArray constructor to create and initialize the subclass instance with the internal state necessary to support the %TypedArray%.prototype built-in methods. +includes: [testTypedArray.js] features: [TypedArray] ---*/ -[ - Int8Array, - Uint8Array, - Uint8ClampedArray, - Int16Array, - Uint16Array, - Int32Array, - Uint32Array, - Float32Array, - Float64Array -].forEach(function(Constructor) { +testWithTypedArrayConstructors(function(Constructor) { class Typed extends Constructor { constructor() {} } From 9fd541994ccc556536989b2268a2ff4af0b45dca Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Sat, 18 Nov 2023 20:15:53 -0800 Subject: [PATCH 2/5] add helpers --- harness/testTypedArray.js | 28 +++++++++++++++++++ ...es-conversion-operations-consistent-nan.js | 7 +---- .../prototype/filter/callbackfn-resize.js | 2 +- .../prototype/map/callbackfn-resize.js | 2 +- .../ctors/object-arg/returns.js | 2 +- .../conversion-operation-consistent-nan.js | 7 +---- .../conversion-operation-consistent-nan.js | 11 ++------ 7 files changed, 36 insertions(+), 23 deletions(-) diff --git a/harness/testTypedArray.js b/harness/testTypedArray.js index efb21f317b9..f8345924f81 100644 --- a/harness/testTypedArray.js +++ b/harness/testTypedArray.js @@ -127,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"); + } +} diff --git a/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js b/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js index ffc8d5678bc..7cacc2d6e69 100644 --- a/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js +++ b/test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js @@ -73,12 +73,7 @@ features: [TypedArray] ---*/ testWithTypedArrayConstructors(function(FA) { - var precision = - FA === Float32Array - ? "single" - : (typeof Float16Array !== "undefined" && TA === Float16Array) - ? "half" - : "double"; + var precision = floatTypedArrayConstructorPrecision(FA); var samples = new FA(3); var controls, idx, aNaN; diff --git a/test/built-ins/TypedArray/prototype/filter/callbackfn-resize.js b/test/built-ins/TypedArray/prototype/filter/callbackfn-resize.js index c2288aa0707..339af37913d 100644 --- a/test/built-ins/TypedArray/prototype/filter/callbackfn-resize.js +++ b/test/built-ins/TypedArray/prototype/filter/callbackfn-resize.js @@ -15,7 +15,7 @@ assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var NaNvalue = (TA === Float32Array || TA === Float64Array || (typeof Float16Array !== 'undefined' && TA === Float16Array)) ? NaN : 0; + var NaNvalue = isFloatTypedArrayConstructor(TA) ? NaN : 0; var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, finalResult, expectedElements, expectedIndices, expectedArrays; diff --git a/test/built-ins/TypedArray/prototype/map/callbackfn-resize.js b/test/built-ins/TypedArray/prototype/map/callbackfn-resize.js index 5927819659b..75b37f4a6c9 100644 --- a/test/built-ins/TypedArray/prototype/map/callbackfn-resize.js +++ b/test/built-ins/TypedArray/prototype/map/callbackfn-resize.js @@ -15,7 +15,7 @@ assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var NaNvalue = (TA === Float32Array || TA === Float64Array || (typeof Float16Array !== 'undefined' && TA === Float16Array)) ? NaN : 0; + var NaNvalue = isFloatTypedArrayConstructor(TA) ? NaN : 0; var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; diff --git a/test/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js b/test/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js index 757f5733d59..e48173a1654 100644 --- a/test/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js +++ b/test/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js @@ -35,7 +35,7 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(typedArray.constructor, TA); assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); - if (TA === Float32Array || TA === Float64Array || (typeof Float16Array !== 'undefined' && TA === Float16Array)) { + if (isFloatTypedArrayConstructor(TA)) { assert.sameValue(typedArray[1], NaN); assert.sameValue(typedArray[4], NaN); } else { diff --git a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js index bfffaed006d..f1962a00d81 100644 --- a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js +++ b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js @@ -69,12 +69,7 @@ features: [TypedArray] ---*/ testWithTypedArrayConstructors(function(FA) { - var precision = - FA === Float32Array - ? "single" - : (typeof Float16Array !== "undefined" && TA === Float16Array) - ? "half" - : "double"; + var precision = floatTypedArrayConstructorPrecision(FA); var samples = new FA(1); var controls, idx, aNaN; diff --git a/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js b/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js index 546a57b358d..1d98c334089 100644 --- a/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js +++ b/test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js @@ -76,12 +76,7 @@ features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ testWithTypedArrayConstructors(function(FA) { - var precision = - FA === Float32Array - ? "single" - : (typeof Float16Array !== "undefined" && TA === Float16Array) - ? "half" - : "double"; + var precision = floatTypedArrayConstructorPrecision(FA); var samples = new FA(1); var controls, idx, aNaN; @@ -97,12 +92,12 @@ testWithTypedArrayConstructors(function(FA) { assert( 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( controls[i] !== controls[i], - 'The result of `(controls[i] !== controls[i])` is true' + `The result of \`(controls[i] !== controls[i])\` is true (${precision} precision)` ); } } From c1cf1d3626b5e73b6c8929c59ddbd3fdee62d7b7 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 20 Nov 2023 09:54:42 -0800 Subject: [PATCH 3/5] address todo --- .../set/typedarray-arg-set-values-same-buffer-other-type.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js index 5ede3b86792..726bc815652 100644 --- a/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js +++ b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js @@ -34,6 +34,7 @@ features: [TypedArray] var expected = { Float64Array: [1.0000002464512363, 42, 1.875, 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], Int16Array: [0, 42, 0, 4, 5, 6, 7, 8], Int8Array: [0, 42, 0, 66, 5, 6, 7, 8], @@ -44,11 +45,6 @@ var expected = { }; testWithTypedArrayConstructors(function(TA) { - if (typeof Float16Array !== 'undefined' && TA === Float16Array) { - // TODO(bakkot) work out bit patterns here - return; - } - var other = TA === Float32Array ? Float64Array : Float32Array; var sample = new TA([1, 2, 3, 4, 5, 6, 7, 8]); From 09645660f8bb3d3095dc15957bd4e4a9b8fb8826 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 20 Nov 2023 09:56:06 -0800 Subject: [PATCH 4/5] use correct constructors --- test/built-ins/TypedArrayConstructors/from/nan-conversion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/TypedArrayConstructors/from/nan-conversion.js b/test/built-ins/TypedArrayConstructors/from/nan-conversion.js index 5ce3ec6e4b0..d4fffa51898 100644 --- a/test/built-ins/TypedArrayConstructors/from/nan-conversion.js +++ b/test/built-ins/TypedArrayConstructors/from/nan-conversion.js @@ -43,4 +43,4 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(result.constructor, TA); assert.sameValue(Object.getPrototypeOf(result), TA.prototype); }, -floatArrayConstructors); +intArrayConstructors); From e5d20a7fb8ed1beeeba3eb75c21aed433de164ac Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Thu, 28 Dec 2023 16:17:39 -0800 Subject: [PATCH 5/5] fix missing paren --- test/built-ins/TypedArray/prototype/sort/sorted-values.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/TypedArray/prototype/sort/sorted-values.js b/test/built-ins/TypedArray/prototype/sort/sorted-values.js index 5b8c0bc13ce..acc7fc88018 100644 --- a/test/built-ins/TypedArray/prototype/sort/sorted-values.js +++ b/test/built-ins/TypedArray/prototype/sort/sorted-values.js @@ -40,7 +40,7 @@ testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) { 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"); -}, floatArrayConstructors.concat([Int8Array, Int16Array, Int32Array]); +}, floatArrayConstructors.concat([Int8Array, Int16Array, Int32Array])); testWithTypedArrayConstructors(function(TA) { var sample;