mirror of
https://github.com/tc39/test262.git
synced 2025-07-28 16:34:27 +02:00
Atomics: fixes to bigint variants; updated assertion messages
This commit is contained in:
parent
c29ae8effb
commit
e164657a2b
@ -14,7 +14,11 @@ includes: [propertyHelper.js]
|
|||||||
features: [Atomics, Symbol, Symbol.toStringTag]
|
features: [Atomics, Symbol, Symbol.toStringTag]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(Atomics[Symbol.toStringTag], 'Atomics');
|
assert.sameValue(
|
||||||
|
Atomics[Symbol.toStringTag],
|
||||||
|
'Atomics',
|
||||||
|
'The value of Atomics[Symbol.toStringTag] is "Atomics"'
|
||||||
|
);
|
||||||
|
|
||||||
verifyNotEnumerable(Atomics, Symbol.toStringTag);
|
verifyNotEnumerable(Atomics, Symbol.toStringTag);
|
||||||
verifyNotWritable(Atomics, Symbol.toStringTag);
|
verifyNotWritable(Atomics, Symbol.toStringTag);
|
||||||
|
@ -9,14 +9,14 @@ includes: [testAtomics.js, testTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
const buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
let view = new TA(buffer);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.add(view, IdxGen(view), 10);
|
Atomics.add(view, IdxGen(view), 10);
|
||||||
}, 'Atomics.add(view, IdxGen(view), 10) throws RangeError');
|
}, '`Atomics.add(view, IdxGen(view), 10)` throws RangeError');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.add
|
esid: sec-atomics.add
|
||||||
description: >
|
description: >
|
||||||
@ -8,14 +7,14 @@ description: >
|
|||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
var buffer = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
let view = new TA(buffer);
|
||||||
|
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.add(view, IdxGen(view), 10);
|
Atomics.add(view, IdxGen(view), 10n);
|
||||||
}, 'Atomics.add(view, IdxGen(view), 10) throws RangeError');
|
}, '`Atomics.add(view, IdxGen(view), 10n)` throws RangeError');
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,53 +1,53 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.add
|
esid: sec-atomics.add
|
||||||
description: Test Atomics.add on arrays that allow atomic operations.
|
description: Test Atomics.add on arrays that allow atomic operations.
|
||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const ab = new ArrayBuffer(16);
|
||||||
var ab = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
const view = new TA(sab, 32, 20);
|
||||||
|
const control = new TA(ab, 0, 2);
|
||||||
|
view[8] = 0n;
|
||||||
|
assert.sameValue(Atomics.add(view, 8, 10n), 0, 'Atomics.add(view, 8, 10n) returns 0');
|
||||||
|
assert.sameValue(view[8], 10n, 'The value of view[8] is 10n');
|
||||||
|
assert.sameValue(Atomics.add(view, 8, -5n), 10n, 'Atomics.add(view, 8, -5n) returns 10n');
|
||||||
|
assert.sameValue(view[8], 5n, 'The value of view[8] is 5n');
|
||||||
|
view[3] = -5n;
|
||||||
|
control[0] = -5n;
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
assert.sameValue(
|
||||||
var control = new TA(ab, 0, 2);
|
Atomics.add(view, 3, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.add(view, 3, 0n) returns the value of `control[0]` (-5n)'
|
||||||
|
);
|
||||||
|
|
||||||
// Add positive number
|
control[0] = 12345n;
|
||||||
view[8] = 0;
|
view[3] = 12345n;
|
||||||
assert.sameValue(Atomics.add(view, 8, 10), 0, 'Atomics.add(view, 8, 10) returns 0');
|
|
||||||
assert.sameValue(view[8], 10, 'The value of view[8] is 10');
|
|
||||||
|
|
||||||
// Add negative number
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.add(view, 8, -5), 10, 'Atomics.add(view, 8, -5) returns 10');
|
Atomics.add(view, 3, 0n),
|
||||||
assert.sameValue(view[8], 5, 'The value of view[8] is 5');
|
control[0],
|
||||||
|
'Atomics.add(view, 3, 0n) returns the value of `control[0]` (12345n)'
|
||||||
|
);
|
||||||
|
|
||||||
view[3] = -5;
|
control[0] = 123456789n;
|
||||||
control[0] = -5;
|
view[3] = 123456789n;
|
||||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
|
||||||
'Atomics.add(view, 3, 0) equals the value of control[0] (-5)');
|
|
||||||
|
|
||||||
control[0] = 12345;
|
assert.sameValue(
|
||||||
view[3] = 12345;
|
Atomics.add(view, 3, 0n),
|
||||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
control[0],
|
||||||
'Atomics.add(view, 3, 0) equals the value of control[0] (12345)');
|
'Atomics.add(view, 3, 0n) returns the value of `control[0]` (123456789n)'
|
||||||
|
);
|
||||||
|
|
||||||
control[0] = 123456789;
|
|
||||||
view[3] = 123456789;
|
|
||||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
|
||||||
'Atomics.add(view, 3, 0) equals the value of control[0] (123456789)');
|
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
Atomics.store(view, Idx, 37n);
|
||||||
// Atomics operations, not quite like view[Idx].
|
assert.sameValue(Atomics.add(view, Idx, 0), 37n, 'Atomics.add(view, Idx, 0) returns 37n');
|
||||||
Atomics.store(view, Idx, 37);
|
|
||||||
assert.sameValue(Atomics.add(view, Idx, 0), 37, 'Atomics.add(view, Idx, 0) returns 37');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.add
|
esid: sec-atomics.add
|
||||||
description: >
|
description: >
|
||||||
@ -8,11 +7,10 @@ description: >
|
|||||||
includes: [testBigIntTypedArray.js]
|
includes: [testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
var ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var ab = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.add(new TA(ab), 0, 0);
|
Atomics.add(new TA(ab), 0, 0n);
|
||||||
}, 'Atomics.add(new TA(ab), 0, 0) throws TypeError');
|
}, '`Atomics.add(new TA(ab), 0, 0n)` throws TypeError');
|
||||||
});
|
});
|
@ -27,9 +27,10 @@ info: |
|
|||||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4);
|
const i32a = new Int32Array(
|
||||||
var i32a = new Int32Array(buffer);
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
var newValue = 0b00000001000000001000000010000001;
|
);
|
||||||
|
const newValue = 0b00000001000000001000000010000001;
|
||||||
|
|
||||||
assert.sameValue(Atomics.add(i32a, 0, newValue), 0, 'Atomics.add(i32a, 0, newValue) returns 0');
|
assert.sameValue(Atomics.add(i32a, 0, newValue), 0, 'Atomics.add(i32a, 0, newValue) returns 0');
|
||||||
assert.sameValue(i32a[0], newValue, 'The value of i32a[0] equals the value of newValue (0b00000001000000001000000010000001)');
|
assert.sameValue(i32a[0], newValue, 'The value of i32a[0] equals the value of `newValue` (0b00000001000000001000000010000001)');
|
||||||
|
@ -8,15 +8,15 @@ includes: [testAtomics.js, testTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var ab = new ArrayBuffer(16);
|
const ab = new ArrayBuffer(16);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
const view = new TA(sab, 32, 20);
|
||||||
var control = new TA(ab, 0, 2);
|
const control = new TA(ab, 0, 2);
|
||||||
|
|
||||||
// Add positive number
|
// Add positive number
|
||||||
view[8] = 0;
|
view[8] = 0;
|
||||||
@ -30,17 +30,17 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
||||||
'Atomics.add(view, 3, 0) equals the value of control[0] (-5)');
|
'Atomics.add(view, 3, 0) returns the value of `control[0]` (-5)');
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
||||||
'Atomics.add(view, 3, 0) equals the value of control[0] (12345)');
|
'Atomics.add(view, 3, 0) returns the value of `control[0]` (12345)');
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
assert.sameValue(Atomics.add(view, 3, 0), control[0],
|
||||||
'Atomics.add(view, 3, 0) equals the value of control[0] (123456789)');
|
'Atomics.add(view, 3, 0) returns the value of `control[0]` (123456789)');
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
|
@ -12,5 +12,5 @@ features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedAr
|
|||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.add(view, 0, 0);
|
Atomics.add(view, 0, 0);
|
||||||
}, 'Atomics.add(view, 0, 0) throws TypeError');
|
}, '`Atomics.add(view, 0, 0)` throws TypeError');
|
||||||
});
|
});
|
||||||
|
@ -9,11 +9,11 @@ includes: [testTypedArray.js]
|
|||||||
features: [ArrayBuffer, Atomics, TypedArray]
|
features: [ArrayBuffer, Atomics, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var ab = new ArrayBuffer(16);
|
const ab = new ArrayBuffer(16);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.add(new TA(ab), 0, 0);
|
Atomics.add(new TA(ab), 0, 0);
|
||||||
}, 'Atomics.add(new TA(ab), 0, 0) throws TypeError');
|
}, '`Atomics.add(new TA(ab), 0, 0)` throws TypeError');
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -9,10 +9,10 @@ includes: [testTypedArray.js]
|
|||||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(1024);
|
const buffer = new SharedArrayBuffer(1024);
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.add(new TA(buffer), 0, 0);
|
Atomics.add(new TA(buffer), 0, 0);
|
||||||
}, 'Atomics.add(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.add(new TA(buffer), 0, 0)` throws TypeError');
|
||||||
}, floatArrayConstructors);
|
}, floatArrayConstructors);
|
||||||
|
@ -9,14 +9,14 @@ includes: [testAtomics.js, testTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
const buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
const view = new TA(buffer);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.and(view, IdxGen(view), 10);
|
Atomics.and(view, IdxGen(view), 10);
|
||||||
}, 'Atomics.and(view, IdxGen(view), 10) throws RangeError');
|
}, '`Atomics.and(view, IdxGen(view), 10)` throws RangeError');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.and
|
esid: sec-atomics.and
|
||||||
description: >
|
description: >
|
||||||
@ -8,14 +7,14 @@ description: >
|
|||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const buffer = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
const view = new TA(buffer);
|
||||||
|
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.and(view, IdxGen(view), 10);
|
Atomics.and(view, IdxGen(view), 10n);
|
||||||
}, 'Atomics.and(view, IdxGen(view), 10) throws RangeError');
|
}, '`Atomics.and(view, IdxGen(view), 10n)` throws RangeError');
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,68 +1,83 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.and
|
esid: sec-atomics.and
|
||||||
description: Test Atomics.and on arrays that allow atomic operations
|
description: Test Atomics.and on arrays that allow atomic operations
|
||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var ab = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
const view = new TA(sab, 32, 20);
|
||||||
|
const control = new TA(ab, 0, 2);
|
||||||
|
view[8] = 0x33333333n;
|
||||||
|
control[0] = 0x33333333n;
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
assert.sameValue(
|
||||||
var control = new TA(ab, 0, 2);
|
Atomics.and(view, 8, 0x55555555n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.and(view, 8, 0x55555555n) returns the value of `control[0]` (0x33333333n)'
|
||||||
|
);
|
||||||
|
|
||||||
view[8] = 0x33333333;
|
control[0] = 0x11111111n;
|
||||||
control[0] = 0x33333333;
|
|
||||||
assert.sameValue(Atomics.and(view, 8, 0x55555555), control[0],
|
|
||||||
'Atomics.and(view, 8, 0x55555555) equals the value of control[0] (0x33333333)');
|
|
||||||
|
|
||||||
control[0] = 0x11111111;
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
view[8],
|
view[8],
|
||||||
control[0],
|
control[0],
|
||||||
'The value of view[8] equals the value of control[0] (0x11111111)'
|
'The value of view[8] equals the value of `control[0]` (0x11111111n)'
|
||||||
);
|
);
|
||||||
assert.sameValue(Atomics.and(view, 8, 0xF0F0F0F0), control[0],
|
|
||||||
'Atomics.and(view, 8, 0xF0F0F0F0) equals the value of control[0] (0x11111111)');
|
|
||||||
|
|
||||||
control[0] = 0x10101010;
|
assert.sameValue(
|
||||||
|
Atomics.and(view, 8, 0xF0F0F0F0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.and(view, 8, 0xF0F0F0F0n) returns the value of `control[0]` (0x11111111n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
control[0] = 0x10101010n;
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
view[8],
|
view[8],
|
||||||
control[0],
|
control[0],
|
||||||
'The value of view[8] equals the value of control[0] (0x10101010)'
|
'The value of view[8] equals the value of `control[0]` (0x10101010n)'
|
||||||
);
|
);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5n;
|
||||||
control[0] = -5;
|
control[0] = -5n;
|
||||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
|
||||||
'Atomics.and(view, 3, 0) equals the value of control[0] (-5)');
|
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
|
||||||
|
|
||||||
control[0] = 12345;
|
assert.sameValue(
|
||||||
view[3] = 12345;
|
Atomics.and(view, 3, 0n),
|
||||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
control[0],
|
||||||
'Atomics.and(view, 3, 0) equals the value of control[0] (12345)');
|
'Atomics.and(view, 3, 0n) returns the value of `control[0]` (-5n)'
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
);
|
||||||
|
|
||||||
control[0] = 123456789;
|
assert.sameValue(view[3], 0n, 'The value of view[3] is 0n');
|
||||||
view[3] = 123456789;
|
control[0] = 12345n;
|
||||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
view[3] = 12345n;
|
||||||
'Atomics.and(view, 3, 0) equals the value of control[0] (123456789)');
|
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
assert.sameValue(
|
||||||
|
Atomics.and(view, 3, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.and(view, 3, 0n) returns the value of `control[0]` (12345n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(view[3], 0n, 'The value of view[3] is 0n');
|
||||||
|
control[0] = 123456789n;
|
||||||
|
view[3] = 123456789n;
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.and(view, 3, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.and(view, 3, 0n) returns the value of `control[0]` (123456789n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(view[3], 0n, 'The value of view[3] is 0n');
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0n);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
Atomics.store(view, Idx, 37n);
|
||||||
// Atomics operations, not quite like view[Idx].
|
assert.sameValue(Atomics.and(view, Idx, 0n), 37n, 'Atomics.and(view, Idx, 0n) returns 37n');
|
||||||
Atomics.store(view, Idx, 37);
|
|
||||||
assert.sameValue(Atomics.and(view, Idx, 0), 37, 'Atomics.and(view, Idx, 0) returns 37');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.and
|
esid: sec-atomics.and
|
||||||
description: >
|
description: >
|
||||||
@ -8,11 +7,10 @@ description: >
|
|||||||
includes: [testBigIntTypedArray.js]
|
includes: [testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.and(new TA(buffer), 0, 0);
|
Atomics.and(new TA(buffer), 0, 0n);
|
||||||
}, 'Atomics.and(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.and(new TA(buffer), 0, 0n)` throws TypeError');
|
||||||
});
|
});
|
@ -27,18 +27,19 @@ info: |
|
|||||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4);
|
const i32a = new Int32Array(
|
||||||
var i32a = new Int32Array(buffer);
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
var initial = 0b00000001000000001000000010000001;
|
);
|
||||||
var other = 0b00000001111111111000000011111111;
|
const a = 0b00000001000000001000000010000001;
|
||||||
var anded = 0b00000001000000001000000010000001;
|
const b = 0b00000001111111111000000011111111;
|
||||||
|
const c = 0b00000001000000001000000010000001;
|
||||||
|
|
||||||
i32a[0] = initial;
|
i32a[0] = a;
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.and(i32a, 0, other),
|
Atomics.and(i32a, 0, b),
|
||||||
initial,
|
a,
|
||||||
'Atomics.and(i32a, 0, other) equals the value of `initial` (0b00000001000000001000000010000001)'
|
'Atomics.and(i32a, 0, b) returns the value of `a` (0b00000001000000001000000010000001)'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(i32a[0], anded, 'The value of i32a[0] equals the value of `anded` (0b00000001000000001000000010000001)');
|
assert.sameValue(i32a[0], c, 'The value of i32a[0] equals the value of `c` (0b00000001000000001000000010000001)');
|
||||||
|
@ -8,53 +8,53 @@ includes: [testAtomics.js, testTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var ab = new ArrayBuffer(16);
|
const ab = new ArrayBuffer(16);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
const view = new TA(sab, 32, 20);
|
||||||
var control = new TA(ab, 0, 2);
|
const control = new TA(ab, 0, 2);
|
||||||
|
|
||||||
view[8] = 0x33333333;
|
view[8] = 0x33333333;
|
||||||
control[0] = 0x33333333;
|
control[0] = 0x33333333;
|
||||||
assert.sameValue(Atomics.and(view, 8, 0x55555555), control[0],
|
assert.sameValue(Atomics.and(view, 8, 0x55555555), control[0],
|
||||||
'Atomics.and(view, 8, 0x55555555) equals the value of control[0] (0x33333333)');
|
'Atomics.and(view, 8, 0x55555555) returns the value of `control[0]` (0x33333333)');
|
||||||
|
|
||||||
control[0] = 0x11111111;
|
control[0] = 0x11111111;
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
view[8],
|
view[8],
|
||||||
control[0],
|
control[0],
|
||||||
'The value of view[8] equals the value of control[0] (0x11111111)'
|
'The value of view[8] equals the value of `control[0]` (0x11111111)'
|
||||||
);
|
);
|
||||||
assert.sameValue(Atomics.and(view, 8, 0xF0F0F0F0), control[0],
|
assert.sameValue(Atomics.and(view, 8, 0xF0F0F0F0), control[0],
|
||||||
'Atomics.and(view, 8, 0xF0F0F0F0) equals the value of control[0] (0x11111111)');
|
'Atomics.and(view, 8, 0xF0F0F0F0) returns the value of `control[0]` (0x11111111)');
|
||||||
|
|
||||||
control[0] = 0x10101010;
|
control[0] = 0x10101010;
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
view[8],
|
view[8],
|
||||||
control[0],
|
control[0],
|
||||||
'The value of view[8] equals the value of control[0] (0x10101010)'
|
'The value of view[8] equals the value of `control[0]` (0x10101010)'
|
||||||
);
|
);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
||||||
'Atomics.and(view, 3, 0) equals the value of control[0] (-5)');
|
'Atomics.and(view, 3, 0) returns the value of `control[0]` (-5)');
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
||||||
'Atomics.and(view, 3, 0) equals the value of control[0] (12345)');
|
'Atomics.and(view, 3, 0) returns the value of `control[0]` (12345)');
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
assert.sameValue(Atomics.and(view, 3, 0), control[0],
|
||||||
'Atomics.and(view, 3, 0) equals the value of control[0] (123456789)');
|
'Atomics.and(view, 3, 0) returns the value of `control[0]` (123456789)');
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
|
@ -12,5 +12,5 @@ features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedAr
|
|||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.and(view, 0, 0);
|
Atomics.and(view, 0, 0);
|
||||||
}, 'Atomics.and(view, 0, 0) throws TypeError');
|
}, '`Atomics.and(view, 0, 0)` throws TypeError');
|
||||||
});
|
});
|
||||||
|
@ -9,11 +9,11 @@ includes: [testTypedArray.js]
|
|||||||
features: [ArrayBuffer, Atomics, TypedArray]
|
features: [ArrayBuffer, Atomics, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new ArrayBuffer(16);
|
const buffer = new ArrayBuffer(16);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.and(new TA(buffer), 0, 0);
|
Atomics.and(new TA(buffer), 0, 0);
|
||||||
}, 'Atomics.and(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.and(new TA(buffer), 0, 0)` throws TypeError');
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -9,10 +9,10 @@ includes: [testTypedArray.js]
|
|||||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(1024);
|
const buffer = new SharedArrayBuffer(1024);
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.and(new TA(buffer), 0, 0);
|
Atomics.and(new TA(buffer), 0, 0);
|
||||||
}, 'Atomics.and(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.and(new TA(buffer), 0, 0)` throws TypeError');
|
||||||
}, floatArrayConstructors);
|
}, floatArrayConstructors);
|
||||||
|
@ -9,14 +9,14 @@ includes: [testAtomics.js, testTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
const buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
const view = new TA(buffer);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.compareExchange(view, IdxGen(view), 10, 0);
|
Atomics.compareExchange(view, IdxGen(view), 10, 0);
|
||||||
}, 'Atomics.compareExchange(view, IdxGen(view), 10, 0) throws RangeError');
|
}, '`Atomics.compareExchange(view, IdxGen(view), 10, 0)` throws RangeError');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.compareexchange
|
esid: sec-atomics.compareexchange
|
||||||
description: >
|
description: >
|
||||||
@ -8,14 +7,14 @@ description: >
|
|||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const buffer = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
const view = new TA(buffer);
|
||||||
|
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.compareExchange(view, IdxGen(view), 10, 0);
|
Atomics.compareExchange(view, IdxGen(view), 10, 0n);
|
||||||
}, 'Atomics.compareExchange(view, IdxGen(view), 10, 0) throws RangeError');
|
}, '`Atomics.compareExchange(view, IdxGen(view), 10, 0n)` throws RangeError');
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,73 +1,91 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.compareexchange
|
esid: sec-atomics.compareexchange
|
||||||
description: Test Atomics.compareExchange on arrays that allow atomic operations.
|
description: Test Atomics.compareExchange on arrays that allow atomic operations.
|
||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var ab = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
const view = new TA(sab, 32, 20);
|
||||||
|
const control = new TA(ab, 0, 2);
|
||||||
|
view[8] = 0n;
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
|
||||||
var control = new TA(ab, 0, 2);
|
|
||||||
|
|
||||||
// Performs the exchange
|
|
||||||
view[8] = 0;
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.compareExchange(view, 8, 0, 10),
|
Atomics.compareExchange(view, 8, 0n, 10n),
|
||||||
0,
|
0n,
|
||||||
'Atomics.compareExchange(view, 8, 0, 10) returns 0'
|
'Atomics.compareExchange(view, 8, 0n, 10n) returns 0n'
|
||||||
);
|
);
|
||||||
assert.sameValue(view[8], 10, 'The value of view[8] is 10');
|
|
||||||
|
|
||||||
view[8] = 0;
|
assert.sameValue(view[8], 10n, 'The value of view[8] is 10n');
|
||||||
assert.sameValue(Atomics.compareExchange(view, 8, 1, 10), 0,
|
view[8] = 0n;
|
||||||
'Atomics.compareExchange(view, 8, 1, 10) returns 0');
|
|
||||||
assert.sameValue(view[8], 0, 'The value of view[8] is 0');
|
|
||||||
|
|
||||||
view[8] = 0;
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.compareExchange(view, 8, 0, -5), 0,
|
Atomics.compareExchange(view, 8, 1n, 10n),
|
||||||
'Atomics.compareExchange(view, 8, 0, -5) returns 0');
|
0n,
|
||||||
control[0] = -5;
|
'Atomics.compareExchange(view, 8, 1n, 10n) returns 0n'
|
||||||
assert.sameValue(view[8], control[0], 'The value of view[8] equals the value of control[0] (-5)');
|
);
|
||||||
|
|
||||||
|
assert.sameValue(view[8], 0n, 'The value of view[8] is 0n');
|
||||||
|
view[8] = 0n;
|
||||||
|
|
||||||
view[3] = -5;
|
assert.sameValue(
|
||||||
control[0] = -5;
|
Atomics.compareExchange(view, 8, 0n, -5n),
|
||||||
assert.sameValue(Atomics.compareExchange(view, 3, -5, 0), control[0],
|
0n,
|
||||||
'Atomics.compareExchange(view, 3, -5, 0) equals the value of control[0] (-5)');
|
'Atomics.compareExchange(view, 8, 0n, -5n) returns 0n'
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
);
|
||||||
|
|
||||||
|
control[0] = -5n;
|
||||||
|
|
||||||
control[0] = 12345;
|
assert.sameValue(
|
||||||
view[3] = 12345;
|
view[8],
|
||||||
assert.sameValue(Atomics.compareExchange(view, 3, 12345, 0), control[0],
|
control[0],
|
||||||
'Atomics.compareExchange(view, 3, 12345, 0) equals the value of control[0] (12345)');
|
'The value of view[8] equals the value of `control[0]` (-5n)'
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
);
|
||||||
|
|
||||||
control[0] = 123456789;
|
view[3] = -5n;
|
||||||
view[3] = 123456789;
|
control[0] = -5n;
|
||||||
assert.sameValue(Atomics.compareExchange(view, 3, 123456789, 0), control[0],
|
|
||||||
'Atomics.compareExchange(view, 3, 123456789, 0) equals the value of control[0] (123456789)');
|
assert.sameValue(
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
Atomics.compareExchange(view, 3, -5n, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.compareExchange(view, 3, -5n, 0n) returns the value of `control[0]` (-5n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(view[3], 0n, 'The value of view[3] is 0n');
|
||||||
|
control[0] = 12345n;
|
||||||
|
view[3] = 12345n;
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.compareExchange(view, 3, 12345n, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.compareExchange(view, 3, 12345n, 0n) returns the value of `control[0]` (12345n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(view[3], 0n, 'The value of view[3] is 0n');
|
||||||
|
control[0] = 123456789n;
|
||||||
|
view[3] = 123456789n;
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.compareExchange(view, 3, 123456789n, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.compareExchange(view, 3, 123456789n, 0n) returns the value of `control[0]` (123456789n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(view[3], 0n, 'The value of view[3] is 0n');
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0n);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
Atomics.store(view, Idx, 37n);
|
||||||
// Atomics operations, not quite like view[Idx].
|
|
||||||
Atomics.store(view, Idx, 37);
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.compareExchange(view, Idx, 37, 0),
|
Atomics.compareExchange(view, Idx, 37n, 0n),
|
||||||
37,
|
37n,
|
||||||
'Atomics.compareExchange(view, Idx, 37, 0) returns 37'
|
'Atomics.compareExchange(view, Idx, 37n, 0n) returns 37n'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.compareexchange
|
esid: sec-atomics.compareexchange
|
||||||
description: >
|
description: >
|
||||||
@ -8,11 +7,10 @@ description: >
|
|||||||
includes: [testBigIntTypedArray.js]
|
includes: [testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.compareExchange(new TA(buffer), 0, 0, 0);
|
Atomics.compareExchange(new TA(buffer), 0, 0n, 0n);
|
||||||
}, 'Atomics.compareExchange(new TA(buffer), 0, 0, 0) throws TypeError');
|
}, '`Atomics.compareExchange(new TA(buffer), 0, 0n, 0n)` throws TypeError');
|
||||||
});
|
});
|
@ -26,15 +26,15 @@ info: |
|
|||||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4);
|
const buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4);
|
||||||
var i32a = new Int32Array(buffer);
|
const i32a = new Int32Array(buffer);
|
||||||
var update = 0b00000001000000001000000010000001;
|
const update = 0b00000001000000001000000010000001;
|
||||||
|
|
||||||
i32a[0] = update;
|
i32a[0] = update;
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.compareExchange(i32a, 0, update, 0),
|
Atomics.compareExchange(i32a, 0, update, 0),
|
||||||
update,
|
update,
|
||||||
'Atomics.compareExchange(i32a, 0, update, 0) equals the value of update (0b00000001000000001000000010000001)'
|
'Atomics.compareExchange(i32a, 0, update, 0) returns the value of `update` (0b00000001000000001000000010000001)'
|
||||||
);
|
);
|
||||||
assert.sameValue(i32a[0], 0, 'The value of i32a[0] is 0');
|
assert.sameValue(i32a[0], 0, 'The value of i32a[0] is 0');
|
||||||
|
@ -8,15 +8,15 @@ includes: [testAtomics.js, testTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var ab = new ArrayBuffer(16);
|
const ab = new ArrayBuffer(16);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
const view = new TA(sab, 32, 20);
|
||||||
var control = new TA(ab, 0, 2);
|
const control = new TA(ab, 0, 2);
|
||||||
|
|
||||||
// Performs the exchange
|
// Performs the exchange
|
||||||
view[8] = 0;
|
view[8] = 0;
|
||||||
@ -36,26 +36,26 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
assert.sameValue(Atomics.compareExchange(view, 8, 0, -5), 0,
|
assert.sameValue(Atomics.compareExchange(view, 8, 0, -5), 0,
|
||||||
'Atomics.compareExchange(view, 8, 0, -5) returns 0');
|
'Atomics.compareExchange(view, 8, 0, -5) returns 0');
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(view[8], control[0], 'The value of view[8] equals the value of control[0] (-5)');
|
assert.sameValue(view[8], control[0], 'The value of view[8] equals the value of `control[0]` (-5)');
|
||||||
|
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.compareExchange(view, 3, -5, 0), control[0],
|
assert.sameValue(Atomics.compareExchange(view, 3, -5, 0), control[0],
|
||||||
'Atomics.compareExchange(view, 3, -5, 0) equals the value of control[0] (-5)');
|
'Atomics.compareExchange(view, 3, -5, 0) returns the value of `control[0]` (-5)');
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
||||||
|
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.compareExchange(view, 3, 12345, 0), control[0],
|
assert.sameValue(Atomics.compareExchange(view, 3, 12345, 0), control[0],
|
||||||
'Atomics.compareExchange(view, 3, 12345, 0) equals the value of control[0] (12345)');
|
'Atomics.compareExchange(view, 3, 12345, 0) returns the value of `control[0]` (12345)');
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.compareExchange(view, 3, 123456789, 0), control[0],
|
assert.sameValue(Atomics.compareExchange(view, 3, 123456789, 0), control[0],
|
||||||
'Atomics.compareExchange(view, 3, 123456789, 0) equals the value of control[0] (123456789)');
|
'Atomics.compareExchange(view, 3, 123456789, 0) returns the value of `control[0]` (123456789)');
|
||||||
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
assert.sameValue(view[3], 0, 'The value of view[3] is 0');
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
|
@ -12,5 +12,5 @@ features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedAr
|
|||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.compareExchange(view, 0, 0, 0);
|
Atomics.compareExchange(view, 0, 0, 0);
|
||||||
}, 'Atomics.compareExchange(view, 0, 0, 0) throws TypeError');
|
}, '`Atomics.compareExchange(view, 0, 0, 0)` throws TypeError');
|
||||||
});
|
});
|
||||||
|
@ -15,5 +15,5 @@ var views = intArrayConstructors.slice();
|
|||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.compareExchange(new TA(buffer), 0, 0, 0);
|
Atomics.compareExchange(new TA(buffer), 0, 0, 0);
|
||||||
}, 'Atomics.compareExchange(new TA(buffer), 0, 0, 0) throws TypeError');
|
}, '`Atomics.compareExchange(new TA(buffer), 0, 0, 0)` throws TypeError');
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -14,5 +14,5 @@ var buffer = new SharedArrayBuffer(1024);
|
|||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.compareExchange(new TA(buffer), 0, 0, 0);
|
Atomics.compareExchange(new TA(buffer), 0, 0, 0);
|
||||||
}, 'Atomics.compareExchange(new TA(buffer), 0, 0, 0) throws TypeError');
|
}, '`Atomics.compareExchange(new TA(buffer), 0, 0, 0)` throws TypeError');
|
||||||
}, floatArrayConstructors);
|
}, floatArrayConstructors);
|
||||||
|
@ -9,14 +9,14 @@ includes: [testAtomics.js, testTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
const buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
const view = new TA(buffer);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.exchange(view, IdxGen(view), 10, 0);
|
Atomics.exchange(view, IdxGen(view), 10, 0);
|
||||||
}, 'Atomics.exchange(view, IdxGen(view), 10, 0) throws RangeError');
|
}, '`Atomics.exchange(view, IdxGen(view), 10, 0)` throws RangeError');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.exchange
|
esid: sec-atomics.exchange
|
||||||
description: >
|
description: >
|
||||||
@ -8,14 +7,14 @@ description: >
|
|||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
var buffer = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
let view = new TA(buffer);
|
||||||
|
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.exchange(view, IdxGen(view), 10, 0);
|
Atomics.exchange(view, IdxGen(view), 10n, 0n);
|
||||||
}, 'Atomics.exchange(view, IdxGen(view), 10, 0) throws RangeError');
|
}, '`Atomics.exchange(view, IdxGen(view), 10n, 0n)` throws RangeError');
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,54 +1,71 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.exchange
|
esid: sec-atomics.exchange
|
||||||
description: Test Atomics.exchange on arrays that allow atomic operations.
|
description: Test Atomics.exchange on arrays that allow atomic operations.
|
||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var ab = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
const view = new TA(sab, 32, 20);
|
||||||
|
const control = new TA(ab, 0, 2);
|
||||||
|
view[8] = 0n;
|
||||||
|
assert.sameValue(Atomics.exchange(view, 8, 10n), 0n, 'Atomics.exchange(view, 8, 10n) returns 0n');
|
||||||
|
assert.sameValue(view[8], 10n, 'The value of view[8] is 10n');
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
assert.sameValue(
|
||||||
var control = new TA(ab, 0, 2);
|
Atomics.exchange(view, 8, -5n),
|
||||||
|
10n,
|
||||||
|
'Atomics.exchange(view, 8, -5n) returns 10n'
|
||||||
|
);
|
||||||
|
|
||||||
view[8] = 0;
|
control[0] = -5n;
|
||||||
assert.sameValue(Atomics.exchange(view, 8, 10), 0,
|
|
||||||
'Atomics.exchange(view, 8, 10) returns 0');
|
|
||||||
assert.sameValue(view[8], 10, 'The value of view[8] is 10');
|
|
||||||
|
|
||||||
assert.sameValue(Atomics.exchange(view, 8, -5), 10,
|
assert.sameValue(
|
||||||
'Atomics.exchange(view, 8, -5) returns 10');
|
view[8],
|
||||||
control[0] = -5;
|
control[0],
|
||||||
assert.sameValue(view[8], control[0], 'The value of view[8] equals the value of control[0] (-5)');
|
'The value of view[8] equals the value of `control[0]` (-5n)'
|
||||||
|
);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5n;
|
||||||
control[0] = -5;
|
control[0] = -5n;
|
||||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
|
||||||
'Atomics.exchange(view, 3, 0) equals the value of control[0] (-5)');
|
|
||||||
|
|
||||||
control[0] = 12345;
|
assert.sameValue(
|
||||||
view[3] = 12345;
|
Atomics.exchange(view, 3, 0n),
|
||||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
control[0],
|
||||||
'Atomics.exchange(view, 3, 0) equals the value of control[0] (12345)');
|
'Atomics.exchange(view, 3, 0n) returns the value of `control[0]` (-5n)'
|
||||||
|
);
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 12345n;
|
||||||
view[3] = 123456789;
|
view[3] = 12345n;
|
||||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
|
||||||
'Atomics.exchange(view, 3, 0) equals the value of control[0] (123456789)');
|
assert.sameValue(
|
||||||
|
Atomics.exchange(view, 3, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.exchange(view, 3, 0n) returns the value of `control[0]` (12345n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
control[0] = 123456789n;
|
||||||
|
view[3] = 123456789n;
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.exchange(view, 3, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.exchange(view, 3, 0n) returns the value of `control[0]` (123456789n)'
|
||||||
|
);
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0n);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
Atomics.store(view, Idx, 37n);
|
||||||
// Atomics operations, not quite like view[Idx].
|
|
||||||
Atomics.store(view, Idx, 37);
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.exchange(view, Idx, 0), 37, 'Atomics.exchange(view, Idx, 0) returns 37');
|
Atomics.exchange(view, Idx, 0n),
|
||||||
|
37n,
|
||||||
|
'Atomics.exchange(view, Idx, 0n) returns 37n'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.exchange
|
esid: sec-atomics.exchange
|
||||||
description: >
|
description: >
|
||||||
@ -8,11 +7,10 @@ description: >
|
|||||||
includes: [testBigIntTypedArray.js]
|
includes: [testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
var buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.exchange(new TA(buffer), 0, 0);
|
Atomics.exchange(new TA(buffer), 0n, 0n);
|
||||||
}, 'Atomics.exchange(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.exchange(new TA(buffer), 0n, 0n)` throws TypeError');
|
||||||
});
|
});
|
@ -27,9 +27,10 @@ info: |
|
|||||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4);
|
const i32a = new Int32Array(
|
||||||
var i32a = new Int32Array(buffer);
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
var update = 0b00000001000000001000000010000001;
|
);
|
||||||
|
const update = 0b00000001000000001000000010000001;
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.exchange(i32a, 0, update),
|
Atomics.exchange(i32a, 0, update),
|
||||||
@ -39,5 +40,5 @@ assert.sameValue(
|
|||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
i32a[0],
|
i32a[0],
|
||||||
update,
|
update,
|
||||||
'The value of i32a[0] equals the value of update (0b00000001000000001000000010000001)'
|
'The value of i32a[0] equals the value of `update` (0b00000001000000001000000010000001)'
|
||||||
);
|
);
|
||||||
|
@ -8,15 +8,15 @@ includes: [testAtomics.js, testTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var ab = new ArrayBuffer(16);
|
const ab = new ArrayBuffer(16);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
const view = new TA(sab, 32, 20);
|
||||||
var control = new TA(ab, 0, 2);
|
const control = new TA(ab, 0, 2);
|
||||||
|
|
||||||
view[8] = 0;
|
view[8] = 0;
|
||||||
assert.sameValue(Atomics.exchange(view, 8, 10), 0,
|
assert.sameValue(Atomics.exchange(view, 8, 10), 0,
|
||||||
@ -26,22 +26,22 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
assert.sameValue(Atomics.exchange(view, 8, -5), 10,
|
assert.sameValue(Atomics.exchange(view, 8, -5), 10,
|
||||||
'Atomics.exchange(view, 8, -5) returns 10');
|
'Atomics.exchange(view, 8, -5) returns 10');
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(view[8], control[0], 'The value of view[8] equals the value of control[0] (-5)');
|
assert.sameValue(view[8], control[0], 'The value of view[8] equals the value of `control[0]` (-5)');
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
||||||
'Atomics.exchange(view, 3, 0) equals the value of control[0] (-5)');
|
'Atomics.exchange(view, 3, 0) returns the value of `control[0]` (-5)');
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
||||||
'Atomics.exchange(view, 3, 0) equals the value of control[0] (12345)');
|
'Atomics.exchange(view, 3, 0) returns the value of `control[0]` (12345)');
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
|
||||||
'Atomics.exchange(view, 3, 0) equals the value of control[0] (123456789)');
|
'Atomics.exchange(view, 3, 0) returns the value of `control[0]` (123456789)');
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
|
@ -12,5 +12,5 @@ features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedAr
|
|||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.exchange(view, 0, 0);
|
Atomics.exchange(view, 0, 0);
|
||||||
}, 'Atomics.exchange(view, 0, 0) throws TypeError');
|
}, '`Atomics.exchange(view, 0, 0)` throws TypeError');
|
||||||
});
|
});
|
||||||
|
@ -15,5 +15,5 @@ var views = intArrayConstructors.slice();
|
|||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.exchange(new TA(buffer), 0, 0);
|
Atomics.exchange(new TA(buffer), 0, 0);
|
||||||
}, 'Atomics.exchange(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.exchange(new TA(buffer), 0, 0)` throws TypeError');
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -14,5 +14,5 @@ var buffer = new SharedArrayBuffer(1024);
|
|||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.exchange(new TA(buffer), 0, 0);
|
Atomics.exchange(new TA(buffer), 0, 0);
|
||||||
}, 'Atomics.exchange(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.exchange(new TA(buffer), 0, 0)` throws TypeError');
|
||||||
}, floatArrayConstructors);
|
}, floatArrayConstructors);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.islockfree
|
esid: sec-atomics.islockfree
|
||||||
description: >
|
description: >
|
||||||
@ -8,22 +7,24 @@ description: >
|
|||||||
features: [arrow-function, Atomics, SharedArrayBuffer, ArrayBuffer, DataView, BigInt, let, TypedArray, for-of]
|
features: [arrow-function, Atomics, SharedArrayBuffer, ArrayBuffer, DataView, BigInt, let, TypedArray, for-of]
|
||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(hide(3, Number.NaN)),
|
Atomics.isLockFree(hide(3, Number.NaN)),
|
||||||
false,
|
false,
|
||||||
'Atomics.isLockFree(hide(3, Number.NaN)) returns false'
|
'Atomics.isLockFree(hide(3, Number.NaN)) returns false'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(hide(3, -1)),
|
Atomics.isLockFree(hide(3, -1)),
|
||||||
false,
|
false,
|
||||||
'Atomics.isLockFree(hide(3, -1)) returns false'
|
'Atomics.isLockFree(hide(3, -1)) returns false'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(hide(3, 3.14)),
|
Atomics.isLockFree(hide(3, 3.14)),
|
||||||
false,
|
false,
|
||||||
'Atomics.isLockFree(hide(3, 3.14)) returns false'
|
'Atomics.isLockFree(hide(3, 3.14)) returns false'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(hide(3, 0)),
|
Atomics.isLockFree(hide(3, 0)),
|
||||||
false,
|
false,
|
||||||
@ -33,12 +34,13 @@ assert.sameValue(
|
|||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree('1'),
|
Atomics.isLockFree('1'),
|
||||||
Atomics.isLockFree(1),
|
Atomics.isLockFree(1),
|
||||||
'Atomics.isLockFree(\'1\') returns Atomics.isLockFree(1)'
|
'Atomics.isLockFree("1") returns Atomics.isLockFree(1)'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree('3'),
|
Atomics.isLockFree('3'),
|
||||||
Atomics.isLockFree(3),
|
Atomics.isLockFree(3),
|
||||||
'Atomics.isLockFree(\'3\') returns Atomics.isLockFree(3)'
|
'Atomics.isLockFree("3") returns Atomics.isLockFree(3)'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
@ -47,30 +49,26 @@ assert.sameValue(
|
|||||||
'Atomics.isLockFree(true) returns Atomics.isLockFree(1)'
|
'Atomics.isLockFree(true) returns Atomics.isLockFree(1)'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(Atomics.isLockFree(1), Atomics.isLockFree({
|
||||||
Atomics.isLockFree(1),
|
valueOf: () => 1
|
||||||
Atomics.isLockFree({valueOf: () => 1}),
|
}), 'Atomics.isLockFree(1) returns Atomics.isLockFree({\n valueOf: () => 1\n})');
|
||||||
'Atomics.isLockFree(1) returns Atomics.isLockFree({valueOf: () => 1})'
|
|
||||||
);
|
assert.sameValue(Atomics.isLockFree(3), Atomics.isLockFree({
|
||||||
assert.sameValue(
|
valueOf: () => 3
|
||||||
Atomics.isLockFree(3),
|
}), 'Atomics.isLockFree(3) returns Atomics.isLockFree({\n valueOf: () => 3\n})');
|
||||||
Atomics.isLockFree({valueOf: () => 3}),
|
|
||||||
'Atomics.isLockFree(3) returns Atomics.isLockFree({valueOf: () => 3})'
|
assert.sameValue(Atomics.isLockFree(1), Atomics.isLockFree({
|
||||||
);
|
toString: () => '1'
|
||||||
assert.sameValue(
|
}), 'Atomics.isLockFree(1) returns Atomics.isLockFree({\n toString: () => "1"\n})');
|
||||||
Atomics.isLockFree(1),
|
|
||||||
Atomics.isLockFree({toString: () => '1'}),
|
assert.sameValue(Atomics.isLockFree(3), Atomics.isLockFree({
|
||||||
'Atomics.isLockFree(1) returns Atomics.isLockFree({toString: () => \'1\'})'
|
toString: () => '3'
|
||||||
);
|
}), 'Atomics.isLockFree(3) returns Atomics.isLockFree({\n toString: () => "3"\n})');
|
||||||
assert.sameValue(
|
|
||||||
Atomics.isLockFree(3),
|
|
||||||
Atomics.isLockFree({toString: () => '3'}),
|
|
||||||
'Atomics.isLockFree(3) returns Atomics.isLockFree({toString: () => \'3\'})'
|
|
||||||
);
|
|
||||||
|
|
||||||
function hide(k, x) {
|
function hide(k, x) {
|
||||||
if (k) {
|
if (k) {
|
||||||
return hide(k - 3, x) + x;
|
return BigInt(hide(k - 3, x) + x);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
return 0n;
|
||||||
}
|
}
|
@ -28,7 +28,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(TA.BYTES_PER_ELEMENT),
|
Atomics.isLockFree(TA.BYTES_PER_ELEMENT),
|
||||||
observed,
|
observed,
|
||||||
'Atomics.isLockFree(TA.BYTES_PER_ELEMENT) equals the value of `observed` (Atomics.isLockFree(TA.BYTES_PER_ELEMENT))'
|
'Atomics.isLockFree(TA.BYTES_PER_ELEMENT) returns the value of `observed` (Atomics.isLockFree(TA.BYTES_PER_ELEMENT))'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ assert.sameValue(
|
|||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree('1'),
|
Atomics.isLockFree('1'),
|
||||||
Atomics.isLockFree(1),
|
Atomics.isLockFree(1),
|
||||||
'Atomics.isLockFree("1") returns Atomics.isLockFree(1)'
|
'Atomics.isLockFree(\'1\') returns Atomics.isLockFree(1)'
|
||||||
);
|
);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree('3'),
|
Atomics.isLockFree('3'),
|
||||||
Atomics.isLockFree(3),
|
Atomics.isLockFree(3),
|
||||||
'Atomics.isLockFree("3") returns Atomics.isLockFree(3)'
|
'Atomics.isLockFree(\'3\') returns Atomics.isLockFree(3)'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
@ -59,12 +59,12 @@ assert.sameValue(
|
|||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(1),
|
Atomics.isLockFree(1),
|
||||||
Atomics.isLockFree({toString: () => '1'}),
|
Atomics.isLockFree({toString: () => '1'}),
|
||||||
'Atomics.isLockFree(1) returns Atomics.isLockFree({toString: () => "1"})'
|
'Atomics.isLockFree(1) returns Atomics.isLockFree({toString: () => \'1\'})'
|
||||||
);
|
);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(3),
|
Atomics.isLockFree(3),
|
||||||
Atomics.isLockFree({toString: () => '3'}),
|
Atomics.isLockFree({toString: () => '3'}),
|
||||||
'Atomics.isLockFree(3) returns Atomics.isLockFree({toString: () => "3"})'
|
'Atomics.isLockFree(3) returns Atomics.isLockFree({toString: () => \'3\'})'
|
||||||
);
|
);
|
||||||
|
|
||||||
function hide(k, x) {
|
function hide(k, x) {
|
||||||
|
@ -32,7 +32,7 @@ var isLockFree8;
|
|||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(1),
|
Atomics.isLockFree(1),
|
||||||
isLockFree1,
|
isLockFree1,
|
||||||
'Atomics.isLockFree(1) equals the value of `isLockFree1` (1)'
|
'Atomics.isLockFree(1) returns the value of `isLockFree1` (Atomics.isLockFree(1))'
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ var isLockFree8;
|
|||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(2),
|
Atomics.isLockFree(2),
|
||||||
isLockFree2,
|
isLockFree2,
|
||||||
'Atomics.isLockFree(2) equals the value of `isLockFree2` (2)'
|
'Atomics.isLockFree(2) returns the value of `isLockFree2` (Atomics.isLockFree(2))'
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
{
|
{
|
||||||
@ -55,8 +55,8 @@ var isLockFree8;
|
|||||||
//
|
//
|
||||||
// If n equals 4, return true.
|
// If n equals 4, return true.
|
||||||
//
|
//
|
||||||
assert.sameValue(typeof isLockFree4, 'boolean', 'The value of `typeof isLockFree` is "boolean"');
|
assert.sameValue(typeof isLockFree4, 'boolean', 'The value of `typeof isLockFree4` is "boolean"');
|
||||||
assert.sameValue(isLockFree4, true, 'The value of `isLockFree` is true');
|
assert.sameValue(isLockFree4, true, 'The value of `isLockFree4` is true');
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -71,14 +71,14 @@ var isLockFree8;
|
|||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(8),
|
Atomics.isLockFree(8),
|
||||||
isLockFree8,
|
isLockFree8,
|
||||||
'Atomics.isLockFree(8) equals the value of `isLockFree8` (8)'
|
'Atomics.isLockFree(8) returns the value of `isLockFree8` (Atomics.isLockFree(8))'
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
for (let i = 0; i < 12; i++) {
|
for (let i = 0; i < 12; i++) {
|
||||||
if (![1, 2, 4, 8].includes(i)) {
|
if (![1, 2, 4, 8].includes(i)) {
|
||||||
assert.sameValue(Atomics.isLockFree(i), false);
|
assert.sameValue(Atomics.isLockFree(i), false, 'Atomics.isLockFree(i) returns false');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -86,17 +86,17 @@ var isLockFree8;
|
|||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(1),
|
Atomics.isLockFree(1),
|
||||||
isLockFree1,
|
isLockFree1,
|
||||||
'Later call to Atomics.isLockFree(1) equals the value of `isLockFree1` (1)'
|
'Atomics.isLockFree(1) returns the value of `isLockFree1` (Atomics.isLockFree(1))'
|
||||||
);
|
);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(2),
|
Atomics.isLockFree(2),
|
||||||
isLockFree2,
|
isLockFree2,
|
||||||
'Later call to Atomics.isLockFree(2) equals the value of `isLockFree2` (2)'
|
'Atomics.isLockFree(2) returns the value of `isLockFree2` (Atomics.isLockFree(2))'
|
||||||
);
|
);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Atomics.isLockFree(8),
|
Atomics.isLockFree(8),
|
||||||
isLockFree8,
|
isLockFree8,
|
||||||
'Later call to Atomics.isLockFree(8) equals the value of `isLockFree8` (8)'
|
'Atomics.isLockFree(8) returns the value of `isLockFree8` (Atomics.isLockFree(8))'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Duplicates behavior created by loop from above
|
// Duplicates behavior created by loop from above
|
||||||
|
@ -17,6 +17,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.load(view, IdxGen(view));
|
Atomics.load(view, IdxGen(view));
|
||||||
}, 'Atomics.load(view, IdxGen(view)) throws RangeError');
|
}, '`Atomics.load(view, IdxGen(view))` throws RangeError');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -9,13 +9,13 @@ includes: [testAtomics.js, testBigIntTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
var buffer = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
let view = new TA(buffer);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.load(view, IdxGen(view));
|
Atomics.load(view, IdxGen(view));
|
||||||
}, 'Atomics.load(view, IdxGen(view)) throws RangeError');
|
}, '`Atomics.load(view, IdxGen(view))` throws RangeError');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,45 +1,48 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.load
|
esid: sec-atomics.load
|
||||||
description: Test Atomics.load on arrays that allow atomic operations.
|
description: Test Atomics.load on arrays that allow atomic operations.
|
||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var ab = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
const view = new TA(sab, 32, 20);
|
||||||
|
const control = new TA(ab, 0, 2);
|
||||||
|
view[3] = -5n;
|
||||||
|
control[0] = -5n;
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
assert.sameValue(
|
||||||
var control = new TA(ab, 0, 2);
|
Atomics.load(view, 3),
|
||||||
|
control[0],
|
||||||
|
'Atomics.load(view, 3) returns the value of `control[0]` (-5n)'
|
||||||
|
);
|
||||||
|
|
||||||
view[3] = -5;
|
control[0] = 12345n;
|
||||||
control[0] = -5;
|
view[3] = 12345n;
|
||||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
|
||||||
"Result is subject to coercion");
|
|
||||||
|
|
||||||
control[0] = 12345;
|
assert.sameValue(
|
||||||
view[3] = 12345;
|
Atomics.load(view, 3),
|
||||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
control[0],
|
||||||
"Result is subject to chopping");
|
'Atomics.load(view, 3) returns the value of `control[0]` (12345n)'
|
||||||
|
);
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789n;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789n;
|
||||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
|
||||||
"Result is subject to chopping");
|
assert.sameValue(
|
||||||
|
Atomics.load(view, 3),
|
||||||
|
control[0],
|
||||||
|
'Atomics.load(view, 3) returns the value of `control[0]` (123456789n)'
|
||||||
|
);
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0n);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
Atomics.store(view, Idx, 37n);
|
||||||
// Atomics operations, not quite like view[Idx].
|
assert.sameValue(Atomics.load(view, Idx), 37n, 'Atomics.load(view, Idx) returns 37n');
|
||||||
Atomics.store(view, Idx, 37);
|
|
||||||
assert.sameValue(Atomics.load(view, Idx), 37);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -9,7 +9,7 @@ includes: [testBigIntTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var ab = new ArrayBuffer(16);
|
var ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
@ -17,5 +17,5 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.load(view, 0);
|
Atomics.load(view, 0);
|
||||||
}, 'Atomics.load(view, 0) throws TypeError');
|
}, '`Atomics.load(view, 0)` throws TypeError');
|
||||||
});
|
});
|
||||||
|
@ -28,13 +28,18 @@ info: |
|
|||||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4);
|
const i32a = new Int32Array(
|
||||||
var i32a = new Int32Array(buffer);
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
var update = 0b00000001000000001000000010000001;
|
);
|
||||||
|
const update = 0b00000001000000001000000010000001;
|
||||||
|
|
||||||
assert.sameValue(Atomics.load(i32a, 0), 0);
|
assert.sameValue(Atomics.load(i32a, 0), 0, 'Atomics.load(i32a, 0) returns 0');
|
||||||
|
|
||||||
i32a[0] = update;
|
i32a[0] = update;
|
||||||
|
|
||||||
assert.sameValue(Atomics.load(i32a, 0), update);
|
assert.sameValue(
|
||||||
|
Atomics.load(i32a, 0),
|
||||||
|
update,
|
||||||
|
'Atomics.load(i32a, 0) returns the value of `update` (0b00000001000000001000000010000001)'
|
||||||
|
);
|
||||||
|
|
||||||
|
@ -8,31 +8,31 @@ includes: [testAtomics.js, testTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var ab = new ArrayBuffer(16);
|
const ab = new ArrayBuffer(16);
|
||||||
|
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
const view = new TA(sab, 32, 20);
|
||||||
var control = new TA(ab, 0, 2);
|
const control = new TA(ab, 0, 2);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
assert.sameValue(Atomics.load(view, 3), control[0],
|
||||||
"Result is subject to coercion");
|
'Atomics.load(view, 3) returns the value of `control[0]` (-5)');
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
assert.sameValue(Atomics.load(view, 3), control[0],
|
||||||
"Result is subject to chopping");
|
'Atomics.load(view, 3) returns the value of `control[0]` (12345)');
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.load(view, 3), control[0],
|
assert.sameValue(Atomics.load(view, 3), control[0],
|
||||||
"Result is subject to chopping");
|
'Atomics.load(view, 3) returns the value of `control[0]` (123456789)');
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
@ -41,6 +41,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.load(view, Idx), 37);
|
assert.sameValue(Atomics.load(view, Idx), 37, 'Atomics.load(view, Idx) returns 37');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -12,5 +12,5 @@ features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedAr
|
|||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.load(view, 0);
|
Atomics.load(view, 0);
|
||||||
}, 'Atomics.load(view, 0) throws TypeError');
|
}, '`Atomics.load(view, 0)` throws TypeError');
|
||||||
});
|
});
|
||||||
|
@ -9,14 +9,13 @@ includes: [testTypedArray.js]
|
|||||||
features: [ArrayBuffer, Atomics, TypedArray]
|
features: [ArrayBuffer, Atomics, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var ab = new ArrayBuffer(16);
|
const buffer = new ArrayBuffer(16);
|
||||||
|
const views = intArrayConstructors.slice();
|
||||||
var views = intArrayConstructors.slice();
|
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
var view = new TA(ab);
|
const view = new TA(buffer);
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.load(view, 0);
|
Atomics.load(view, 0);
|
||||||
}, 'Atomics.load(view, 0) throws TypeError');
|
}, '`Atomics.load(view, 0)` throws TypeError');
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -9,9 +9,9 @@ includes: [testTypedArray.js]
|
|||||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(1024);
|
const buffer = new SharedArrayBuffer(1024);
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.load(new TA(buffer), 0);
|
Atomics.load(new TA(buffer), 0);
|
||||||
}, 'Atomics.load(new TA(buffer), 0) throws TypeError');
|
}, '`Atomics.load(new TA(buffer), 0)` throws TypeError');
|
||||||
}, floatArrayConstructors);
|
}, floatArrayConstructors);
|
||||||
|
@ -17,6 +17,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.or(view, IdxGen(view), 10);
|
Atomics.or(view, IdxGen(view), 10);
|
||||||
}, 'Atomics.or(view, IdxGen(view), 10) throws RangeError');
|
}, '`Atomics.or(view, IdxGen(view), 10)` throws RangeError');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.or
|
esid: sec-atomics.or
|
||||||
description: >
|
description: >
|
||||||
@ -8,14 +7,14 @@ description: >
|
|||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
var buffer = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
let view = new TA(buffer);
|
||||||
|
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.or(view, IdxGen(view), 10);
|
Atomics.or(view, IdxGen(view), 10n);
|
||||||
}, 'Atomics.or(view, IdxGen(view), 10) throws RangeError');
|
}, '`Atomics.or(view, IdxGen(view), 10n)` throws RangeError');
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,60 +1,97 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.or
|
esid: sec-atomics.or
|
||||||
description: Test Atomics.or on arrays that allow atomic operations
|
description: Test Atomics.or on arrays that allow atomic operations
|
||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var ab = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
const view = new TA(sab, 32, 20);
|
||||||
|
const control = new TA(ab, 0, 2);
|
||||||
|
view[8] = 0x33333333n;
|
||||||
|
control[0] = 0x33333333n;
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
assert.sameValue(
|
||||||
var control = new TA(ab, 0, 2);
|
Atomics.or(view, 8, 0x55555555n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.or(view, 8, 0x55555555n) returns the value of `control[0]` (0x33333333n)'
|
||||||
|
);
|
||||||
|
|
||||||
view[8] = 0x33333333;
|
control[0] = 0x77777777n;
|
||||||
control[0] = 0x33333333;
|
|
||||||
assert.sameValue(Atomics.or(view, 8, 0x55555555), control[0],
|
|
||||||
"Result is subject to chopping");
|
|
||||||
|
|
||||||
control[0] = 0x77777777;
|
assert.sameValue(
|
||||||
assert.sameValue(view[8], control[0]);
|
view[8],
|
||||||
assert.sameValue(Atomics.or(view, 8, 0xF0F0F0F0), control[0],
|
control[0],
|
||||||
"Result is subject to chopping");
|
'The value of view[8] equals the value of `control[0]` (0x77777777n)'
|
||||||
|
);
|
||||||
|
|
||||||
control[0] = 0xF7F7F7F7;
|
assert.sameValue(
|
||||||
assert.sameValue(view[8], control[0]);
|
Atomics.or(view, 8, 0xF0F0F0F0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.or(view, 8, 0xF0F0F0F0n) returns the value of `control[0]` (0x77777777n)'
|
||||||
|
);
|
||||||
|
|
||||||
view[3] = -5;
|
control[0] = 0xF7F7F7F7n;
|
||||||
control[0] = -5;
|
|
||||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
|
||||||
"Result is negative and subject to coercion");
|
|
||||||
assert.sameValue(view[3], control[0]);
|
|
||||||
|
|
||||||
control[0] = 12345;
|
assert.sameValue(
|
||||||
view[3] = 12345;
|
view[8],
|
||||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
control[0],
|
||||||
"Result is subject to chopping");
|
'The value of view[8] equals the value of `control[0]` (0xF7F7F7F7n)'
|
||||||
assert.sameValue(view[3], control[0]);
|
);
|
||||||
|
|
||||||
control[0] = 123456789;
|
view[3] = -5n;
|
||||||
view[3] = 123456789;
|
control[0] = -5n;
|
||||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
|
||||||
"Result is subject to chopping");
|
assert.sameValue(
|
||||||
assert.sameValue(view[3], control[0]);
|
Atomics.or(view, 3, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.or(view, 3, 0n) returns the value of `control[0]` (-5n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
view[3],
|
||||||
|
control[0],
|
||||||
|
'The value of view[3] equals the value of `control[0]` (-5n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
control[0] = 12345n;
|
||||||
|
view[3] = 12345n;
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.or(view, 3, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.or(view, 3, 0n) returns the value of `control[0]` (12345n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
view[3],
|
||||||
|
control[0],
|
||||||
|
'The value of view[3] equals the value of `control[0]` (12345n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
control[0] = 123456789n;
|
||||||
|
view[3] = 123456789n;
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.or(view, 3, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.or(view, 3, 0n) returns the value of `control[0]` (123456789n)'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
view[3],
|
||||||
|
control[0],
|
||||||
|
'The value of view[3] equals the value of `control[0]` (123456789n)'
|
||||||
|
);
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0n);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
Atomics.store(view, Idx, 37n);
|
||||||
// Atomics operations, not quite like view[Idx].
|
assert.sameValue(Atomics.or(view, Idx, 0n), 37n, 'Atomics.or(view, Idx, 0n) returns 37n');
|
||||||
Atomics.store(view, Idx, 37);
|
|
||||||
assert.sameValue(Atomics.or(view, Idx, 0), 37);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.or
|
esid: sec-atomics.or
|
||||||
description: >
|
description: >
|
||||||
@ -8,11 +7,10 @@ description: >
|
|||||||
includes: [testBigIntTypedArray.js]
|
includes: [testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.or(new TA(buffer), 0, 0);
|
Atomics.or(new TA(buffer), 0, 0n);
|
||||||
}, 'Atomics.or(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.or(new TA(buffer), 0, 0n)` throws TypeError');
|
||||||
});
|
});
|
@ -27,9 +27,20 @@ info: |
|
|||||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4);
|
const i32a = new Int32Array(
|
||||||
var i32a = new Int32Array(buffer);
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
var update = 0b00000001000000001000000010000001;
|
);
|
||||||
|
const a = 0b00000001000000001000000010000001;
|
||||||
|
const b = 0b00000001111111111000000011111111;
|
||||||
|
const c = 0b00000001111111111000000011111111;
|
||||||
|
|
||||||
|
i32a[0] = a;
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.or(i32a, 0, b),
|
||||||
|
a,
|
||||||
|
'Atomics.or(i32a, 0, b) returns the value of `a` (0b00000001000000001000000010000001)'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(i32a[0], c, 'The value of i32a[0] equals the value of `c` (0b00000001111111111000000011111111)');
|
||||||
|
|
||||||
assert.sameValue(Atomics.or(i32a, 0, update), 0);
|
|
||||||
assert.sameValue(i32a[0], 0 | update);
|
|
||||||
|
@ -21,33 +21,53 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
view[8] = 0x33333333;
|
view[8] = 0x33333333;
|
||||||
control[0] = 0x33333333;
|
control[0] = 0x33333333;
|
||||||
assert.sameValue(Atomics.or(view, 8, 0x55555555), control[0],
|
assert.sameValue(Atomics.or(view, 8, 0x55555555), control[0],
|
||||||
"Result is subject to chopping");
|
'Atomics.or(view, 8, 0x55555555) returns the value of `control[0]` (0x33333333)');
|
||||||
|
|
||||||
control[0] = 0x77777777;
|
control[0] = 0x77777777;
|
||||||
assert.sameValue(view[8], control[0]);
|
assert.sameValue(
|
||||||
|
view[8],
|
||||||
|
control[0],
|
||||||
|
'The value of view[8] equals the value of `control[0]` (0x77777777)'
|
||||||
|
);
|
||||||
assert.sameValue(Atomics.or(view, 8, 0xF0F0F0F0), control[0],
|
assert.sameValue(Atomics.or(view, 8, 0xF0F0F0F0), control[0],
|
||||||
"Result is subject to chopping");
|
'Atomics.or(view, 8, 0xF0F0F0F0) returns the value of `control[0]` (0x77777777)');
|
||||||
|
|
||||||
control[0] = 0xF7F7F7F7;
|
control[0] = 0xF7F7F7F7;
|
||||||
assert.sameValue(view[8], control[0]);
|
assert.sameValue(
|
||||||
|
view[8],
|
||||||
|
control[0],
|
||||||
|
'The value of view[8] equals the value of `control[0]` (0xF7F7F7F7)'
|
||||||
|
);
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
||||||
"Result is negative and subject to coercion");
|
'Atomics.or(view, 3, 0) returns the value of `control[0]` (-5)');
|
||||||
assert.sameValue(view[3], control[0]);
|
assert.sameValue(
|
||||||
|
view[3],
|
||||||
|
control[0],
|
||||||
|
'The value of view[3] equals the value of `control[0]` (-5)'
|
||||||
|
);
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
'Atomics.or(view, 3, 0) returns the value of `control[0]` (12345)');
|
||||||
assert.sameValue(view[3], control[0]);
|
assert.sameValue(
|
||||||
|
view[3],
|
||||||
|
control[0],
|
||||||
|
'The value of view[3] equals the value of `control[0]` (12345)'
|
||||||
|
);
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
assert.sameValue(Atomics.or(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
'Atomics.or(view, 3, 0) returns the value of `control[0]` (123456789)');
|
||||||
assert.sameValue(view[3], control[0]);
|
assert.sameValue(
|
||||||
|
view[3],
|
||||||
|
control[0],
|
||||||
|
'The value of view[3] equals the value of `control[0]` (123456789)'
|
||||||
|
);
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
@ -56,6 +76,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.or(view, Idx, 0), 37);
|
assert.sameValue(Atomics.or(view, Idx, 0), 37, 'Atomics.or(view, Idx, 0) returns 37');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -12,5 +12,5 @@ features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedAr
|
|||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.or(view, 0, 0);
|
Atomics.or(view, 0, 0);
|
||||||
}, 'Atomics.or(view, 0, 0) throws TypeError');
|
}, '`Atomics.or(view, 0, 0)` throws TypeError');
|
||||||
});
|
});
|
||||||
|
@ -9,11 +9,11 @@ includes: [testTypedArray.js]
|
|||||||
features: [ArrayBuffer, Atomics, TypedArray]
|
features: [ArrayBuffer, Atomics, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new ArrayBuffer(16);
|
const buffer = new ArrayBuffer(16);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.or(new TA(buffer), 0, 0);
|
Atomics.or(new TA(buffer), 0, 0);
|
||||||
}, 'Atomics.or(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.or(new TA(buffer), 0, 0)` throws TypeError');
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -14,7 +14,7 @@ var buffer = new SharedArrayBuffer(1024);
|
|||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.or(new TA(buffer), 0, 0);
|
Atomics.or(new TA(buffer), 0, 0);
|
||||||
}, 'Atomics.or(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.or(new TA(buffer), 0, 0)` throws TypeError');
|
||||||
}, floatArrayConstructors);
|
}, floatArrayConstructors);
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,15 +24,15 @@ includes: [propertyHelper.js]
|
|||||||
features: [Atomics]
|
features: [Atomics]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(typeof Atomics, "object");
|
assert.sameValue(typeof Atomics, "object", 'The value of `typeof Atomics` is "object"');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics();
|
Atomics();
|
||||||
}, "no [[Call]]");
|
}, '`Atomics()` throws TypeError');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
new Atomics();
|
new Atomics();
|
||||||
}, "no [[Construct]]");
|
}, '`new Atomics()` throws TypeError');
|
||||||
|
|
||||||
verifyProperty(this, "Atomics", {
|
verifyProperty(this, "Atomics", {
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
|
@ -13,4 +13,8 @@ info: |
|
|||||||
features: [Atomics]
|
features: [Atomics]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(Object.getPrototypeOf(Atomics), Object.prototype);
|
assert.sameValue(
|
||||||
|
Object.getPrototypeOf(Atomics),
|
||||||
|
Object.prototype,
|
||||||
|
'Object.getPrototypeOf(Atomics) returns the value of `Object.prototype`'
|
||||||
|
);
|
||||||
|
@ -9,14 +9,14 @@ includes: [testAtomics.js, testTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
const buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
const view = new TA(buffer);
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.store(view, IdxGen(view), 10);
|
Atomics.store(view, IdxGen(view), 10);
|
||||||
}, 'Atomics.store(view, IdxGen(view), 10) throws RangeError');
|
}, '`Atomics.store(view, IdxGen(view), 10)` throws RangeError');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.store
|
esid: sec-atomics.store
|
||||||
description: >
|
description: >
|
||||||
@ -8,14 +7,14 @@ description: >
|
|||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const buffer = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
const view = new TA(buffer);
|
||||||
|
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.store(view, IdxGen(view), 10);
|
Atomics.store(view, IdxGen(view), 10n);
|
||||||
}, 'Atomics.store(view, IdxGen(view), 10) throws RangeError');
|
}, '`Atomics.store(view, IdxGen(view), 10n)` throws RangeError');
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,59 +1,42 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.store
|
esid: sec-atomics.store
|
||||||
description: Test Atomics.store on arrays that allow atomic operations.
|
description: Test Atomics.store on arrays that allow atomic operations.
|
||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
var sab = new SharedArrayBuffer(1024);
|
// In-bounds boundary cases for indexing
|
||||||
var ab = new ArrayBuffer(16);
|
const sab = new SharedArrayBuffer(1024);
|
||||||
|
const ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
const view = new TA(sab, 32, 20);
|
||||||
|
const control = new TA(ab, 0, 2);
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
for (let val of [10n, -5n, 12345n, 123456789n, BigInt('33'), {
|
||||||
var control = new TA(ab, 0, 2);
|
valueOf: () => 33n
|
||||||
|
}, BigInt(undefined)]) {
|
||||||
for (let val of [10, -5,
|
assert.sameValue(
|
||||||
12345,
|
Atomics.store(view, 3, val),
|
||||||
123456789,
|
BigInt(val),
|
||||||
Math.PI,
|
'Atomics.store(view, 3, val) returns BigInt(val)'
|
||||||
"33",
|
);
|
||||||
{
|
|
||||||
valueOf: () => 33
|
|
||||||
},
|
|
||||||
undefined
|
|
||||||
])
|
|
||||||
{
|
|
||||||
assert.sameValue(Atomics.store(view, 3, val), ToInteger(val),
|
|
||||||
"Atomics.store returns its third argument (" + val + ") converted to Integer, not the input value nor the value that was stored");
|
|
||||||
|
|
||||||
control[0] = val;
|
control[0] = val;
|
||||||
assert.sameValue(view[3], control[0]);
|
|
||||||
|
assert.sameValue(
|
||||||
|
view[3],
|
||||||
|
control[0],
|
||||||
|
'The value of view[3] equals the value of `control[0]` (val)'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0n);
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37n);
|
||||||
assert.sameValue(Atomics.load(view, Idx), 37);
|
assert.sameValue(Atomics.load(view, Idx), 37n, 'Atomics.load(view, Idx) returns 37n');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function ToInteger(v) {
|
|
||||||
v = +v;
|
|
||||||
if (isNaN(v)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (v == 0 || !isFinite(v)) {
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
if (v < 0) {
|
|
||||||
return -Math.floor(Math.abs(v));
|
|
||||||
}
|
|
||||||
return Math.floor(v);
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.store
|
esid: sec-atomics.store
|
||||||
description: >
|
description: >
|
||||||
@ -8,11 +7,10 @@ description: >
|
|||||||
includes: [testBigIntTypedArray.js]
|
includes: [testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.store(new TA(buffer), 0, 0);
|
Atomics.store(new TA(buffer), 0, 0n);
|
||||||
}, 'Atomics.store(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.store(new TA(buffer), 0, 0n)` throws TypeError');
|
||||||
});
|
});
|
@ -18,9 +18,18 @@ info: |
|
|||||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4);
|
const i32a = new Int32Array(
|
||||||
var i32a = new Int32Array(buffer);
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
var update = 0b00000001000000001000000010000001;
|
);
|
||||||
|
const update = 0b00000001000000001000000010000001;
|
||||||
|
|
||||||
assert.sameValue(Atomics.store(i32a, 0, update), update);
|
assert.sameValue(
|
||||||
assert.sameValue(i32a[0], update);
|
Atomics.store(i32a, 0, update),
|
||||||
|
update,
|
||||||
|
'Atomics.store(i32a, 0, update) returns the value of `update` (0b00000001000000001000000010000001)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
i32a[0],
|
||||||
|
update,
|
||||||
|
'The value of i32a[0] equals the value of `update` (0b00000001000000001000000010000001)'
|
||||||
|
);
|
||||||
|
@ -8,15 +8,15 @@ includes: [testAtomics.js, testTypedArray.js]
|
|||||||
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var sab = new SharedArrayBuffer(1024);
|
const sab = new SharedArrayBuffer(1024);
|
||||||
var ab = new ArrayBuffer(16);
|
const ab = new ArrayBuffer(16);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
const view = new TA(sab, 32, 20);
|
||||||
var control = new TA(ab, 0, 2);
|
const control = new TA(ab, 0, 2);
|
||||||
|
|
||||||
for (let val of [10, -5,
|
for (let val of [10, -5,
|
||||||
12345,
|
12345,
|
||||||
@ -30,10 +30,14 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
])
|
])
|
||||||
{
|
{
|
||||||
assert.sameValue(Atomics.store(view, 3, val), ToInteger(val),
|
assert.sameValue(Atomics.store(view, 3, val), ToInteger(val),
|
||||||
"Atomics.store returns its third argument (" + val + ") converted to Integer, not the input value nor the value that was stored");
|
'Atomics.store(view, 3, val) returns ToInteger(val)');
|
||||||
|
|
||||||
control[0] = val;
|
control[0] = val;
|
||||||
assert.sameValue(view[3], control[0]);
|
assert.sameValue(
|
||||||
|
view[3],
|
||||||
|
control[0],
|
||||||
|
'The value of view[3] equals the value of `control[0]` (val)'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
@ -41,7 +45,7 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0);
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.load(view, Idx), 37);
|
assert.sameValue(Atomics.load(view, Idx), 37, 'Atomics.load(view, Idx) returns 37');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
|
||||||
|
@ -12,5 +12,5 @@ features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedAr
|
|||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.store(view, 0, 0);
|
Atomics.store(view, 0, 0);
|
||||||
}, 'Atomics.store(view, 0, 0) throws TypeError');
|
}, '`Atomics.store(view, 0, 0)` throws TypeError');
|
||||||
});
|
});
|
||||||
|
@ -9,11 +9,11 @@ includes: [testTypedArray.js]
|
|||||||
features: [ArrayBuffer, Atomics, TypedArray]
|
features: [ArrayBuffer, Atomics, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new ArrayBuffer(16);
|
const buffer = new ArrayBuffer(16);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.store(new TA(buffer), 0, 0);
|
Atomics.store(new TA(buffer), 0, 0);
|
||||||
}, 'Atomics.store(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.store(new TA(buffer), 0, 0)` throws TypeError');
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -14,7 +14,7 @@ var buffer = new SharedArrayBuffer(1024);
|
|||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.store(new TA(buffer), 0, 0);
|
Atomics.store(new TA(buffer), 0, 0);
|
||||||
}, 'Atomics.store(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.store(new TA(buffer), 0, 0)` throws TypeError');
|
||||||
}, floatArrayConstructors);
|
}, floatArrayConstructors);
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.sub(view, IdxGen(view), 10);
|
Atomics.sub(view, IdxGen(view), 10);
|
||||||
}, 'Atomics.sub(view, IdxGen(view), 10) throws RangeError');
|
}, '`Atomics.sub(view, IdxGen(view), 10)` throws RangeError');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.sub
|
esid: sec-atomics.sub
|
||||||
description: >
|
description: >
|
||||||
@ -8,14 +7,14 @@ description: >
|
|||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const buffer = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
let view = new TA(buffer);
|
const view = new TA(buffer);
|
||||||
|
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.sub(view, IdxGen(view), 10);
|
Atomics.sub(view, IdxGen(view), 10n);
|
||||||
}, 'Atomics.sub(view, IdxGen(view), 10) throws RangeError');
|
}, '`Atomics.sub(view, IdxGen(view), 10n)` throws RangeError');
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,53 +1,57 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.sub
|
esid: sec-atomics.sub
|
||||||
description: Test Atomics.sub on arrays that allow atomic operations
|
description: Test Atomics.sub on arrays that allow atomic operations
|
||||||
includes: [testAtomics.js, testBigIntTypedArray.js]
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||||
var sab = new SharedArrayBuffer(1024);
|
// In-bounds boundary cases for indexing
|
||||||
var ab = new ArrayBuffer(16);
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
|
// Atomics operations, not quite like view[Idx].
|
||||||
|
const sab = new SharedArrayBuffer(1024);
|
||||||
|
const ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
const view = new TA(sab, 32, 20);
|
||||||
|
const control = new TA(ab, 0, 2);
|
||||||
|
view[8] = 100n;
|
||||||
|
assert.sameValue(Atomics.sub(view, 8, 10n), 100n, 'Atomics.sub(view, 8, 10n) returns 100n');
|
||||||
|
assert.sameValue(view[8], 90n, 'The value of view[8] is 90n');
|
||||||
|
assert.sameValue(Atomics.sub(view, 8, -5n), 90n, 'Atomics.sub(view, 8, -5n) returns 90n');
|
||||||
|
assert.sameValue(view[8], 95, 'The value of view[8] is 95');
|
||||||
|
view[3] = -5n;
|
||||||
|
control[0] = -5n;
|
||||||
|
|
||||||
var view = new TA(sab, 32, 20);
|
assert.sameValue(
|
||||||
var control = new TA(ab, 0, 2);
|
Atomics.sub(view, 3, 0n),
|
||||||
|
control[0],
|
||||||
|
'Atomics.sub(view, 3, 0n) returns the value of `control[0]` (-5n)'
|
||||||
|
);
|
||||||
|
|
||||||
view[8] = 100;
|
control[0] = 12345n;
|
||||||
assert.sameValue(Atomics.sub(view, 8, 10), 100,
|
view[3] = 12345n;
|
||||||
"Subtract positive number");
|
|
||||||
assert.sameValue(view[8], 90);
|
|
||||||
|
|
||||||
assert.sameValue(Atomics.sub(view, 8, -5), 90,
|
assert.sameValue(
|
||||||
"Subtract negative number, though result remains positive");
|
Atomics.sub(view, 3, 0n),
|
||||||
assert.sameValue(view[8], 95);
|
control[0],
|
||||||
|
'Atomics.sub(view, 3, 0n) returns the value of `control[0]` (12345n)'
|
||||||
|
);
|
||||||
|
|
||||||
view[3] = -5;
|
control[0] = 123456789n;
|
||||||
control[0] = -5;
|
view[3] = 123456789n;
|
||||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
|
||||||
"Result is negative and subject to coercion");
|
|
||||||
|
|
||||||
control[0] = 12345;
|
assert.sameValue(
|
||||||
view[3] = 12345;
|
Atomics.sub(view, 3, 0n),
|
||||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
control[0],
|
||||||
"Result is subject to chopping");
|
'Atomics.sub(view, 3, 0n) returns the value of `control[0]` (123456789n)'
|
||||||
|
);
|
||||||
|
|
||||||
control[0] = 123456789;
|
|
||||||
view[3] = 123456789;
|
|
||||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
|
||||||
"Result is subject to chopping");
|
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
let Idx = IdxGen(view);
|
let Idx = IdxGen(view);
|
||||||
view.fill(0);
|
view.fill(0n);
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
Atomics.store(view, Idx, 37n);
|
||||||
// Atomics operations, not quite like view[Idx].
|
assert.sameValue(Atomics.sub(view, Idx, 0n), 37n, 'Atomics.sub(view, Idx, 0n) returns 37n');
|
||||||
Atomics.store(view, Idx, 37);
|
|
||||||
assert.sameValue(Atomics.sub(view, Idx, 0), 37);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.sub
|
esid: sec-atomics.sub
|
||||||
description: >
|
description: >
|
||||||
@ -8,11 +7,10 @@ description: >
|
|||||||
includes: [testBigIntTypedArray.js]
|
includes: [testBigIntTypedArray.js]
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
||||||
var buffer = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.sub(new TA(buffer), 0, 0);
|
Atomics.sub(new TA(buffer), 0, 0n);
|
||||||
}, 'Atomics.sub(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.sub(new TA(buffer), 0, 0n)` throws TypeError');
|
||||||
});
|
});
|
@ -27,11 +27,16 @@ info: |
|
|||||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4);
|
const i32a = new Int32Array(
|
||||||
var i32a = new Int32Array(buffer);
|
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
var update = 0b00000001000000001000000010000001;
|
);
|
||||||
|
const update = 0b00000001000000001000000010000001;
|
||||||
|
|
||||||
i32a[0] = update;
|
i32a[0] = update;
|
||||||
|
|
||||||
assert.sameValue(Atomics.sub(i32a, 0, update), update);
|
assert.sameValue(
|
||||||
assert.sameValue(i32a[0], 0);
|
Atomics.sub(i32a, 0, update),
|
||||||
|
update,
|
||||||
|
'Atomics.sub(i32a, 0, update) returns the value of `update` (0b00000001000000001000000010000001)'
|
||||||
|
);
|
||||||
|
assert.sameValue(i32a[0], 0, 'The value of i32a[0] is 0');
|
||||||
|
@ -20,27 +20,27 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
|
|
||||||
view[8] = 100;
|
view[8] = 100;
|
||||||
assert.sameValue(Atomics.sub(view, 8, 10), 100,
|
assert.sameValue(Atomics.sub(view, 8, 10), 100,
|
||||||
"Subtract positive number");
|
'Atomics.sub(view, 8, 10) returns 100');
|
||||||
assert.sameValue(view[8], 90);
|
assert.sameValue(view[8], 90, 'The value of view[8] is 90');
|
||||||
|
|
||||||
assert.sameValue(Atomics.sub(view, 8, -5), 90,
|
assert.sameValue(Atomics.sub(view, 8, -5), 90,
|
||||||
"Subtract negative number, though result remains positive");
|
'Atomics.sub(view, 8, -5) returns 90');
|
||||||
assert.sameValue(view[8], 95);
|
assert.sameValue(view[8], 95, 'The value of view[8] is 95');
|
||||||
|
|
||||||
view[3] = -5;
|
view[3] = -5;
|
||||||
control[0] = -5;
|
control[0] = -5;
|
||||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
||||||
"Result is negative and subject to coercion");
|
'Atomics.sub(view, 3, 0) returns the value of `control[0]` (-5)');
|
||||||
|
|
||||||
control[0] = 12345;
|
control[0] = 12345;
|
||||||
view[3] = 12345;
|
view[3] = 12345;
|
||||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
'Atomics.sub(view, 3, 0) returns the value of `control[0]` (12345)');
|
||||||
|
|
||||||
control[0] = 123456789;
|
control[0] = 123456789;
|
||||||
view[3] = 123456789;
|
view[3] = 123456789;
|
||||||
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
assert.sameValue(Atomics.sub(view, 3, 0), control[0],
|
||||||
"Result is subject to chopping");
|
'Atomics.sub(view, 3, 0) returns the value of `control[0]` (123456789)');
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
// In-bounds boundary cases for indexing
|
||||||
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
testWithAtomicsInBoundsIndices(function(IdxGen) {
|
||||||
@ -49,6 +49,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||||||
// Atomics.store() computes an index from Idx in the same way as other
|
// Atomics.store() computes an index from Idx in the same way as other
|
||||||
// Atomics operations, not quite like view[Idx].
|
// Atomics operations, not quite like view[Idx].
|
||||||
Atomics.store(view, Idx, 37);
|
Atomics.store(view, Idx, 37);
|
||||||
assert.sameValue(Atomics.sub(view, Idx, 0), 37);
|
assert.sameValue(Atomics.sub(view, Idx, 0), 37, 'Atomics.sub(view, Idx, 0) returns 37');
|
||||||
});
|
});
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -12,5 +12,5 @@ features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedAr
|
|||||||
testWithAtomicsNonViewValues(function(view) {
|
testWithAtomicsNonViewValues(function(view) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.sub(view, 0, 0);
|
Atomics.sub(view, 0, 0);
|
||||||
}, 'Atomics.sub(view, 0, 0) throws TypeError');
|
}, '`Atomics.sub(view, 0, 0)` throws TypeError');
|
||||||
});
|
});
|
||||||
|
@ -9,11 +9,11 @@ includes: [testTypedArray.js]
|
|||||||
features: [ArrayBuffer, Atomics, TypedArray]
|
features: [ArrayBuffer, Atomics, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var buffer = new ArrayBuffer(16);
|
const buffer = new ArrayBuffer(16);
|
||||||
var views = intArrayConstructors.slice();
|
const views = intArrayConstructors.slice();
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.sub(new TA(buffer), 0, 0);
|
Atomics.sub(new TA(buffer), 0, 0);
|
||||||
}, 'Atomics.sub(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.sub(new TA(buffer), 0, 0)` throws TypeError');
|
||||||
}, views);
|
}, views);
|
||||||
|
@ -14,7 +14,7 @@ var buffer = new SharedArrayBuffer(1024);
|
|||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.sub(new TA(buffer), 0, 0);
|
Atomics.sub(new TA(buffer), 0, 0);
|
||||||
}, 'Atomics.sub(new TA(buffer), 0, 0) throws TypeError');
|
}, '`Atomics.sub(new TA(buffer), 0, 0)` throws TypeError');
|
||||||
}, floatArrayConstructors);
|
}, floatArrayConstructors);
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,5 +22,5 @@ const i32a = new Int32Array(
|
|||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.wait(i32a, IdxGen(i32a), 0, 0);
|
Atomics.wait(i32a, IdxGen(i32a), 0, 0);
|
||||||
}, 'Atomics.wait(i32a, IdxGen(i32a), 0, 0) throws RangeError');
|
}, '`Atomics.wait(i32a, IdxGen(i32a), 0, 0)` throws RangeError');
|
||||||
});
|
});
|
||||||
|
@ -21,6 +21,6 @@ const i64a = new BigInt64Array(
|
|||||||
|
|
||||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.wait(i64a, IdxGen(i64a), 0, 0);
|
Atomics.wait(i64a, IdxGen(i64a), 0n, 0);
|
||||||
}, 'Atomics.wait(i64a, IdxGen(i64a), 0, 0) throws RangeError');
|
}, '`Atomics.wait(i64a, IdxGen(i64a), 0n, 0)` throws RangeError');
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
// Copyright (C) 2018 Amal Hussein. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.wait
|
esid: sec-atomics.wait
|
||||||
description: >
|
description: >
|
||||||
@ -17,11 +16,8 @@ info: |
|
|||||||
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
||||||
flags: [CanBlockIsFalse]
|
flags: [CanBlockIsFalse]
|
||||||
---*/
|
---*/
|
||||||
|
const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8));
|
||||||
const i64a = new BigInt64Array(
|
|
||||||
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.wait(i64a, 0, 0, 0);
|
Atomics.wait(i64a, 0, 0n, 0);
|
||||||
});
|
}, '`Atomics.wait(i64a, 0, 0n, 0)` throws TypeError');
|
||||||
|
@ -32,9 +32,9 @@ $262.agent.start(`
|
|||||||
$262.agent.receiveBroadcast(function(sab) {
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
const i64a = new BigInt64Array(sab);
|
const i64a = new BigInt64Array(sab);
|
||||||
const before = $262.agent.monotonicNow();
|
const before = $262.agent.monotonicNow();
|
||||||
$262.agent.report(Atomics.wait(i64a, 0, 0, false));
|
$262.agent.report(Atomics.wait(i64a, 0, 0n, false));
|
||||||
$262.agent.report(Atomics.wait(i64a, 0, 0, valueOf));
|
$262.agent.report(Atomics.wait(i64a, 0, 0n, valueOf));
|
||||||
$262.agent.report(Atomics.wait(i64a, 0, 0, toPrimitive));
|
$262.agent.report(Atomics.wait(i64a, 0, 0n, toPrimitive));
|
||||||
$262.agent.report($262.agent.monotonicNow() - before);
|
$262.agent.report($262.agent.monotonicNow() - before);
|
||||||
$262.agent.leaving();
|
$262.agent.leaving();
|
||||||
});
|
});
|
||||||
@ -47,18 +47,30 @@ const i64a = new BigInt64Array(
|
|||||||
$262.agent.broadcast(i64a.buffer);
|
$262.agent.broadcast(i64a.buffer);
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
|
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
assert.sameValue(
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
$262.agent.getReport(),
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
const lapse = $262.agent.getReport();
|
const lapse = $262.agent.getReport();
|
||||||
assert(
|
assert(
|
||||||
lapse >= 0,
|
lapse >= 0,
|
||||||
`${lapse} should be greater than, or equal to 0`
|
'The result of `(lapse >= 0)` is true'
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
lapse <= $262.agent.MAX_TIME_EPSILON,
|
lapse <= $262.agent.MAX_TIME_EPSILON,
|
||||||
`${lapse} should be less than ${$262.agent.MAX_TIME_EPSILON}`
|
'The result of `(lapse <= $262.agent.MAX_TIME_EPSILON)` is true'
|
||||||
);
|
);
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
assert.sameValue(Atomics.wake(i64a, 0), 0, 'Atomics.wake(i64a, 0) returns 0');
|
||||||
|
|
||||||
|
@ -32,7 +32,19 @@ const toPrimitive = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
assert.sameValue(Atomics.wait(i64a, 0, 0, false), "timed-out");
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.wait(i64a, 0, 0, valueOf), "timed-out");
|
Atomics.wait(i64a, 0, 0n, false),
|
||||||
assert.sameValue(Atomics.wait(i64a, 0, 0, toPrimitive), "timed-out");
|
"timed-out",
|
||||||
|
'Atomics.wait(i64a, 0, 0n, false) returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.wait(i64a, 0, 0n, valueOf),
|
||||||
|
"timed-out",
|
||||||
|
'Atomics.wait(i64a, 0, 0n, valueOf) returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Atomics.wait(i64a, 0, 0n, toPrimitive),
|
||||||
|
"timed-out",
|
||||||
|
'Atomics.wait(i64a, 0, 0n, toPrimitive) returns "timed-out"'
|
||||||
|
);
|
||||||
|
|
||||||
|
@ -1,49 +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.wait
|
|
||||||
description: >
|
|
||||||
Test Atomics.wait on arrays that allow atomic operations,
|
|
||||||
in an Agent that is allowed to wait.
|
|
||||||
includes: [atomicsHelper.js]
|
|
||||||
features: [Atomics, BigInt]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
// Let's assume 'wait' is not allowed on the main thread,
|
|
||||||
// even in the shell.
|
|
||||||
|
|
||||||
$262.agent.start(`
|
|
||||||
const sab = new SharedArrayBuffer(1024);
|
|
||||||
const ab = new ArrayBuffer(16);
|
|
||||||
|
|
||||||
const good_indices = [ (view) => 0/-1, // -0
|
|
||||||
(view) => '-0',
|
|
||||||
(view) => view.length - 1,
|
|
||||||
(view) => ({ valueOf: () => 0 }),
|
|
||||||
(view) => ({ toString: () => '0', valueOf: false }) // non-callable valueOf triggers invocation of toString
|
|
||||||
];
|
|
||||||
|
|
||||||
const view = new BigInt64Array(sab, 32, 20);
|
|
||||||
|
|
||||||
view[0] = 0;
|
|
||||||
$262.agent.report("A " + Atomics.wait(view, 0, 0, 0))
|
|
||||||
$262.agent.report("B " + Atomics.wait(view, 0, 37, 0));
|
|
||||||
|
|
||||||
// In-bounds boundary cases for indexing
|
|
||||||
for ( let IdxGen of good_indices ) {
|
|
||||||
let Idx = IdxGen(view);
|
|
||||||
view.fill(0);
|
|
||||||
// Atomics.store() computes an index from Idx in the same way as other
|
|
||||||
// Atomics operations, not quite like view[Idx].
|
|
||||||
Atomics.store(view, Idx, 37);
|
|
||||||
$262.agent.report("C " + Atomics.wait(view, Idx, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
$262.agent.report("done");
|
|
||||||
$262.agent.leaving();
|
|
||||||
`);
|
|
||||||
|
|
||||||
assert.sameValue($262.agent.getReport(), 'A timed-out');
|
|
||||||
assert.sameValue($262.agent.getReport(), 'B not-equal');
|
|
||||||
assert.sameValue($262.agent.getReport(), 'C not-equal');
|
|
@ -20,7 +20,7 @@ features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
|||||||
$262.agent.start(`
|
$262.agent.start(`
|
||||||
$262.agent.receiveBroadcast(function(sab) {
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
const i64a = new BigInt64Array(sab);
|
const i64a = new BigInt64Array(sab);
|
||||||
$262.agent.report(Atomics.wait(i64a, 0, 0, NaN)); // NaN => +Infinity
|
$262.agent.report(Atomics.wait(i64a, 0, 0n, NaN)); // NaN => +Infinity
|
||||||
$262.agent.leaving();
|
$262.agent.leaving();
|
||||||
});
|
});
|
||||||
`);
|
`);
|
||||||
@ -31,5 +31,5 @@ const i64a = new BigInt64Array(
|
|||||||
|
|
||||||
$262.agent.broadcast(i64a.buffer);
|
$262.agent.broadcast(i64a.buffer);
|
||||||
$262.agent.sleep(100);
|
$262.agent.sleep(100);
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 1);
|
assert.sameValue(Atomics.wake(i64a, 0), 1, 'Atomics.wake(i64a, 0) returns 1');
|
||||||
assert.sameValue($262.agent.getReport(), 'ok');
|
assert.sameValue($262.agent.getReport(), 'ok', '$262.agent.getReport() returns "ok"');
|
||||||
|
@ -27,13 +27,13 @@ const poisoned = {
|
|||||||
|
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.wait(i64a, -Infinity, poisoned, poisoned);
|
Atomics.wait(i64a, -Infinity, poisoned, poisoned);
|
||||||
});
|
}, '`Atomics.wait(i64a, -Infinity, poisoned, poisoned)` throws RangeError');
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.wait(i64a, -7.999, poisoned, poisoned);
|
Atomics.wait(i64a, -7.999, poisoned, poisoned);
|
||||||
});
|
}, '`Atomics.wait(i64a, -7.999, poisoned, poisoned)` throws RangeError');
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.wait(i64a, -1, poisoned, poisoned);
|
Atomics.wait(i64a, -1, poisoned, poisoned);
|
||||||
});
|
}, '`Atomics.wait(i64a, -1, poisoned, poisoned)` throws RangeError');
|
||||||
assert.throws(RangeError, function() {
|
assert.throws(RangeError, function() {
|
||||||
Atomics.wait(i64a, -300, poisoned, poisoned);
|
Atomics.wait(i64a, -300, poisoned, poisoned);
|
||||||
});
|
}, '`Atomics.wait(i64a, -300, poisoned, poisoned)` throws RangeError');
|
||||||
|
@ -23,5 +23,9 @@ const i64a = new BigInt64Array(
|
|||||||
|
|
||||||
$262.agent.broadcast(i64a.buffer);
|
$262.agent.broadcast(i64a.buffer);
|
||||||
$262.agent.sleep(10);
|
$262.agent.sleep(10);
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(Atomics.wake(i64a, 0), 0, 'Atomics.wake(i64a, 0) returns 0');
|
||||||
|
@ -13,4 +13,8 @@ const i64a = new BigInt64Array(
|
|||||||
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
|
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(Atomics.wait(i64a, 0, 0, -1), "timed-out");
|
assert.sameValue(
|
||||||
|
Atomics.wait(i64a, 0, 0n, -1),
|
||||||
|
"timed-out",
|
||||||
|
'Atomics.wait(i64a, 0, 0n, -1) returns "timed-out"'
|
||||||
|
);
|
||||||
|
@ -40,7 +40,11 @@ $262.agent.sleep(10);
|
|||||||
const lapse = $262.agent.getReport();
|
const lapse = $262.agent.getReport();
|
||||||
assert(
|
assert(
|
||||||
lapse >= TIMEOUT,
|
lapse >= TIMEOUT,
|
||||||
`${lapse} should be at least ${TIMEOUT}`
|
'The result of `(lapse >= TIMEOUT)` is true'
|
||||||
);
|
);
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(Atomics.wake(i64a, 0), 0, 'Atomics.wake(i64a, 0) returns 0');
|
||||||
|
@ -18,7 +18,7 @@ $262.agent.start(`
|
|||||||
$262.agent.receiveBroadcast(function(sab) {
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
const i64a = new BigInt64Array(sab);
|
const i64a = new BigInt64Array(sab);
|
||||||
const before = $262.agent.monotonicNow();
|
const before = $262.agent.monotonicNow();
|
||||||
const unpark = Atomics.wait(i64a, 0, 0, ${TIMEOUT});
|
const unpark = Atomics.wait(i64a, 0, 0n, ${TIMEOUT});
|
||||||
$262.agent.report($262.agent.monotonicNow() - before);
|
$262.agent.report($262.agent.monotonicNow() - before);
|
||||||
$262.agent.report(unpark);
|
$262.agent.report(unpark);
|
||||||
$262.agent.leaving();
|
$262.agent.leaving();
|
||||||
@ -33,9 +33,13 @@ Atomics.add(i64a, 0, 1);
|
|||||||
const lapse = $262.agent.getReport();
|
const lapse = $262.agent.getReport();
|
||||||
assert(
|
assert(
|
||||||
lapse >= TIMEOUT,
|
lapse >= TIMEOUT,
|
||||||
`${lapse} should be at least ${TIMEOUT}`
|
'The result of `(lapse >= TIMEOUT)` is true'
|
||||||
);
|
);
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(Atomics.wake(i64a, 0), 0, 'Atomics.wake(i64a, 0) returns 0');
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ $262.agent.start(`
|
|||||||
$262.agent.receiveBroadcast(function(sab) {
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
const i64a = new BigInt64Array(sab);
|
const i64a = new BigInt64Array(sab);
|
||||||
const before = $262.agent.monotonicNow();
|
const before = $262.agent.monotonicNow();
|
||||||
const unpark = Atomics.wait(i64a, 0, 0, ${TIMEOUT});
|
const unpark = Atomics.wait(i64a, 0, 0n, ${TIMEOUT});
|
||||||
$262.agent.report($262.agent.monotonicNow() - before);
|
$262.agent.report($262.agent.monotonicNow() - before);
|
||||||
$262.agent.report(unpark);
|
$262.agent.report(unpark);
|
||||||
$262.agent.leaving();
|
$262.agent.leaving();
|
||||||
@ -32,9 +32,13 @@ Atomics.and(i64a, 0, 1);
|
|||||||
const lapse = $262.agent.getReport();
|
const lapse = $262.agent.getReport();
|
||||||
assert(
|
assert(
|
||||||
lapse >= TIMEOUT,
|
lapse >= TIMEOUT,
|
||||||
`${lapse} should be at least ${TIMEOUT}`
|
'The result of `(lapse >= TIMEOUT)` is true'
|
||||||
);
|
);
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(Atomics.wake(i64a, 0), 0, 'Atomics.wake(i64a, 0) returns 0');
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ $262.agent.start(`
|
|||||||
$262.agent.receiveBroadcast(function(sab) {
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
const i64a = new BigInt64Array(sab);
|
const i64a = new BigInt64Array(sab);
|
||||||
const before = $262.agent.monotonicNow();
|
const before = $262.agent.monotonicNow();
|
||||||
const unpark = Atomics.wait(i64a, 0, 0, ${TIMEOUT});
|
const unpark = Atomics.wait(i64a, 0, 0n, ${TIMEOUT});
|
||||||
$262.agent.report($262.agent.monotonicNow() - before);
|
$262.agent.report($262.agent.monotonicNow() - before);
|
||||||
$262.agent.report(unpark);
|
$262.agent.report(unpark);
|
||||||
$262.agent.leaving();
|
$262.agent.leaving();
|
||||||
@ -32,7 +32,11 @@ Atomics.compareExchange(i64a, 0, 0, 1);
|
|||||||
const lapse = $262.agent.getReport();
|
const lapse = $262.agent.getReport();
|
||||||
assert(
|
assert(
|
||||||
lapse >= TIMEOUT,
|
lapse >= TIMEOUT,
|
||||||
`${lapse} should be at least ${TIMEOUT}`
|
'The result of `(lapse >= TIMEOUT)` is true'
|
||||||
);
|
);
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(Atomics.wake(i64a, 0), 0, 'Atomics.wake(i64a, 0) returns 0');
|
||||||
|
@ -17,7 +17,7 @@ $262.agent.start(`
|
|||||||
$262.agent.receiveBroadcast(function(sab) {
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
const i64a = new BigInt64Array(sab);
|
const i64a = new BigInt64Array(sab);
|
||||||
const before = $262.agent.monotonicNow();
|
const before = $262.agent.monotonicNow();
|
||||||
const unpark = Atomics.wait(i64a, 0, 0, ${TIMEOUT});
|
const unpark = Atomics.wait(i64a, 0, 0n, ${TIMEOUT});
|
||||||
$262.agent.report($262.agent.monotonicNow() - before);
|
$262.agent.report($262.agent.monotonicNow() - before);
|
||||||
$262.agent.report(unpark);
|
$262.agent.report(unpark);
|
||||||
$262.agent.leaving();
|
$262.agent.leaving();
|
||||||
@ -32,8 +32,12 @@ Atomics.exchange(i64a, 0, 1);
|
|||||||
const lapse = $262.agent.getReport();
|
const lapse = $262.agent.getReport();
|
||||||
assert(
|
assert(
|
||||||
lapse >= TIMEOUT,
|
lapse >= TIMEOUT,
|
||||||
`${lapse} should be at least ${TIMEOUT}`
|
'The result of `(lapse >= TIMEOUT)` is true'
|
||||||
);
|
);
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(Atomics.wake(i64a, 0), 0, 'Atomics.wake(i64a, 0) returns 0');
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ $262.agent.start(`
|
|||||||
$262.agent.receiveBroadcast(function(sab) {
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
const i64a = new BigInt64Array(sab);
|
const i64a = new BigInt64Array(sab);
|
||||||
const before = $262.agent.monotonicNow();
|
const before = $262.agent.monotonicNow();
|
||||||
const unpark = Atomics.wait(i64a, 0, 0, ${TIMEOUT});
|
const unpark = Atomics.wait(i64a, 0, 0n, ${TIMEOUT});
|
||||||
$262.agent.report($262.agent.monotonicNow() - before);
|
$262.agent.report($262.agent.monotonicNow() - before);
|
||||||
$262.agent.report(unpark);
|
$262.agent.report(unpark);
|
||||||
$262.agent.leaving();
|
$262.agent.leaving();
|
||||||
@ -32,9 +32,13 @@ Atomics.or(i64a, 0, 1);
|
|||||||
const lapse = $262.agent.getReport();
|
const lapse = $262.agent.getReport();
|
||||||
assert(
|
assert(
|
||||||
lapse >= TIMEOUT,
|
lapse >= TIMEOUT,
|
||||||
`${lapse} should be at least ${TIMEOUT}`
|
'The result of `(lapse >= TIMEOUT)` is true'
|
||||||
);
|
);
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(Atomics.wake(i64a, 0), 0, 'Atomics.wake(i64a, 0) returns 0');
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ $262.agent.start(`
|
|||||||
$262.agent.receiveBroadcast(function(sab) {
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
const i64a = new BigInt64Array(sab);
|
const i64a = new BigInt64Array(sab);
|
||||||
const before = $262.agent.monotonicNow();
|
const before = $262.agent.monotonicNow();
|
||||||
const unpark = Atomics.wait(i64a, 0, 0, ${TIMEOUT});
|
const unpark = Atomics.wait(i64a, 0, 0n, ${TIMEOUT});
|
||||||
$262.agent.report($262.agent.monotonicNow() - before);
|
$262.agent.report($262.agent.monotonicNow() - before);
|
||||||
$262.agent.report(unpark);
|
$262.agent.report(unpark);
|
||||||
$262.agent.leaving();
|
$262.agent.leaving();
|
||||||
@ -32,8 +32,12 @@ Atomics.store(i64a, 0, 0x111111);
|
|||||||
const lapse = $262.agent.getReport();
|
const lapse = $262.agent.getReport();
|
||||||
assert(
|
assert(
|
||||||
lapse >= TIMEOUT,
|
lapse >= TIMEOUT,
|
||||||
`${lapse} should be at least ${TIMEOUT}`
|
'The result of `(lapse >= TIMEOUT)` is true'
|
||||||
);
|
);
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(Atomics.wake(i64a, 0), 0, 'Atomics.wake(i64a, 0) returns 0');
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ $262.agent.start(`
|
|||||||
$262.agent.receiveBroadcast(function(sab) {
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
const i64a = new BigInt64Array(sab);
|
const i64a = new BigInt64Array(sab);
|
||||||
const before = $262.agent.monotonicNow();
|
const before = $262.agent.monotonicNow();
|
||||||
const unpark = Atomics.wait(i64a, 0, 0, ${TIMEOUT});
|
const unpark = Atomics.wait(i64a, 0, 0n, ${TIMEOUT});
|
||||||
$262.agent.report($262.agent.monotonicNow() - before);
|
$262.agent.report($262.agent.monotonicNow() - before);
|
||||||
$262.agent.report(unpark);
|
$262.agent.report(unpark);
|
||||||
$262.agent.leaving();
|
$262.agent.leaving();
|
||||||
@ -32,7 +32,11 @@ Atomics.sub(i64a, 0, 1);
|
|||||||
const lapse = $262.agent.getReport();
|
const lapse = $262.agent.getReport();
|
||||||
assert(
|
assert(
|
||||||
lapse >= TIMEOUT,
|
lapse >= TIMEOUT,
|
||||||
`${lapse} should be at least ${TIMEOUT}`
|
'The result of `(lapse >= TIMEOUT)` is true'
|
||||||
);
|
);
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(Atomics.wake(i64a, 0), 0, 'Atomics.wake(i64a, 0) returns 0');
|
||||||
|
@ -17,7 +17,7 @@ $262.agent.start(`
|
|||||||
$262.agent.receiveBroadcast(function(sab) {
|
$262.agent.receiveBroadcast(function(sab) {
|
||||||
const i64a = new BigInt64Array(sab);
|
const i64a = new BigInt64Array(sab);
|
||||||
const before = $262.agent.monotonicNow();
|
const before = $262.agent.monotonicNow();
|
||||||
const unpark = Atomics.wait(i64a, 0, 0, ${TIMEOUT});
|
const unpark = Atomics.wait(i64a, 0, 0n, ${TIMEOUT});
|
||||||
$262.agent.report($262.agent.monotonicNow() - before);
|
$262.agent.report($262.agent.monotonicNow() - before);
|
||||||
$262.agent.report(unpark);
|
$262.agent.report(unpark);
|
||||||
$262.agent.leaving();
|
$262.agent.leaving();
|
||||||
@ -32,10 +32,14 @@ Atomics.xor(i64a, 0, 1);
|
|||||||
const lapse = $262.agent.getReport();
|
const lapse = $262.agent.getReport();
|
||||||
assert(
|
assert(
|
||||||
lapse >= TIMEOUT,
|
lapse >= TIMEOUT,
|
||||||
`${lapse} should be at least ${TIMEOUT}`
|
'The result of `(lapse >= TIMEOUT)` is true'
|
||||||
);
|
);
|
||||||
assert.sameValue($262.agent.getReport(), 'timed-out');
|
assert.sameValue(
|
||||||
assert.sameValue(Atomics.wake(i64a, 0), 0);
|
$262.agent.getReport(),
|
||||||
|
'timed-out',
|
||||||
|
'$262.agent.getReport() returns "timed-out"'
|
||||||
|
);
|
||||||
|
assert.sameValue(Atomics.wake(i64a, 0), 0, 'Atomics.wake(i64a, 0) returns 0');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ info: |
|
|||||||
|
|
||||||
...
|
...
|
||||||
5. If waitable is true, then
|
5. If waitable is true, then
|
||||||
a. If typeName is not "Int32Array" or "BigInt64Array",
|
a. If typeName is not "BigInt64Array",
|
||||||
throw a TypeError exception.
|
throw a TypeError exception.
|
||||||
|
|
||||||
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray, ArrayBuffer, DataView, let, arrow-function, for-of, Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
features: [Atomics, BigInt, SharedArrayBuffer, TypedArray, ArrayBuffer, DataView, let, arrow-function, for-of, Atomics, BigInt, SharedArrayBuffer, TypedArray]
|
||||||
@ -34,10 +34,10 @@ const poisoned = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.wait(i64a, 0, 0, 0);
|
Atomics.wait(i64a, 0, 0n, 0);
|
||||||
}, 'BigUint64Array');
|
}, '`Atomics.wait(i64a, 0, 0n, 0)` throws TypeError');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.wait(i64a, poisoned, poisoned, poisoned);
|
Atomics.wait(i64a, poisoned, poisoned, poisoned);
|
||||||
}, 'BigUint64Array');
|
}, '`Atomics.wait(i64a, poisoned, poisoned, poisoned)` throws TypeError');
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ const poisoned = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.wait(i64a, 0, 0, 0);
|
Atomics.wait(i64a, 0, 0n, 0);
|
||||||
}, 'Atomics.wait(i64a, 0, 0, 0) on ArrayBuffer throws TypeError');
|
}, '`Atomics.wait(i64a, 0, 0n, 0)` throws TypeError');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.wait(i64a, poisoned, poisoned, poisoned);
|
Atomics.wait(i64a, poisoned, poisoned, poisoned);
|
||||||
}, 'Atomics.wait(i64a, poisoned, poisoned, poisoned) on ArrayBuffer throws TypeError');
|
}, '`Atomics.wait(i64a, poisoned, poisoned, poisoned)` throws TypeError');
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user