mirror of https://github.com/tc39/test262.git
Atomics.exchange will operate on TA when TA.buffer is not a SharedArrayBuffer
This commit is contained in:
parent
eb5120a1e9
commit
1f977dc9fc
|
@ -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.exchange
|
||||
description: >
|
||||
Atomics.exchange 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.exchange(i64a, 0, 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.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}(view), 0, 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.exchange
|
||||
description: >
|
||||
Test Atomics.exchange on non-shared integer TypedArrays
|
||||
includes: [testBigIntTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
var buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.exchange(new TA(buffer), 0n, 0n);
|
||||
}, '`Atomics.exchange(new TA(buffer), 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.exchange
|
||||
description: >
|
||||
Atomics.exchange 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.exchange(i32a, 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.add
|
||||
description: >
|
||||
Atomics.add 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.add(view, 0, 1);
|
||||
}, `Atomics.add(new ${TA.name}(view), 0, 1) throws TypeError`);
|
||||
});
|
Loading…
Reference in New Issue