Atomics: corrections

This commit is contained in:
Rick Waldron 2020-05-27 15:00:02 -04:00
parent 7e603ae236
commit 529cff8ee6
41 changed files with 172 additions and 307 deletions

View File

@ -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]);
}

View File

@ -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
]);
}

View File

@ -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');
});

View File

@ -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`);
});

View File

@ -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');
});

View File

@ -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() {

View File

@ -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');
});

View File

@ -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`);
});

View File

@ -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');
});

View File

@ -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() {

View File

@ -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');
});

View File

@ -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`);
});

View File

@ -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');
});

View File

@ -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() {

View File

@ -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');
});

View File

@ -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`);
});

View File

@ -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');
});

View File

@ -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`);

View File

@ -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');
});

View File

@ -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`);
});

View File

@ -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');
});

View File

@ -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);

View File

@ -31,5 +31,3 @@ const poisoned = {
assert.throws(Test262Error, function() {
Atomics.notify(i64a, poisoned, 0);
}, '`Atomics.notify(i64a, poisoned, 0)` throws Test262Error');

View File

@ -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);

View File

@ -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');
});

View File

@ -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`);
});

View File

@ -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');
});

View File

@ -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() {

View File

@ -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) {

View File

@ -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');
});

View File

@ -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`);
});

View File

@ -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');
});

View File

@ -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() {

View File

@ -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');
});

View File

@ -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`);
});

View File

@ -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');
});

View File

@ -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() {

View File

@ -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');
});

View File

@ -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`);
});

View File

@ -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');
});

View File

@ -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() {