diff --git a/harness/testBigIntTypedArray.js b/harness/testBigIntTypedArray.js index c9d559de09..cc7ae7a9f0 100644 --- a/harness/testBigIntTypedArray.js +++ b/harness/testBigIntTypedArray.js @@ -6,7 +6,6 @@ description: | defines: - TypedArray - testWithBigIntTypedArrayConstructors - - testWithNonShareableBigIntTypedArrayConstructors ---*/ /** @@ -39,12 +38,3 @@ function testWithBigIntTypedArrayConstructors(f, selected) { } } } - -/** - * Calls the provided function for every NON SHARABLE bigint typed array constructor. - * - * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. - */ -function testWithNonShareableBigIntTypedArrayConstructors(f) { - testWithBigIntTypedArrayConstructors(f, [BigUint64Array]); -} diff --git a/harness/testTypedArray.js b/harness/testTypedArray.js index faf4c7aa09..27ca2ceae9 100644 --- a/harness/testTypedArray.js +++ b/harness/testTypedArray.js @@ -9,7 +9,8 @@ defines: - intArrayConstructors - TypedArray - testWithTypedArrayConstructors - - testWithNonShareableTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors - testTypedArrayConversions ---*/ @@ -63,21 +64,33 @@ function testWithTypedArrayConstructors(f, selected) { } /** - * Calls the provided function for every NON SHARABLE typed array constructor. + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. * * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. * @param {Array} selected - An optional Array with filtered typed arrays */ -function testWithNonShareableTypedArrayConstructors(f) { +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { testWithTypedArrayConstructors(f, [ Float64Array, Float32Array, + Uint8ClampedArray + ]); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, Int16Array, Int8Array, Uint32Array, Uint16Array, Uint8Array, - Uint8ClampedArray ]); } diff --git a/test/built-ins/Atomics/add/bigint/non-shared-bufferdata.js b/test/built-ins/Atomics/add/bigint/non-shared-bufferdata.js index 3ea44b5a25..d48682edc3 100644 --- a/test/built-ins/Atomics/add/bigint/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/add/bigint/non-shared-bufferdata.js @@ -4,8 +4,12 @@ esid: sec-atomics.add description: > Atomics.add will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testBigIntTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -const i64a = new BigInt64Array(new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)); -assert.sameValue(Atomics.add(i64a, 0, 1n), 0n, 'Atomics.add(i64a, 0, 1n) returns 0n'); -assert.sameValue(Atomics.load(i64a, 0), 1n, 'Atomics.load(i64a, 0) returns 1n'); +testWithBigIntTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); + const view = new TA(buffer); + assert.sameValue(Atomics.add(view, 0, 1n), 0n, 'Atomics.add(view, 0, 1n) returns 0n'); + assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); +}); diff --git a/test/built-ins/Atomics/add/bigint/non-shared-int-views-throws.js b/test/built-ins/Atomics/add/bigint/non-shared-int-views-throws.js deleted file mode 100644 index 2685316da9..0000000000 --- a/test/built-ins/Atomics/add/bigint/non-shared-int-views-throws.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-atomics.add -description: > - Atomics.add throws when operating on non-sharable integer TypedArrays -includes: [testBigIntTypedArray.js] -features: [ArrayBuffer, Atomics, BigInt, TypedArray] ----*/ -const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableBigIntTypedArrayConstructors(function(TA) { - const view = new TA(buffer); - - assert.throws(TypeError, function() { - Atomics.add(view, 0, 1n); - }, `Atomics.add(new ${TA.name}(buffer), 0, 1n) throws TypeError`); -}); diff --git a/test/built-ins/Atomics/add/non-shared-bufferdata.js b/test/built-ins/Atomics/add/non-shared-bufferdata.js index b586cb241e..364e7f0ac3 100644 --- a/test/built-ins/Atomics/add/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/add/non-shared-bufferdata.js @@ -5,13 +5,14 @@ esid: sec-atomics.add description: > Atomics.add will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ +testWithAtomicsFriendlyTypedArrayConstructors(TA => { + const view = new TA( + new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) + ); -const i32a = new Int32Array( - new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) -); - -assert.sameValue(Atomics.add(i32a, 0, 1), 0, 'Atomics.add(i32a, 0, 1) returns 0'); -assert.sameValue(Atomics.load(i32a, 0), 1, 'Atomics.load(i32a, 0) returns 1'); - + assert.sameValue(Atomics.add(view, 0, 1), 0, 'Atomics.add(view, 0, 1) returns 0'); + assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1'); +}); diff --git a/test/built-ins/Atomics/add/non-shared-int-views-throws.js b/test/built-ins/Atomics/add/non-shared-int-views-throws.js index 7e62f7b561..0a98a5e10b 100644 --- a/test/built-ins/Atomics/add/non-shared-int-views-throws.js +++ b/test/built-ins/Atomics/add/non-shared-int-views-throws.js @@ -8,10 +8,8 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ - -const buffer = new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableTypedArrayConstructors(function(TA) { +testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); const view = new TA(buffer); assert.throws(TypeError, function() { diff --git a/test/built-ins/Atomics/and/bigint/non-shared-bufferdata.js b/test/built-ins/Atomics/and/bigint/non-shared-bufferdata.js index 04df9fbf4a..cfcd7cd597 100644 --- a/test/built-ins/Atomics/and/bigint/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/and/bigint/non-shared-bufferdata.js @@ -4,8 +4,12 @@ esid: sec-atomics.and description: > Atomics.and will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testBigIntTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -const i64a = new BigInt64Array(new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)); -assert.sameValue(Atomics.and(i64a, 0, 1n), 0n, 'Atomics.and(i64a, 0, 1n) returns 0n'); -assert.sameValue(Atomics.load(i64a, 0), 0n, 'Atomics.load(i64a, 0) returns 0n'); +testWithBigIntTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); + const view = new TA(buffer); + assert.sameValue(Atomics.and(view, 0, 1n), 0n, 'Atomics.and(view, 0, 1n) returns 0n'); + assert.sameValue(Atomics.load(view, 0), 0n, 'Atomics.load(view, 0) returns 0n'); +}); diff --git a/test/built-ins/Atomics/and/bigint/non-shared-int-views-throws.js b/test/built-ins/Atomics/and/bigint/non-shared-int-views-throws.js deleted file mode 100644 index 7bc9e49ff9..0000000000 --- a/test/built-ins/Atomics/and/bigint/non-shared-int-views-throws.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-atomics.and -description: > - Atomics.and throws when operating on non-sharable integer TypedArrays -includes: [testBigIntTypedArray.js] -features: [ArrayBuffer, Atomics, BigInt, TypedArray] ----*/ -const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableBigIntTypedArrayConstructors(function(TA) { - const view = new TA(buffer); - - assert.throws(TypeError, function() { - Atomics.and(view, 0, 1n); - }, `Atomics.and(new ${TA.name}(buffer), 0, 1n) throws TypeError`); -}); diff --git a/test/built-ins/Atomics/and/non-shared-bufferdata.js b/test/built-ins/Atomics/and/non-shared-bufferdata.js index 9232693dbc..aa6a6d6ca8 100644 --- a/test/built-ins/Atomics/and/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/and/non-shared-bufferdata.js @@ -5,13 +5,14 @@ esid: sec-atomics.and description: > Atomics.and will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ +testWithAtomicsFriendlyTypedArrayConstructors(TA => { + const view = new TA( + new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) + ); -const i32a = new Int32Array( - new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) -); - -assert.sameValue(Atomics.and(i32a, 0, 1), 0, 'Atomics.and(i32a, 0, 1) returns 0'); -assert.sameValue(Atomics.load(i32a, 0), 0, 'Atomics.load(i32a, 0) returns 0'); - + assert.sameValue(Atomics.and(view, 0, 1), 0, 'Atomics.and(view, 0, 1) returns 0'); + assert.sameValue(Atomics.load(view, 0), 0, 'Atomics.load(view, 0) returns 0'); +}); diff --git a/test/built-ins/Atomics/and/non-shared-int-views-throws.js b/test/built-ins/Atomics/and/non-shared-int-views-throws.js index 51367fd6a3..8b0da10ee3 100644 --- a/test/built-ins/Atomics/and/non-shared-int-views-throws.js +++ b/test/built-ins/Atomics/and/non-shared-int-views-throws.js @@ -8,10 +8,8 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ - -const buffer = new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableTypedArrayConstructors(function(TA) { +testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); const view = new TA(buffer); assert.throws(TypeError, function() { diff --git a/test/built-ins/Atomics/compareExchange/bigint/non-shared-bufferdata.js b/test/built-ins/Atomics/compareExchange/bigint/non-shared-bufferdata.js index 72f672e713..9442589f7a 100644 --- a/test/built-ins/Atomics/compareExchange/bigint/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/compareExchange/bigint/non-shared-bufferdata.js @@ -4,8 +4,12 @@ esid: sec-atomics.compareExchange description: > Atomics.compareExchange will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testBigIntTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -const i64a = new BigInt64Array(new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)); -assert.sameValue(Atomics.compareExchange(i64a, 0, 0n, 1n), 0n, 'Atomics.compareExchange(i64a, 0, 0n, 1n) returns 0n'); -assert.sameValue(Atomics.load(i64a, 0), 1n, 'Atomics.load(i64a, 0) returns 1n'); +testWithBigIntTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); + const view = new TA(buffer); + assert.sameValue(Atomics.compareExchange(view, 0, 0n, 1n), 0n, 'Atomics.compareExchange(view, 0, 0n, 1n) returns 0n'); + assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); +}); diff --git a/test/built-ins/Atomics/compareExchange/bigint/non-shared-int-views-throws.js b/test/built-ins/Atomics/compareExchange/bigint/non-shared-int-views-throws.js deleted file mode 100644 index 29704be216..0000000000 --- a/test/built-ins/Atomics/compareExchange/bigint/non-shared-int-views-throws.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-atomics.compareExchange -description: > - Atomics.compareExchange throws when operating on non-sharable integer TypedArrays -includes: [testBigIntTypedArray.js] -features: [ArrayBuffer, Atomics, BigInt, TypedArray] ----*/ -const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableBigIntTypedArrayConstructors(function(TA) { - const view = new TA(buffer); - - assert.throws(TypeError, function() { - Atomics.compareExchange(view, 0, 0n, 0n); - }, `Atomics.compareExchange(new ${TA.name}(buffer), 0, 0n, 0n) throws TypeError`); -}); diff --git a/test/built-ins/Atomics/compareExchange/non-shared-bufferdata.js b/test/built-ins/Atomics/compareExchange/non-shared-bufferdata.js index b77cbfc027..025f3e05a8 100644 --- a/test/built-ins/Atomics/compareExchange/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/compareExchange/non-shared-bufferdata.js @@ -5,13 +5,14 @@ esid: sec-atomics.compareExchange description: > Atomics.compareExchange will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ +testWithAtomicsFriendlyTypedArrayConstructors(TA => { + const view = new TA( + new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) + ); -const i32a = new Int32Array( - new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) -); - -assert.sameValue(Atomics.compareExchange(i32a, 0, 0, 1), 0, 'Atomics.compareExchange(i32a, 0, 0, 1) returns 0'); -assert.sameValue(Atomics.load(i32a, 0), 1, 'Atomics.load(i32a, 0) returns 1'); - + assert.sameValue(Atomics.compareExchange(view, 0, 0, 1), 0, 'Atomics.compareExchange(view, 0, 0, 1) returns 0'); + assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1'); +}); diff --git a/test/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js b/test/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js index d17fa3af7f..0006a53fe9 100644 --- a/test/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js +++ b/test/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js @@ -8,10 +8,8 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ - -const buffer = new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableTypedArrayConstructors(function(TA) { +testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); const view = new TA(buffer); assert.throws(TypeError, function() { diff --git a/test/built-ins/Atomics/exchange/bigint/non-shared-bufferdata.js b/test/built-ins/Atomics/exchange/bigint/non-shared-bufferdata.js index 2590ba6d58..21582471a2 100644 --- a/test/built-ins/Atomics/exchange/bigint/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/exchange/bigint/non-shared-bufferdata.js @@ -4,8 +4,12 @@ esid: sec-atomics.exchange description: > Atomics.exchange will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testBigIntTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -const i64a = new BigInt64Array(new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)); -assert.sameValue(Atomics.exchange(i64a, 0, 1n), 0n, 'Atomics.exchange(i64a, 0, 1n) returns 0n'); -assert.sameValue(Atomics.load(i64a, 0), 1n, 'Atomics.load(i64a, 0) returns 1n'); +testWithBigIntTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); + const view = new TA(buffer); + assert.sameValue(Atomics.exchange(view, 0, 1n), 0n, 'Atomics.exchange(view, 0, 1n) returns 0n'); + assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); +}); diff --git a/test/built-ins/Atomics/exchange/bigint/non-shared-int-views-throws.js b/test/built-ins/Atomics/exchange/bigint/non-shared-int-views-throws.js deleted file mode 100644 index 7306f71a04..0000000000 --- a/test/built-ins/Atomics/exchange/bigint/non-shared-int-views-throws.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-atomics.exchange -description: > - Atomics.exchange throws when operating on non-sharable integer TypedArrays -includes: [testBigIntTypedArray.js] -features: [ArrayBuffer, Atomics, BigInt, TypedArray] ----*/ -const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableBigIntTypedArrayConstructors(function(TA) { - const view = new TA(buffer); - - assert.throws(TypeError, function() { - Atomics.exchange(view, 0, 0n); - }, `Atomics.exchange(new ${TA.name}(buffer), 0, 0n) throws TypeError`); -}); diff --git a/test/built-ins/Atomics/exchange/non-shared-bufferdata.js b/test/built-ins/Atomics/exchange/non-shared-bufferdata.js index e8a0656437..d0694dab22 100644 --- a/test/built-ins/Atomics/exchange/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/exchange/non-shared-bufferdata.js @@ -5,13 +5,14 @@ esid: sec-atomics.exchange description: > Atomics.exchange will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ +testWithAtomicsFriendlyTypedArrayConstructors(TA => { + const view = new TA( + new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) + ); -const i32a = new Int32Array( - new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) -); - -assert.sameValue(Atomics.exchange(i32a, 0, 1), 0, 'Atomics.exchange(i32a, 0, 1) returns 0'); -assert.sameValue(Atomics.load(i32a, 0), 1, 'Atomics.load(i32a, 0) returns 1'); - + assert.sameValue(Atomics.exchange(view, 0, 1), 0, 'Atomics.exchange(view, 0, 1) returns 0'); + assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1'); +}); diff --git a/test/built-ins/Atomics/exchange/non-shared-int-views-throws.js b/test/built-ins/Atomics/exchange/non-shared-int-views-throws.js index 37633b15f1..aca2ec627d 100644 --- a/test/built-ins/Atomics/exchange/non-shared-int-views-throws.js +++ b/test/built-ins/Atomics/exchange/non-shared-int-views-throws.js @@ -8,12 +8,9 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ - -const buffer = new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableTypedArrayConstructors(function(TA) { +testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); const view = new TA(buffer); - assert.throws(TypeError, function() { Atomics.add(view, 0, 1); }, `Atomics.add(new ${TA.name}(buffer), 0, 1) throws TypeError`); diff --git a/test/built-ins/Atomics/load/bigint/non-shared-bufferdata.js b/test/built-ins/Atomics/load/bigint/non-shared-bufferdata.js index b61568b105..a3f94dbe61 100644 --- a/test/built-ins/Atomics/load/bigint/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/load/bigint/non-shared-bufferdata.js @@ -4,7 +4,11 @@ esid: sec-atomics.load description: > Atomics.load will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testBigIntTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -const i64a = new BigInt64Array(new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)); -assert.sameValue(Atomics.load(i64a, 0), 0n, 'Atomics.load(i64a, 0) returns 0n'); +testWithBigIntTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); + const view = new TA(buffer); + assert.sameValue(Atomics.load(view, 0), 0n, 'Atomics.load(view, 0) returns 0n'); +}); diff --git a/test/built-ins/Atomics/load/bigint/non-shared-int-views-throws.js b/test/built-ins/Atomics/load/bigint/non-shared-int-views-throws.js deleted file mode 100644 index 8ef1639683..0000000000 --- a/test/built-ins/Atomics/load/bigint/non-shared-int-views-throws.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-atomics.load -description: > - Atomics.load throws when operating on non-sharable integer TypedArrays -includes: [testBigIntTypedArray.js] -features: [ArrayBuffer, Atomics, BigInt, TypedArray] ----*/ - -const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableBigIntTypedArrayConstructors(function(TA) { - const view = new TA(buffer); - assert.throws(TypeError, function() { - Atomics.load(view, 0); - }, `Atomics.load(new ${TA.name}(buffer), 0) throws TypeError`); -}); diff --git a/test/built-ins/Atomics/load/non-shared-bufferdata.js b/test/built-ins/Atomics/load/non-shared-bufferdata.js index 3fab8ffce3..8f1828b274 100644 --- a/test/built-ins/Atomics/load/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/load/non-shared-bufferdata.js @@ -5,11 +5,13 @@ esid: sec-atomics.load description: > Atomics.load will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ +testWithAtomicsFriendlyTypedArrayConstructors(TA => { + const view = new TA( + new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) + ); -const i32a = new Int32Array( - new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) -); - -assert.sameValue(Atomics.load(i32a, 0), 0, 'Atomics.load(i32a, 0) returns 0'); + assert.sameValue(Atomics.load(view, 0), 0, 'Atomics.load(view, 0) returns 0'); +}); diff --git a/test/built-ins/Atomics/load/non-shared-int-views-throws.js b/test/built-ins/Atomics/load/non-shared-int-views-throws.js index 81e849121e..4ee7c8e3dc 100644 --- a/test/built-ins/Atomics/load/non-shared-int-views-throws.js +++ b/test/built-ins/Atomics/load/non-shared-int-views-throws.js @@ -8,10 +8,8 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ - -const buffer = new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableTypedArrayConstructors(function(TA) { +testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); const view = new TA(buffer); assert.throws(TypeError, function() { Atomics.load(view, 0); diff --git a/test/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js b/test/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js index 4ecee85f3f..806ac14c1e 100644 --- a/test/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js +++ b/test/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js @@ -31,5 +31,3 @@ const poisoned = { assert.throws(Test262Error, function() { Atomics.notify(i64a, poisoned, 0); }, '`Atomics.notify(i64a, poisoned, 0)` throws Test262Error'); - - diff --git a/test/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js b/test/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js index 78fdcf574c..0e882dbcaa 100644 --- a/test/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js +++ b/test/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js @@ -5,7 +5,7 @@ esid: sec-atomics.notify description: > Atomics.notify throws on non-shared integer TypedArrays -features: [ArrayBuffer, Atomics, BigInt TypedArray] +features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ const nonsab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8); diff --git a/test/built-ins/Atomics/or/bigint/non-shared-bufferdata.js b/test/built-ins/Atomics/or/bigint/non-shared-bufferdata.js index 2197bbd3ac..8e68d14da8 100644 --- a/test/built-ins/Atomics/or/bigint/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/or/bigint/non-shared-bufferdata.js @@ -4,8 +4,12 @@ esid: sec-atomics.or description: > Atomics.or will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testBigIntTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -const i64a = new BigInt64Array(new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)); -assert.sameValue(Atomics.or(i64a, 0, 1n), 0n, 'Atomics.or(i64a, 0, 1n) returns 0n'); -assert.sameValue(Atomics.load(i64a, 0), 1n, 'Atomics.load(i64a, 0) returns 1n'); +testWithBigIntTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); + const view = new TA(buffer); + assert.sameValue(Atomics.or(view, 0, 1n), 0n, 'Atomics.or(view, 0, 1n) returns 0n'); + assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); +}); diff --git a/test/built-ins/Atomics/or/bigint/non-shared-int-views-throws.js b/test/built-ins/Atomics/or/bigint/non-shared-int-views-throws.js deleted file mode 100644 index 76dd1f4113..0000000000 --- a/test/built-ins/Atomics/or/bigint/non-shared-int-views-throws.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-atomics.or -description: > - Atomics.or throws when operating on non-sharable integer TypedArrays -includes: [testBigIntTypedArray.js] -features: [ArrayBuffer, Atomics, BigInt, TypedArray] ----*/ -const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableBigIntTypedArrayConstructors(function(TA) { - const view = new TA(buffer); - - assert.throws(TypeError, function() { - Atomics.or(view, 0, 1n); - }, `Atomics.or(new ${TA.name}(buffer), 0, 1n) throws TypeError`); -}); diff --git a/test/built-ins/Atomics/or/non-shared-bufferdata.js b/test/built-ins/Atomics/or/non-shared-bufferdata.js index cc612aede9..d1ad8cac95 100644 --- a/test/built-ins/Atomics/or/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/or/non-shared-bufferdata.js @@ -5,13 +5,14 @@ esid: sec-atomics.or description: > Atomics.or will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ +testWithAtomicsFriendlyTypedArrayConstructors(TA => { + const view = new TA( + new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) + ); -const i32a = new Int32Array( - new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) -); - -assert.sameValue(Atomics.or(i32a, 0, 1), 0, 'Atomics.or(i32a, 0, 1) returns 0'); -assert.sameValue(Atomics.load(i32a, 0), 1, 'Atomics.load(i32a, 0) returns 1'); - + assert.sameValue(Atomics.or(view, 0, 1), 0, 'Atomics.or(view, 0, 1) returns 0'); + assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1'); +}); diff --git a/test/built-ins/Atomics/or/non-shared-int-views-throws.js b/test/built-ins/Atomics/or/non-shared-int-views-throws.js index 51367fd6a3..8b0da10ee3 100644 --- a/test/built-ins/Atomics/or/non-shared-int-views-throws.js +++ b/test/built-ins/Atomics/or/non-shared-int-views-throws.js @@ -8,10 +8,8 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ - -const buffer = new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableTypedArrayConstructors(function(TA) { +testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); const view = new TA(buffer); assert.throws(TypeError, function() { diff --git a/test/built-ins/Atomics/store/bigint/bad-range.js b/test/built-ins/Atomics/store/bigint/bad-range.js index 41293772bd..c79f46f9d3 100644 --- a/test/built-ins/Atomics/store/bigint/bad-range.js +++ b/test/built-ins/Atomics/store/bigint/bad-range.js @@ -9,7 +9,7 @@ features: [ArrayBuffer, Atomics, BigInt, DataView, SharedArrayBuffer, Symbol, Ty ---*/ const buffer = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2); -testWithBigIntTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(TA => { const view = new TA(buffer); testWithAtomicsOutOfBoundsIndices(function(IdxGen) { diff --git a/test/built-ins/Atomics/store/bigint/non-shared-bufferdata.js b/test/built-ins/Atomics/store/bigint/non-shared-bufferdata.js index 22ab646070..254640ef70 100644 --- a/test/built-ins/Atomics/store/bigint/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/store/bigint/non-shared-bufferdata.js @@ -4,8 +4,12 @@ esid: sec-atomics.store description: > Atomics.store will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testBigIntTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -const i64a = new BigInt64Array(new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)); -assert.sameValue(Atomics.store(i64a, 0, 1n), 1n, 'Atomics.store(i64a, 0, 1n) returns 1n'); -assert.sameValue(Atomics.load(i64a, 0), 1n, 'Atomics.load(i64a, 0) returns 1n'); +testWithBigIntTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); + const view = new TA(buffer); + assert.sameValue(Atomics.store(view, 0, 1n), 1n, 'Atomics.store(view, 0, 1n) returns 1n'); + assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); +}); diff --git a/test/built-ins/Atomics/store/bigint/non-shared-int-views-throws.js b/test/built-ins/Atomics/store/bigint/non-shared-int-views-throws.js deleted file mode 100644 index 6f4937d9b3..0000000000 --- a/test/built-ins/Atomics/store/bigint/non-shared-int-views-throws.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-atomics.store -description: > - Atomics.store throws when operating on non-sharable integer TypedArrays -includes: [testBigIntTypedArray.js] -features: [ArrayBuffer, Atomics, BigInt, TypedArray] ----*/ -const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableBigIntTypedArrayConstructors(function(TA) { - const view = new TA(buffer); - - assert.throws(TypeError, function() { - Atomics.store(view, 0, 1n); - }, `Atomics.store(new ${TA.name}(buffer), 0, 1n) throws TypeError`); -}); diff --git a/test/built-ins/Atomics/store/non-shared-bufferdata.js b/test/built-ins/Atomics/store/non-shared-bufferdata.js index eb2833995f..9a4ce03e65 100644 --- a/test/built-ins/Atomics/store/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/store/non-shared-bufferdata.js @@ -5,13 +5,14 @@ esid: sec-atomics.store description: > Atomics.store will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ +testWithAtomicsFriendlyTypedArrayConstructors(TA => { + const view = new TA( + new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) + ); -const i32a = new Int32Array( - new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) -); - -assert.sameValue(Atomics.store(i32a, 0, 1), 1, 'Atomics.store(i32a, 0, 1) returns 1'); -assert.sameValue(Atomics.load(i32a, 0), 1, 'Atomics.load(i32a, 0) returns 1'); - + assert.sameValue(Atomics.store(view, 0, 1), 1, 'Atomics.store(view, 0, 1) returns 1'); + assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1'); +}); diff --git a/test/built-ins/Atomics/store/non-shared-int-views-throws.js b/test/built-ins/Atomics/store/non-shared-int-views-throws.js index c316d5bd8f..35198c6a00 100644 --- a/test/built-ins/Atomics/store/non-shared-int-views-throws.js +++ b/test/built-ins/Atomics/store/non-shared-int-views-throws.js @@ -8,10 +8,8 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ - -const buffer = new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableTypedArrayConstructors(function(TA) { +testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); const view = new TA(buffer); assert.throws(TypeError, function() { diff --git a/test/built-ins/Atomics/sub/bigint/non-shared-bufferdata.js b/test/built-ins/Atomics/sub/bigint/non-shared-bufferdata.js index f956e07be2..5da25106af 100644 --- a/test/built-ins/Atomics/sub/bigint/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/sub/bigint/non-shared-bufferdata.js @@ -4,9 +4,13 @@ esid: sec-atomics.sub description: > Atomics.sub will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testBigIntTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -const i64a = new BigInt64Array(new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)); -assert.sameValue(Atomics.store(i64a, 0, 1n), 1n, 'Atomics.store(i64a, 0, 1n) returns 1n'); -assert.sameValue(Atomics.sub(i64a, 0, 1n), 1n, 'Atomics.sub(i64a, 0, 1n) returns 1n'); -assert.sameValue(Atomics.load(i64a, 0), 0n, 'Atomics.load(i64a, 0) returns 0n'); +testWithBigIntTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); + const view = new TA(buffer); + assert.sameValue(Atomics.store(view, 0, 1n), 1n, 'Atomics.store(view, 0, 1n) returns 1n'); + assert.sameValue(Atomics.sub(view, 0, 1n), 1n, 'Atomics.sub(view, 0, 1n) returns 1n'); + assert.sameValue(Atomics.load(view, 0), 0n, 'Atomics.load(view, 0) returns 0n'); +}); diff --git a/test/built-ins/Atomics/sub/bigint/non-shared-int-views-throws.js b/test/built-ins/Atomics/sub/bigint/non-shared-int-views-throws.js deleted file mode 100644 index 6d37e182ae..0000000000 --- a/test/built-ins/Atomics/sub/bigint/non-shared-int-views-throws.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-atomics.sub -description: > - Atomics.sub throws when operating on non-sharable integer TypedArrays -includes: [testBigIntTypedArray.js] -features: [ArrayBuffer, Atomics, BigInt, TypedArray] ----*/ -const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableBigIntTypedArrayConstructors(function(TA) { - const view = new TA(buffer); - - assert.throws(TypeError, function() { - Atomics.sub(view, 0, 1n); - }, `Atomics.sub(new ${TA.name}(buffer), 0, 1n) throws TypeError`); -}); diff --git a/test/built-ins/Atomics/sub/non-shared-bufferdata.js b/test/built-ins/Atomics/sub/non-shared-bufferdata.js index 19413d5afc..2bd71d45ba 100644 --- a/test/built-ins/Atomics/sub/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/sub/non-shared-bufferdata.js @@ -5,14 +5,15 @@ esid: sec-atomics.sub description: > Atomics.sub will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ +testWithAtomicsFriendlyTypedArrayConstructors(TA => { + const view = new TA( + new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) + ); -const i32a = new Int32Array( - new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) -); - -assert.sameValue(Atomics.store(i32a, 0, 1), 1, 'Atomics.store(i32a, 0, 1) returns 1'); -assert.sameValue(Atomics.sub(i32a, 0, 1), 0, 'Atomics.sub(i32a, 0, 1) returns 0'); -assert.sameValue(Atomics.load(i32a, 0), 0, 'Atomics.load(i32a, 0) returns 0'); - + assert.sameValue(Atomics.store(view, 0, 1), 1, 'Atomics.store(view, 0, 1) returns 1'); + assert.sameValue(Atomics.sub(view, 0, 1), 0, 'Atomics.sub(view, 0, 1) returns 0'); + assert.sameValue(Atomics.load(view, 0), 0, 'Atomics.load(view, 0) returns 0'); +}); diff --git a/test/built-ins/Atomics/sub/non-shared-int-views-throws.js b/test/built-ins/Atomics/sub/non-shared-int-views-throws.js index eca79c4d35..e0cbe55ef3 100644 --- a/test/built-ins/Atomics/sub/non-shared-int-views-throws.js +++ b/test/built-ins/Atomics/sub/non-shared-int-views-throws.js @@ -8,10 +8,8 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ - -const buffer = new ArrayBuffer(16); - -testWithNonShareableTypedArrayConstructors(function(TA) { +testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(16); const view = new TA(buffer); assert.throws(TypeError, function() { diff --git a/test/built-ins/Atomics/xor/bigint/non-shared-bufferdata.js b/test/built-ins/Atomics/xor/bigint/non-shared-bufferdata.js index 49a9cee62a..d8ce71761c 100644 --- a/test/built-ins/Atomics/xor/bigint/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/xor/bigint/non-shared-bufferdata.js @@ -4,8 +4,12 @@ esid: sec-atomics.xor description: > Atomics.xor will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testBigIntTypedArray.js] features: [ArrayBuffer, Atomics, BigInt, TypedArray] ---*/ -const i64a = new BigInt64Array(new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)); -assert.sameValue(Atomics.xor(i64a, 0, 1n), 0n, 'Atomics.xor(i64a, 0, 1n) returns 0n'); -assert.sameValue(Atomics.load(i64a, 0), 1n, 'Atomics.load(i64a, 0) returns 1n'); +testWithBigIntTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); + const view = new TA(buffer); + assert.sameValue(Atomics.xor(view, 0, 1n), 0n, 'Atomics.xor(view, 0, 1n) returns 0n'); + assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n'); +}); diff --git a/test/built-ins/Atomics/xor/bigint/non-shared-int-views-throws.js b/test/built-ins/Atomics/xor/bigint/non-shared-int-views-throws.js deleted file mode 100644 index 1b95ff40dd..0000000000 --- a/test/built-ins/Atomics/xor/bigint/non-shared-int-views-throws.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-atomics.xor -description: > - Atomics.xor throws when operating on non-sharable integer TypedArrays -includes: [testBigIntTypedArray.js] -features: [ArrayBuffer, Atomics, BigInt, TypedArray] ----*/ -const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableBigIntTypedArrayConstructors(function(TA) { - const view = new TA(buffer); - - assert.throws(TypeError, function() { - Atomics.xor(view, 0, 1n); - }, `Atomics.xor(new ${TA.name}(buffer), 0, 1n) throws TypeError`); -}); diff --git a/test/built-ins/Atomics/xor/non-shared-bufferdata.js b/test/built-ins/Atomics/xor/non-shared-bufferdata.js index ebd8a666b1..3ded3c8b85 100644 --- a/test/built-ins/Atomics/xor/non-shared-bufferdata.js +++ b/test/built-ins/Atomics/xor/non-shared-bufferdata.js @@ -5,13 +5,14 @@ esid: sec-atomics.and description: > Atomics.and will operate on TA when TA.buffer is not a SharedArrayBuffer +includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ +testWithAtomicsFriendlyTypedArrayConstructors(TA => { + const view = new TA( + new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4) + ); -const i32a = new Int32Array( - new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) -); - -assert.sameValue(Atomics.and(i32a, 0, 1), 0, 'Atomics.and(i32a, 0, 1) returns 0'); -assert.sameValue(Atomics.load(i32a, 0), 0, 'Atomics.load(i32a, 0) returns 0'); - + assert.sameValue(Atomics.and(view, 0, 1), 0, 'Atomics.and(view, 0, 1) returns 0'); + assert.sameValue(Atomics.load(view, 0), 0, 'Atomics.load(view, 0) returns 0'); +}); diff --git a/test/built-ins/Atomics/xor/non-shared-int-views-throws.js b/test/built-ins/Atomics/xor/non-shared-int-views-throws.js index 4194c9c556..b8379deaa9 100644 --- a/test/built-ins/Atomics/xor/non-shared-int-views-throws.js +++ b/test/built-ins/Atomics/xor/non-shared-int-views-throws.js @@ -8,10 +8,8 @@ description: > includes: [testTypedArray.js] features: [ArrayBuffer, Atomics, TypedArray] ---*/ - -const buffer = new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4); - -testWithNonShareableTypedArrayConstructors(function(TA) { +testWithNonAtomicsFriendlyTypedArrayConstructors(TA => { + const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4); const view = new TA(buffer); assert.throws(TypeError, function() {