mirror of https://github.com/tc39/test262.git
Atomics.sub will operate on TA when TA.buffer is not a SharedArrayBuffer
This commit is contained in:
parent
5e43594d44
commit
e4d24694ea
|
@ -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.sub
|
||||
description: >
|
||||
Atomics.sub 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.store(i64a, 0, 1n), 1n);
|
||||
assert.sameValue(Atomics.sub(i64a, 0, 1n), 1n);
|
||||
assert.sameValue(Atomics.load(i64a, 0), 0n);
|
|
@ -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.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`);
|
||||
});
|
|
@ -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.sub
|
||||
description: >
|
||||
Test Atomics.sub 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.sub(new TA(buffer), 0, 0n);
|
||||
}, '`Atomics.sub(new TA(buffer), 0, 0n)` throws TypeError');
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
// 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 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.store(i32a, 0, 1), 1);
|
||||
assert.sameValue(Atomics.sub(i32a, 0, 1), 0);
|
||||
assert.sameValue(Atomics.load(i32a, 0), 0);
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// 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: [testTypedArray.js]
|
||||
features: [ArrayBuffer, Atomics, TypedArray]
|
||||
---*/
|
||||
|
||||
const buffer = new ArrayBuffer(16);
|
||||
|
||||
testWithNonSharableTypedArrayConstructors(function(TA) {
|
||||
const view = new TA(buffer);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.sub(view, 0, 1);
|
||||
}, `Atomics.sub(new ${TA.name}(buffer), 0, 1) 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.sub
|
||||
description: >
|
||||
Test Atomics.sub on non-shared integer TypedArrays
|
||||
includes: [testTypedArray.js]
|
||||
features: [ArrayBuffer, Atomics, TypedArray]
|
||||
---*/
|
||||
|
||||
const buffer = new ArrayBuffer(16);
|
||||
const views = intArrayConstructors.slice();
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.sub(new TA(buffer), 0, 0);
|
||||
}, '`Atomics.sub(new TA(buffer), 0, 0)` throws TypeError');
|
||||
}, views);
|
Loading…
Reference in New Issue