Atomics.and will operate on TA when TA.buffer is not a SharedArrayBuffer

This commit is contained in:
Rick Waldron 2020-05-13 13:25:01 -04:00
parent b4517aa192
commit f82e09bab0
5 changed files with 59 additions and 22 deletions

View File

@ -0,0 +1,16 @@
// 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 will operate on TA when TA.buffer is not a SharedArrayBuffer
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
const i64a = new BigInt64Array(
new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
);
assert.sameValue(Atomics.and(i64a, 0, 1n), 0n);
assert.sameValue(Atomics.load(i64a, 0), 1n);

View File

@ -0,0 +1,19 @@
// Copyright (C) 2020 Mozilla Corporation. 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, 1);
}, `Atomics.and(new ${TA.name}(view), 0, 1) throws TypeError`);
});

View File

@ -1,16 +0,0 @@
// Copyright (C) 2018 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.and
description: >
Test Atomics.and on non-shared integer TypedArrays
includes: [testBigIntTypedArray.js]
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
---*/
const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() {
Atomics.and(new TA(buffer), 0, 0n);
}, '`Atomics.and(new TA(buffer), 0, 0n)` throws TypeError');
});

View File

@ -0,0 +1,17 @@
// 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 will operate on TA when TA.buffer is not a SharedArrayBuffer
features: [ArrayBuffer, Atomics, TypedArray]
---*/
const i32a = new Int32Array(
new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
);
assert.sameValue(Atomics.and(i32a, 0, 1), 0);
assert.sameValue(Atomics.load(i32a, 0), 0);

View File

@ -4,16 +4,17 @@
/*---
esid: sec-atomics.and
description: >
Test Atomics.and on non-shared integer TypedArrays
Atomics.and throws when operating on non-sharable integer TypedArrays
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
const buffer = new ArrayBuffer(16);
const views = intArrayConstructors.slice();
testWithTypedArrayConstructors(function(TA) {
testWithNonSharableTypedArrayConstructors(function(TA) {
const view = new TA(buffer);
assert.throws(TypeError, function() {
Atomics.and(new TA(buffer), 0, 0);
}, '`Atomics.and(new TA(buffer), 0, 0)` throws TypeError');
}, views);
Atomics.and(view, 0, 1);
}, `Atomics.and(new ${TA.name}(view), 0, 1) throws TypeError`);
});