1
0
mirror of https://github.com/tc39/test262.git synced 2025-04-08 19:35:28 +02:00

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

This commit is contained in:
Rick Waldron 2020-05-13 13:59:57 -04:00
parent f82e09bab0
commit eb5120a1e9
6 changed files with 72 additions and 35 deletions

@ -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.compareExchange
description: >
Atomics.compareExchange 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.compareExchange(i64a, 0, 0n, 1n), 0n);
assert.sameValue(Atomics.load(i64a, 0), 1n);

@ -0,0 +1,19 @@
// 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}(view), 0, 0n, 0n) throws TypeError`);
});

@ -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.compareexchange
description: >
Test Atomics.compareExchange 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.compareExchange(new TA(buffer), 0, 0n, 0n);
}, '`Atomics.compareExchange(new TA(buffer), 0, 0n, 0n)` throws TypeError');
});

@ -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.compareExchange
description: >
Atomics.compareExchange 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.compareExchange(i32a, 0, 0, 1), 0);
assert.sameValue(Atomics.load(i32a, 0), 1);

@ -0,0 +1,20 @@
// Copyright (C) 2017 Mozilla Corporation. 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: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
const buffer = new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4);
testWithNonSharableTypedArrayConstructors(function(TA) {
const view = new TA(buffer);
assert.throws(TypeError, function() {
Atomics.compareExchange(view, 0, 0, 0);
}, `Atomics.compareExchange(new ${TA.name}(view), 0, 0, 0) throws TypeError`);
});

@ -1,19 +0,0 @@
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.compareexchange
description: >
Test Atomics.compareExchange on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
var buffer = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() {
Atomics.compareExchange(new TA(buffer), 0, 0, 0);
}, '`Atomics.compareExchange(new TA(buffer), 0, 0, 0)` throws TypeError');
}, views);