Atomics: updates to tests

This commit is contained in:
Rick Waldron 2018-04-19 10:11:50 -04:00
parent 251a69acca
commit ac65ecab7c
111 changed files with 1422 additions and 854 deletions

View File

@ -20,6 +20,9 @@ var typedArrayConstructors = [
Uint8ClampedArray Uint8ClampedArray
]; ];
var floatArrayConstructors = typedArrayConstructors.slice(0, 2);
var intArrayConstructors = typedArrayConstructors.slice(2, 7);
/** /**
* The %TypedArray% intrinsic constructor function. * The %TypedArray% intrinsic constructor function.
*/ */

View File

@ -11,7 +11,7 @@ info: |
This property has the attributes { [[Writable]]: false, [[Enumerable]]: This property has the attributes { [[Writable]]: false, [[Enumerable]]:
false, [[Configurable]]: true }. false, [[Configurable]]: true }.
includes: [propertyHelper.js] includes: [propertyHelper.js]
features: [Atomics, Symbol.toStringTag] features: [Atomics, Symbol, Symbol.toStringTag]
---*/ ---*/
assert.sameValue(Atomics[Symbol.toStringTag], 'Atomics'); assert.sameValue(Atomics[Symbol.toStringTag], 'Atomics');

View File

@ -6,21 +6,20 @@ esid: sec-atomics.add
description: > description: >
Test range checking of Atomics.add on arrays that allow atomic operations Test range checking of Atomics.add on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; var views = intArrayConstructors.slice();
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
views.push(BigInt64Array); views.push(BigInt64Array);
views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
let view = new View(sab); let view = new TA(buffer);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
let Idx = IdxGen(view); assert.throws(RangeError, () => Atomics.add(view, IdxGen(view), 10));
assert.throws(RangeError, () => Atomics.add(view, Idx, 10));
}); });
}, views); }, views);

View File

@ -5,19 +5,18 @@
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, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
var ab = new ArrayBuffer(16); var ab = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; testWithTypedArrayConstructors(function(TA) {
testWithTypedArrayConstructors(function(View) {
// 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 View(sab, 32, 20); var view = new TA(sab, 32, 20);
var control = new View(ab, 0, 2); var control = new TA(ab, 0, 2);
// Add positive number // Add positive number
view[8] = 0; view[8] = 0;
@ -52,4 +51,4 @@ testWithTypedArrayConstructors(function(View) {
Atomics.store(view, Idx, 37); Atomics.store(view, Idx, 37);
assert.sameValue(Atomics.add(view, Idx, 0), 37); assert.sameValue(Atomics.add(view, Idx, 0), 37);
}); });
}, int_views); }, views);

View File

@ -6,7 +6,7 @@ esid: sec-atomics.add
description: > description: >
Test Atomics.add on view values other than TypedArrays Test Atomics.add on view values other than TypedArrays
includes: [testAtomics.js] includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer]
---*/ ---*/
testWithAtomicsNonViewValues(function(view) { testWithAtomicsNonViewValues(function(view) {

View File

@ -6,20 +6,17 @@ esid: sec-atomics.add
description: > description: >
Test Atomics.add on non-shared integer TypedArrays Test Atomics.add on non-shared integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/ ---*/
var ab = new ArrayBuffer(16); var ab = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
int_views.push(BigInt64Array); views.push(BigInt64Array);
int_views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
var view = new View(ab); assert.throws(TypeError, (() => Atomics.add(new TA(ab), 0, 0)));
}, views);
assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
}, int_views);

View File

@ -6,15 +6,11 @@ esid: sec-atomics.add
description: > description: >
Test Atomics.add on shared non-integer TypedArrays Test Atomics.add on shared non-integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
var other_views = [Uint8ClampedArray, Float32Array, Float64Array]; testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, (() => Atomics.add(new TA(buffer), 0, 0)));
testWithTypedArrayConstructors(function(View) { }, floatArrayConstructors);
var view = new View(sab);
assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
}, other_views);

View File

@ -6,21 +6,20 @@ esid: sec-atomics.and
description: > description: >
Test range checking of Atomics.and on arrays that allow atomic operations Test range checking of Atomics.and on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; var views = intArrayConstructors.slice();
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
views.push(BigInt64Array); views.push(BigInt64Array);
views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
let view = new View(sab); let view = new TA(buffer);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
let Idx = IdxGen(view); assert.throws(RangeError, () => Atomics.and(view, IdxGen(view), 10));
assert.throws(RangeError, () => Atomics.and(view, Idx, 10));
}); });
}, views); }, views);

View File

@ -5,19 +5,18 @@
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, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
var ab = new ArrayBuffer(16); var ab = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; testWithTypedArrayConstructors(function(TA) {
testWithTypedArrayConstructors(function(View) {
// 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 View(sab, 32, 20); var view = new TA(sab, 32, 20);
var control = new View(ab, 0, 2); var control = new TA(ab, 0, 2);
view[8] = 0x33333333; view[8] = 0x33333333;
control[0] = 0x33333333; control[0] = 0x33333333;
@ -59,4 +58,4 @@ testWithTypedArrayConstructors(function(View) {
Atomics.store(view, Idx, 37); Atomics.store(view, Idx, 37);
assert.sameValue(Atomics.and(view, Idx, 0), 37); assert.sameValue(Atomics.and(view, Idx, 0), 37);
}); });
}, int_views); }, views);

View File

@ -6,7 +6,7 @@ esid: sec-atomics.and
description: > description: >
Test Atomics.and on view values other than TypedArrays Test Atomics.and on view values other than TypedArrays
includes: [testAtomics.js] includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer]
---*/ ---*/
testWithAtomicsNonViewValues(function(view) { testWithAtomicsNonViewValues(function(view) {

View File

@ -6,20 +6,17 @@ esid: sec-atomics.and
description: > description: >
Test Atomics.and on non-shared integer TypedArrays Test Atomics.and on non-shared integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/ ---*/
var ab = new ArrayBuffer(16); var buffer = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
int_views.push(BigInt64Array); views.push(BigInt64Array);
int_views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
var view = new View(ab); assert.throws(TypeError, (() => Atomics.and(new TA(buffer), 0, 0)));
}, views);
assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
}, int_views);

View File

@ -6,15 +6,11 @@ esid: sec-atomics.and
description: > description: >
Test Atomics.and on shared non-integer TypedArrays Test Atomics.and on shared non-integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
var other_views = [Uint8ClampedArray, Float32Array, Float64Array]; testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, (() => Atomics.and(new TA(buffer), 0, 0)));
testWithTypedArrayConstructors(function(View) { }, floatArrayConstructors);
var view = new View(sab);
assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
}, other_views);

View File

@ -6,21 +6,20 @@ esid: sec-atomics.compareexchange
description: > description: >
Test range checking of Atomics.compareExchange on arrays that allow atomic operations Test range checking of Atomics.compareExchange on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; var views = intArrayConstructors.slice();
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
views.push(BigInt64Array); views.push(BigInt64Array);
views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
let view = new View(sab); let view = new TA(buffer);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
let Idx = IdxGen(view); assert.throws(RangeError, () => Atomics.compareExchange(view, IdxGen(view), 10, 0));
assert.throws(RangeError, () => Atomics.compareExchange(view, Idx, 10, 0));
}); });
}, views); }, views);

View File

@ -5,26 +5,18 @@
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, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
var ab = new ArrayBuffer(16); var ab = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; testWithTypedArrayConstructors(function(TA) {
var 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
];
testWithTypedArrayConstructors(function(View) {
// 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 View(sab, 32, 20); var view = new TA(sab, 32, 20);
var control = new View(ab, 0, 2); var control = new TA(ab, 0, 2);
// Performs the exchange // Performs the exchange
view[8] = 0; view[8] = 0;
@ -71,4 +63,4 @@ testWithTypedArrayConstructors(function(View) {
Atomics.store(view, Idx, 37); Atomics.store(view, Idx, 37);
assert.sameValue(Atomics.compareExchange(view, Idx, 37, 0), 37); assert.sameValue(Atomics.compareExchange(view, Idx, 37, 0), 37);
}); });
}, int_views); }, views);

View File

@ -6,7 +6,7 @@ esid: sec-atomics.compareexchange
description: > description: >
Test Atomics.compareExchange on view values other than TypedArrays Test Atomics.compareExchange on view values other than TypedArrays
includes: [testAtomics.js] includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer]
---*/ ---*/
testWithAtomicsNonViewValues(function(view) { testWithAtomicsNonViewValues(function(view) {

View File

@ -6,20 +6,17 @@ esid: sec-atomics.compareexchange
description: > description: >
Test Atomics.compareExchange on non-shared integer TypedArrays Test Atomics.compareExchange on non-shared integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/ ---*/
var ab = new ArrayBuffer(16); var buffer = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
int_views.push(BigInt64Array); views.push(BigInt64Array);
int_views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
var view = new View(ab); assert.throws(TypeError, (() => Atomics.compareExchange(new TA(buffer), 0, 0, 0)));
}, views);
assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
}, int_views);

View File

@ -6,15 +6,11 @@ esid: sec-atomics.compareexchange
description: > description: >
Test Atomics.compareExchange on shared non-integer TypedArrays Test Atomics.compareExchange on shared non-integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
var other_views = [Uint8ClampedArray, Float32Array, Float64Array]; testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, (() => Atomics.compareExchange(new TA(buffer), 0, 0, 0)));
testWithTypedArrayConstructors(function(View) { }, floatArrayConstructors);
var view = new View(sab);
assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
}, other_views);

View File

@ -6,21 +6,20 @@ esid: sec-atomics.exchange
description: > description: >
Test range checking of Atomics.exchange on arrays that allow atomic operations Test range checking of Atomics.exchange on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; var views = intArrayConstructors.slice();
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
views.push(BigInt64Array); views.push(BigInt64Array);
views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
let view = new View(sab); let view = new TA(buffer);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
let Idx = IdxGen(view); assert.throws(RangeError, () => Atomics.exchange(view, IdxGen(view), 10, 0));
assert.throws(RangeError, () => Atomics.exchange(view, Idx, 10, 0));
}); });
}, views); }, views);

View File

@ -5,19 +5,18 @@
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, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
var ab = new ArrayBuffer(16); var ab = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; testWithTypedArrayConstructors(function(TA) {
testWithTypedArrayConstructors(function(View) {
// 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 View(sab, 32, 20); var view = new TA(sab, 32, 20);
var control = new View(ab, 0, 2); var 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,
@ -53,4 +52,4 @@ testWithTypedArrayConstructors(function(View) {
Atomics.store(view, Idx, 37); Atomics.store(view, Idx, 37);
assert.sameValue(Atomics.exchange(view, Idx, 0), 37); assert.sameValue(Atomics.exchange(view, Idx, 0), 37);
}); });
}, int_views); }, views);

View File

@ -6,7 +6,7 @@ esid: sec-atomics.exchange
description: > description: >
Test Atomics.exchange on view values other than TypedArrays Test Atomics.exchange on view values other than TypedArrays
includes: [testAtomics.js] includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer]
---*/ ---*/
testWithAtomicsNonViewValues(function(view) { testWithAtomicsNonViewValues(function(view) {

View File

@ -6,20 +6,17 @@ esid: sec-atomics.exchange
description: > description: >
Test Atomics.exchange on non-shared integer TypedArrays Test Atomics.exchange on non-shared integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/ ---*/
var ab = new ArrayBuffer(16); var buffer = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
int_views.push(BigInt64Array); views.push(BigInt64Array);
int_views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
var view = new View(ab); assert.throws(TypeError, (() => Atomics.exchange(new TA(buffer), 0, 0)));
}, views);
assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
}, int_views);

View File

@ -6,15 +6,11 @@ esid: sec-atomics.exchange
description: > description: >
Test Atomics.exchange on shared non-integer TypedArrays Test Atomics.exchange on shared non-integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
var other_views = [Uint8ClampedArray, Float32Array, Float64Array]; testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, (() => Atomics.exchange(new TA(buffer), 0, 0)));
testWithTypedArrayConstructors(function(View) { }, floatArrayConstructors);
var view = new View(sab);
assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
}, other_views);

View File

@ -8,10 +8,10 @@ description: >
features: [Atomics] features: [Atomics]
---*/ ---*/
assert.sameValue(false, Atomics.isLockFree(hide(3, Number.NaN))); assert.sameValue(Atomics.isLockFree(hide(3, Number.NaN)), false);
assert.sameValue(false, Atomics.isLockFree(hide(3, -1))); assert.sameValue(Atomics.isLockFree(hide(3, -1)), false);
assert.sameValue(false, Atomics.isLockFree(hide(3, 3.14))); assert.sameValue(Atomics.isLockFree(hide(3, 3.14)), false);
assert.sameValue(false, Atomics.isLockFree(hide(3, 0))); assert.sameValue(Atomics.isLockFree(hide(3, 0)), false);
assert.sameValue(Atomics.isLockFree('1'), Atomics.isLockFree(1)); assert.sameValue(Atomics.isLockFree('1'), Atomics.isLockFree(1));
assert.sameValue(Atomics.isLockFree('3'), Atomics.isLockFree(3)); assert.sameValue(Atomics.isLockFree('3'), Atomics.isLockFree(3));
@ -24,7 +24,8 @@ assert.sameValue(Atomics.isLockFree(1), Atomics.isLockFree({toString: () => '1'}
assert.sameValue(Atomics.isLockFree(3), Atomics.isLockFree({toString: () => '3'})); assert.sameValue(Atomics.isLockFree(3), Atomics.isLockFree({toString: () => '3'}));
function hide(k, x) { function hide(k, x) {
if (k) if (k) {
return hide(k - 3, x) + x; return hide(k - 3, x) + x;
}
return 0; return 0;
} }

View File

@ -13,36 +13,33 @@ var sizes = [ 1, 2, 3, 4, 5, 6, 7, 8,
var answers = [ {}, {}, false, true, false, false, false, false, var answers = [ {}, {}, false, true, false, false, false, false,
false, false, false, false]; false, false, false, false];
function testIsLockFree() { var saved = {};
var saved = {};
// This should defeat most optimizations. // This should defeat most optimizations.
for (var i = 0; i < sizes.length; i++) { for (var i = 0; i < sizes.length; i++) {
var v = Atomics.isLockFree(sizes[i]); var v = Atomics.isLockFree(sizes[i]);
var a = answers[i]; var a = answers[i];
assert.sameValue(typeof v, 'boolean'); assert.sameValue(typeof v, 'boolean');
if (typeof a == 'boolean') if (typeof a == 'boolean') {
assert.sameValue(v, a); assert.sameValue(v, a);
else } else {
saved[sizes[i]] = v; saved[sizes[i]] = v;
} }
// This ought to be optimizable. Make sure the answers are the same
// as for the unoptimized case.
assert.sameValue(Atomics.isLockFree(1), saved[1]);
assert.sameValue(Atomics.isLockFree(2), saved[2]);
assert.sameValue(Atomics.isLockFree(3), false);
assert.sameValue(Atomics.isLockFree(4), true);
assert.sameValue(Atomics.isLockFree(5), false);
assert.sameValue(Atomics.isLockFree(6), false);
assert.sameValue(Atomics.isLockFree(7), false);
assert.sameValue(Atomics.isLockFree(8), false);
assert.sameValue(Atomics.isLockFree(9), false);
assert.sameValue(Atomics.isLockFree(10), false);
assert.sameValue(Atomics.isLockFree(11), false);
assert.sameValue(Atomics.isLockFree(12), false);
} }
testIsLockFree(); // This ought to be optimizable. Make sure the answers are the same
// as for the unoptimized case.
assert.sameValue(Atomics.isLockFree(1), saved[1]);
assert.sameValue(Atomics.isLockFree(2), saved[2]);
assert.sameValue(Atomics.isLockFree(3), false);
assert.sameValue(Atomics.isLockFree(4), true);
assert.sameValue(Atomics.isLockFree(5), false);
assert.sameValue(Atomics.isLockFree(6), false);
assert.sameValue(Atomics.isLockFree(7), false);
assert.sameValue(Atomics.isLockFree(8), false);
assert.sameValue(Atomics.isLockFree(9), false);
assert.sameValue(Atomics.isLockFree(10), false);
assert.sameValue(Atomics.isLockFree(11), false);
assert.sameValue(Atomics.isLockFree(12), false);

View File

@ -6,21 +6,20 @@ esid: sec-atomics.load
description: > description: >
Test range checking of Atomics.load on arrays that allow atomic operations Test range checking of Atomics.load on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; var views = intArrayConstructors.slice();
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
views.push(BigInt64Array); views.push(BigInt64Array);
views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
let view = new View(sab); let view = new TA(buffer);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
let Idx = IdxGen(view); assert.throws(RangeError, () => Atomics.load(view, IdxGen(view)));
assert.throws(RangeError, () => Atomics.load(view, Idx));
}); });
}, views); }, views);

View File

@ -5,19 +5,19 @@
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, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
var ab = new ArrayBuffer(16); var ab = new ArrayBuffer(16);
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; var views = intArrayConstructors.slice();
testWithTypedArrayConstructors(function(View) { 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 View(sab, 32, 20); var view = new TA(sab, 32, 20);
var control = new View(ab, 0, 2); var control = new TA(ab, 0, 2);
view[3] = -5; view[3] = -5;
control[0] = -5; control[0] = -5;
@ -43,4 +43,4 @@ testWithTypedArrayConstructors(function(View) {
Atomics.store(view, Idx, 37); Atomics.store(view, Idx, 37);
assert.sameValue(Atomics.load(view, Idx), 37); assert.sameValue(Atomics.load(view, Idx), 37);
}); });
}, int_views); }, views);

View File

@ -6,7 +6,7 @@ esid: sec-atomics.load
description: > description: >
Test Atomics.load on view values other than TypedArrays Test Atomics.load on view values other than TypedArrays
includes: [testAtomics.js] includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer]
---*/ ---*/
testWithAtomicsNonViewValues(function(view) { testWithAtomicsNonViewValues(function(view) {

View File

@ -6,20 +6,20 @@ esid: sec-atomics.load
description: > description: >
Test Atomics.load on non-shared integer TypedArrays Test Atomics.load on non-shared integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/ ---*/
var ab = new ArrayBuffer(16); var ab = new ArrayBuffer(16);
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; var views = intArrayConstructors.slice();
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
int_views.push(BigInt64Array); views.push(BigInt64Array);
int_views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
var view = new View(ab); var view = new TA(ab);
assert.throws(TypeError, (() => Atomics.load(view, 0))); assert.throws(TypeError, (() => Atomics.load(view, 0)));
}, int_views); }, views);

View File

@ -6,15 +6,10 @@ esid: sec-atomics.load
description: > description: >
Test Atomics.load on shared non-integer TypedArrays Test Atomics.load on shared non-integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
testWithTypedArrayConstructors(function(TA) {
var other_views = [Uint8ClampedArray, Float32Array, Float64Array]; assert.throws(TypeError, (() => Atomics.load(new TA(buffer), 0)));
}, floatArrayConstructors);
testWithTypedArrayConstructors(function(View) {
var view = new View(sab);
assert.throws(TypeError, (() => Atomics.load(view, 0)));
}, other_views);

View File

@ -6,21 +6,20 @@ esid: sec-atomics.or
description: > description: >
Test range checking of Atomics.or on arrays that allow atomic operations Test range checking of Atomics.or on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; var views = intArrayConstructors.slice();
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
views.push(BigInt64Array); views.push(BigInt64Array);
views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
let view = new View(sab); let view = new TA(buffer);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
let Idx = IdxGen(view); assert.throws(RangeError, () => Atomics.or(view, IdxGen(view), 10));
assert.throws(RangeError, () => Atomics.or(view, Idx, 10));
}); });
}, views); }, views);

View File

@ -5,18 +5,18 @@
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, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
var ab = new ArrayBuffer(16); var ab = new ArrayBuffer(16);
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; var views = intArrayConstructors.slice();
testWithTypedArrayConstructors(function(View) { 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 View(sab, 32, 20); var view = new TA(sab, 32, 20);
var control = new View(ab, 0, 2); var control = new TA(ab, 0, 2);
view[8] = 0x33333333; view[8] = 0x33333333;
control[0] = 0x33333333; control[0] = 0x33333333;
@ -58,4 +58,4 @@ testWithTypedArrayConstructors(function(View) {
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);
}); });
}, int_views); }, views);

View File

@ -6,7 +6,7 @@ esid: sec-atomics.or
description: > description: >
Test Atomics.or on view values other than TypedArrays Test Atomics.or on view values other than TypedArrays
includes: [testAtomics.js] includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer]
---*/ ---*/
testWithAtomicsNonViewValues(function(view) { testWithAtomicsNonViewValues(function(view) {

View File

@ -6,20 +6,17 @@ esid: sec-atomics.or
description: > description: >
Test Atomics.or on non-shared integer TypedArrays Test Atomics.or on non-shared integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/ ---*/
var ab = new ArrayBuffer(16); var buffer = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
int_views.push(BigInt64Array); views.push(BigInt64Array);
int_views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
var view = new View(ab); assert.throws(TypeError, (() => Atomics.or(new TA(buffer), 0, 0)));
}, views);
assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
}, int_views);

View File

@ -6,15 +6,13 @@ esid: sec-atomics.or
description: > description: >
Test Atomics.or on shared non-integer TypedArrays Test Atomics.or on shared non-integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
var other_views = [Uint8ClampedArray, Float32Array, Float64Array]; testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, (() => Atomics.or(new TA(buffer), 0, 0)));
}, floatArrayConstructors);
testWithTypedArrayConstructors(function(View) {
var view = new View(sab);
assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
}, other_views);

View File

@ -6,21 +6,20 @@ esid: sec-atomics.store
description: > description: >
Test range checking of Atomics.store on arrays that allow atomic operations Test range checking of Atomics.store on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; var views = intArrayConstructors.slice();
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
views.push(BigInt64Array); views.push(BigInt64Array);
views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
let view = new View(sab); let view = new TA(buffer);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
let Idx = IdxGen(view); assert.throws(RangeError, () => Atomics.store(view, IdxGen(view), 10));
assert.throws(RangeError, () => Atomics.store(view, Idx, 10));
}); });
}, views); }, views);

View File

@ -5,19 +5,18 @@
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, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
var ab = new ArrayBuffer(16); var ab = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; testWithTypedArrayConstructors(function(TA) {
testWithTypedArrayConstructors(function(View) {
// 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 View(sab, 32, 20); var view = new TA(sab, 32, 20);
var control = new View(ab, 0, 2); var control = new TA(ab, 0, 2);
for (let val of [10, -5, for (let val of [10, -5,
12345, 12345,
@ -44,15 +43,18 @@ testWithTypedArrayConstructors(function(View) {
Atomics.store(view, Idx, 37); Atomics.store(view, Idx, 37);
assert.sameValue(Atomics.load(view, Idx), 37); assert.sameValue(Atomics.load(view, Idx), 37);
}); });
}, int_views); }, views);
function ToInteger(v) { function ToInteger(v) {
v = +v; v = +v;
if (isNaN(v)) if (isNaN(v)) {
return 0; return 0;
if (v == 0 || !isFinite(v)) }
if (v == 0 || !isFinite(v)) {
return v; return v;
if (v < 0) }
if (v < 0) {
return -Math.floor(Math.abs(v)); return -Math.floor(Math.abs(v));
}
return Math.floor(v); return Math.floor(v);
} }

View File

@ -6,7 +6,7 @@ esid: sec-atomics.store
description: > description: >
Test Atomics.store on view values other than TypedArrays Test Atomics.store on view values other than TypedArrays
includes: [testAtomics.js] includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer]
---*/ ---*/
testWithAtomicsNonViewValues(function(view) { testWithAtomicsNonViewValues(function(view) {

View File

@ -6,20 +6,17 @@ esid: sec-atomics.store
description: > description: >
Test Atomics.store on non-shared integer TypedArrays Test Atomics.store on non-shared integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/ ---*/
var ab = new ArrayBuffer(16); var buffer = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
int_views.push(BigInt64Array); views.push(BigInt64Array);
int_views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
var view = new View(ab); assert.throws(TypeError, (() => Atomics.store(new TA(ab), 0, 0)));
}, views);
assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
}, int_views);

View File

@ -6,15 +6,14 @@ esid: sec-atomics.store
description: > description: >
Test Atomics.store on shared non-integer TypedArrays Test Atomics.store on shared non-integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, (() => Atomics.store(new TA(buffer), 0, 0)));
}, floatArrayConstructors);
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
testWithTypedArrayConstructors(function(View) {
var view = new View(sab);
assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
}, other_views);

View File

@ -6,21 +6,20 @@ esid: sec-atomics.sub
description: > description: >
Test range checking of Atomics.sub on arrays that allow atomic operations Test range checking of Atomics.sub on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(8); var buffer = new SharedArrayBuffer(8);
var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; var views = intArrayConstructors.slice();
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
views.push(BigInt64Array); views.push(BigInt64Array);
views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
let view = new View(sab); let view = new TA(buffer);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
let Idx = IdxGen(view); assert.throws(RangeError, () => Atomics.sub(view, IdxGen(view), 10));
assert.throws(RangeError, () => Atomics.sub(view, Idx, 10));
}); });
}, views); }, views);

View File

@ -5,19 +5,18 @@
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, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
var ab = new ArrayBuffer(16); var ab = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; testWithTypedArrayConstructors(function(TA) {
testWithTypedArrayConstructors(function(View) {
// 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 View(sab, 32, 20); var view = new TA(sab, 32, 20);
var control = new View(ab, 0, 2); var control = new TA(ab, 0, 2);
view[8] = 100; view[8] = 100;
assert.sameValue(Atomics.sub(view, 8, 10), 100, assert.sameValue(Atomics.sub(view, 8, 10), 100,
@ -52,4 +51,4 @@ testWithTypedArrayConstructors(function(View) {
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);
}); });
}, int_views); }, views);

View File

@ -6,7 +6,7 @@ esid: sec-atomics.sub
description: > description: >
Test Atomics.sub on view values other than TypedArrays Test Atomics.sub on view values other than TypedArrays
includes: [testAtomics.js] includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer]
---*/ ---*/
testWithAtomicsNonViewValues(function(view) { testWithAtomicsNonViewValues(function(view) {

View File

@ -6,20 +6,17 @@ esid: sec-atomics.sub
description: > description: >
Test Atomics.sub on non-shared integer TypedArrays Test Atomics.sub on non-shared integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/ ---*/
var ab = new ArrayBuffer(16); var buffer = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
int_views.push(BigInt64Array); views.push(BigInt64Array);
int_views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
var view = new View(ab); assert.throws(TypeError, (() => Atomics.sub(new TA(ab), 0, 0)));
}, views);
assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
}, int_views);

View File

@ -6,15 +6,14 @@ esid: sec-atomics.sub
description: > description: >
Test Atomics.sub on shared non-integer TypedArrays Test Atomics.sub on shared non-integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, (() => Atomics.sub(new TA(buffer), 0, 0)));
}, floatArrayConstructors);
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
testWithTypedArrayConstructors(function(View) {
var view = new View(sab);
assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
}, other_views);

View File

@ -14,12 +14,13 @@ info: |
6. Let B be AgentCanSuspend(). 6. Let B be AgentCanSuspend().
7. If B is false, throw a TypeError exception. 7. If B is false, throw a TypeError exception.
... ...
features: [Atomics, SharedArrayBuffer, TypedArray, CannotSuspendMainAgent] features: [Atomics, SharedArrayBuffer, TypedArray]
flags: [CanBlockIsFalse]
---*/ ---*/
var sab = new SharedArrayBuffer(4); var buffer = new SharedArrayBuffer(4);
var int32Array = new Int32Array(sab); var int32Array = new Int32Array(buffer);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wait(int32Array, 0, 0, 0); Atomics.wait(int32Array, 0, 0, 0);
}); });

View File

@ -13,9 +13,17 @@ description: >
19. Else, 19. Else,
a.Perform RemoveWaiter(WL, W). a.Perform RemoveWaiter(WL, W).
includes: [atomicsHelper.js] includes: [atomicsHelper.js]
features: [Atomics] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100);
}
return r;
}
$262.agent.start( $262.agent.start(
` `
$262.agent.receiveBroadcast(function (sab, id) { $262.agent.receiveBroadcast(function (sab, id) {
@ -33,9 +41,3 @@ $262.agent.broadcast(ia.buffer);
assert.sameValue(getReport(), "timed-out"); assert.sameValue(getReport(), "timed-out");
assert.sameValue((getReport() | 0) >= 500 - $ATOMICS_MAX_TIME_EPSILON, true); assert.sameValue((getReport() | 0) >= 500 - $ATOMICS_MAX_TIME_EPSILON, true);
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null)
$262.agent.sleep(100);
return r;
}

View File

@ -0,0 +1,68 @@
// Copyright (C) 2018 Amal Hussein. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
False timeout arg should result in an +0 timeout
info: |
Atomics.wait( typedArray, index, value, timeout )
4. Let q be ? ToNumber(timeout).
Boolean -> If argument is true, return 1. If argument is false, return +0.
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100);
}
return r;
}
$262.agent.start(
`
var valueOf = {
valueOf: function() {
return false;
}
};
var toPrimitive = {
[Symbol.toPrimitive]: function() {
return false;
}
};
$262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab);
var start = Date.now();
$262.agent.report(Atomics.wait(int32Array, 0, 0, false));
$262.agent.report(Atomics.wait(int32Array, 0, 0, valueOf));
$262.agent.report(Atomics.wait(int32Array, 0, 0, toPrimitive));
$262.agent.report(Date.now() - start);
$262.agent.leaving();
})
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(int32Array.buffer);
$262.agent.sleep(150);
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
var timeDiffReport = getReport();
assert(timeDiffReport >= 0, 'timeout should be a min of 0ms');
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -1,4 +1,4 @@
// 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.
/*--- /*---
@ -8,45 +8,30 @@ description: >
info: | info: |
Atomics.wait( typedArray, index, value, timeout ) Atomics.wait( typedArray, index, value, timeout )
4.Let q be ? ToNumber(timeout). 4. Let q be ? ToNumber(timeout).
...
Null Return +0. Boolean -> If argument is true, return 1. If argument is false, return +0.
Boolean If argument is true, return 1. If argument is false, return +0.
features: [ Atomics, SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
includes: [ atomicsHelper.js ] flags: [CanBlockIsFalse]
---*/ ---*/
function getReport() { var buffer = new SharedArrayBuffer(1024);
var r; var int32Array = new Int32Array(buffer);
while ((r = $262.agent.getReport()) == null)
$262.agent.sleep(100);
return r;
}
$262.agent.start( var valueOf = {
` valueOf: function() {
$262.agent.receiveBroadcast(function (sab) { return false;
var int32Array = new Int32Array(sab); }
var start = Date.now(); };
$262.agent.report(Atomics.wait(int32Array, 0, 0, false)); // false => +0
$262.agent.report(Date.now() - start);
$262.agent.leaving();
})
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)); var toPrimitive = {
[Symbol.toPrimitive]: function() {
return false;
}
};
$262.agent.broadcast(int32Array.buffer); assert.sameValue(Atomics.wait(int32Array, 0, 0, false), "timed-out");
assert.sameValue(Atomics.wait(int32Array, 0, 0, valueOf), "timed-out");
assert.sameValue(Atomics.wait(int32Array, 0, 0, toPrimitive), "timed-out");
$262.agent.sleep(150);
var atomicsReport = getReport();
var timeDiffReport = getReport();
assert.sameValue(atomicsReport, 'timed-out');
assert(timeDiffReport >= 0, 'timeout should be a min of 0ms');
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -42,17 +42,19 @@ for ( let IdxGen of good_indices ) {
$262.agent.report("done"); $262.agent.report("done");
$262.agent.leaving(); $262.agent.leaving();
`) `);
assert.sameValue(getReport(), "A timed-out"); assert.sameValue(getReport(), "A timed-out");
assert.sameValue(getReport(), "B not-equal"); // Even with zero timeout assert.sameValue(getReport(), "B not-equal"); // Even with zero timeout
var r; var r;
while ((r = getReport()) != "done") while ((r = getReport()) != "done") {
assert.sameValue(r, "C not-equal"); assert.sameValue(r, "C not-equal");
}
function getReport() { function getReport() {
var r; var r;
while ((r = $262.agent.getReport()) == null) while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100); $262.agent.sleep(100);
}
return r; return r;
} }

View File

@ -12,13 +12,15 @@ info: |
... ...
Undefined Return NaN. Undefined Return NaN.
5.If q is NaN, let t be +, else let t be max(q, 0) 5.If q is NaN, let t be +, else let t be max(q, 0)
features: [ Atomics, SharedArrayBuffer, TypedArray ]
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
function getReport() { function getReport() {
var r; var r;
while ((r = $262.agent.getReport()) == null) while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100); $262.agent.sleep(100);
}
return r; return r;
} }
@ -34,11 +36,7 @@ $262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)); var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(int32Array.buffer); $262.agent.broadcast(int32Array.buffer);
$262.agent.sleep(500); // Ample time $262.agent.sleep(500); // Ample time
assert.sameValue($262.agent.getReport(), null); assert.sameValue(getReport(), null);
assert.sameValue(Atomics.wake(int32Array, 0), 1); assert.sameValue(Atomics.wake(int32Array, 0), 1);
assert.sameValue(getReport(), "ok");

View File

@ -13,7 +13,7 @@ info: |
2.Let accessIndex be ? ToIndex(requestIndex). 2.Let accessIndex be ? ToIndex(requestIndex).
... ...
2.b If integerIndex < 0, throw a RangeError exception 2.b If integerIndex < 0, throw a RangeError exception
features: [ Atomics , SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
@ -24,7 +24,15 @@ var poisoned = {
} }
}; };
assert.throws(RangeError, () => Atomics.wait(int32Array, -Infinity, poisoned, poisoned)); assert.throws(RangeError, function() {
assert.throws(RangeError, () => Atomics.wait(int32Array, -7.999, poisoned, poisoned)); Atomics.wait(int32Array, -Infinity, poisoned, poisoned);
assert.throws(RangeError, () => Atomics.wait(int32Array, -1, poisoned, poisoned)); });
assert.throws(RangeError, () => Atomics.wait(int32Array, -300, poisoned, poisoned)); assert.throws(RangeError, function() {
Atomics.wait(int32Array, -7.999, poisoned, poisoned);
});
assert.throws(RangeError, function() {
Atomics.wait(int32Array, -1, poisoned, poisoned);
});
assert.throws(RangeError, function() {
Atomics.wait(int32Array, -300, poisoned, poisoned);
});

View File

@ -0,0 +1,33 @@
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
Test that Atomics.wait times out with a negative timeout
features: [Atomics, SharedArrayBuffer, TypedArray]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100);
}
return r;
}
$262.agent.start(
`
$262.agent.receiveBroadcast(function(sab, id) {
var ia = new Int32Array(sab);
$262.agent.report(Atomics.wait(ia, 0, 0, -5)); // -5 => 0
$262.agent.leaving();
})
`);
var buffer = new SharedArrayBuffer(1024);
var int32Array = new Int32Array(buffer);
$262.agent.broadcast(int32Array.buffer);
assert.sameValue(getReport(), "timed-out");
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -5,26 +5,11 @@
esid: sec-atomics.wait esid: sec-atomics.wait
description: > description: >
Test that Atomics.wait times out with a negative timeout Test that Atomics.wait times out with a negative timeout
features: [Atomics] features: [Atomics, SharedArrayBuffer, TypedArray]
flags: [CanBlockIsFalse]
---*/ ---*/
$262.agent.start( var buffer = new SharedArrayBuffer(1024);
` var int32Array = new Int32Array(buffer);
$262.agent.receiveBroadcast(function (sab, id) {
var ia = new Int32Array(sab);
$262.agent.report(Atomics.wait(ia, 0, 0, -5)); // -5 => 0
$262.agent.leaving();
})
`);
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)); assert.sameValue(Atomics.wait(int32Array, 0, 0, -1), "timed-out");
$262.agent.broadcast(ia.buffer);
assert.sameValue(getReport(), "timed-out");
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null)
$262.agent.sleep(100);
return r;
}

View File

@ -7,7 +7,7 @@ description: >
Test that Atomics.wait actually waits and does not spuriously wake Test that Atomics.wait actually waits and does not spuriously wake
up when the memory value is changed. up when the memory value is changed.
includes: [atomicsHelper.js] includes: [atomicsHelper.js]
features: [Atomics] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
$262.agent.start( $262.agent.start(
@ -33,7 +33,8 @@ assert.sameValue((getReport() | 0) >= 1000 - $ATOMICS_MAX_TIME_EPSILON, true);
function getReport() { function getReport() {
var r; var r;
while ((r = $262.agent.getReport()) == null) while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100); $262.agent.sleep(100);
}
return r; return r;
} }

View File

@ -12,7 +12,7 @@ info: |
... ...
5.If onlyInt32 is true, then 5.If onlyInt32 is true, then
If typeName is not "Int32Array", throw a TypeError exception. If typeName is not "Int32Array", throw a TypeError exception.
features: [ Atomics, TypedArray ] features: [Atomics, Float32Array, Float64Array, Int8Array, TypedArray, Uint16Array, Uint8Array, Uint8ClampedArray]
---*/ ---*/
var poisoned = { var poisoned = {

View File

@ -12,7 +12,7 @@ info: |
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception. 9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
... ...
4.If bufferData is a Data Block, return false. 4.If bufferData is a Data Block, return false.
features: [ Atomics, ArrayBuffer, TypedArray ] features: [ArrayBuffer, Atomics, TypedArray]
---*/ ---*/
var int32Array = new Int32Array(new ArrayBuffer(4)); var int32Array = new Int32Array(new ArrayBuffer(4));
@ -23,9 +23,9 @@ var poisoned = {
}; };
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wait(int32Array, 0, 0, 0) Atomics.wait(int32Array, 0, 0, 0);
}); });
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wait(int32Array, poisoned, poisoned, poisoned) Atomics.wait(int32Array, poisoned, poisoned, poisoned);
}); });

View File

@ -11,7 +11,7 @@ info: |
... ...
3.If typedArray does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. 3.If typedArray does not have a [[TypedArrayName]] internal slot, throw a TypeError exception.
features: [ Atomics ] features: [Atomics]
---*/ ---*/
var poisoned = { var poisoned = {
@ -20,5 +20,10 @@ var poisoned = {
} }
}; };
assert.throws(TypeError, () => Atomics.wait({}, 0, 0, 0)); assert.throws(TypeError, function() {
assert.throws(TypeError, () => Atomics.wait({}, poisoned, poisoned, poisoned)); Atomics.wait({}, 0, 0, 0);
});
assert.throws(TypeError, function() {
Atomics.wait({}, poisoned, poisoned, poisoned);
});

View File

@ -10,7 +10,7 @@ info: |
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true). 1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
... ...
2. if Type(typedArray) is not Object, throw a TypeError exception 2. if Type(typedArray) is not Object, throw a TypeError exception
features: [ Atomics, Symbol ] features: [Atomics, Symbol]
---*/ ---*/
var poisoned = { var poisoned = {
@ -19,16 +19,30 @@ var poisoned = {
} }
}; };
assert.throws(TypeError, function() { Atomics.wait(null,poisoned,poisoned,poisoned) }, 'null'); assert.throws(TypeError, function() {
Atomics.wait(null, poisoned, poisoned, poisoned);
}, 'null');
assert.throws(TypeError, function() { Atomics.wait(undefined,poisoned,poisoned,poisoned) }, 'undefined'); assert.throws(TypeError, function() {
Atomics.wait(undefined, poisoned, poisoned, poisoned);
}, 'undefined');
assert.throws(TypeError, function() { Atomics.wait(true,poisoned,poisoned,poisoned) }, 'true'); assert.throws(TypeError, function() {
Atomics.wait(true, poisoned, poisoned, poisoned);
}, 'true');
assert.throws(TypeError, function() { Atomics.wait(false,poisoned,poisoned,poisoned) }, 'false'); assert.throws(TypeError, function() {
Atomics.wait(false, poisoned, poisoned, poisoned);
}, 'false');
assert.throws(TypeError, function() { Atomics.wait('***string***',poisoned,poisoned,poisoned) }, 'String'); assert.throws(TypeError, function() {
Atomics.wait('***string***', poisoned, poisoned, poisoned);
}, 'String');
assert.throws(TypeError, function() { Atomics.wait(Number.NEGATIVE_INFINITY,poisoned,poisoned,poisoned) }, '-Infinity'); assert.throws(TypeError, function() {
Atomics.wait(Number.NEGATIVE_INFINITY, poisoned, poisoned, poisoned);
}, '-Infinity');
assert.throws(TypeError, function() { Atomics.wait(Symbol('***symbol***'),poisoned,poisoned,poisoned) }, 'Symbol'); assert.throws(TypeError, function() {
Atomics.wait(Symbol('***symbol***'), poisoned, poisoned, poisoned);
}, 'Symbol');

View File

@ -13,7 +13,7 @@ info: |
... ...
3.If bufferData is null, return false. 3.If bufferData is null, return false.
includes: [detachArrayBuffer.js] includes: [detachArrayBuffer.js]
features: [ Atomics, ArrayBuffer, TypedArray ] features: [ArrayBuffer, Atomics, TypedArray]
---*/ ---*/
var int32Array = new Int32Array(new ArrayBuffer(1024)); var int32Array = new Int32Array(new ArrayBuffer(1024));
@ -25,4 +25,6 @@ var poisoned = {
$DETACHBUFFER(int32Array.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null $DETACHBUFFER(int32Array.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
assert.throws(TypeError, () => Atomics.wait(int32Array, poisoned, poisoned, poisoned)); assert.throws(TypeError, function() {
Atomics.wait(int32Array, poisoned, poisoned, poisoned);
});

View File

@ -0,0 +1,68 @@
// Copyright (C) 2018 Amal Hussein. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
False timeout arg should result in an +0 timeout
info: |
Atomics.wait( typedArray, index, value, timeout )
4. Let q be ? ToNumber(timeout).
Null -> Return +0.
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100);
}
return r;
}
$262.agent.start(
`
var valueOf = {
valueOf: function() {
return null;
}
};
var toPrimitive = {
[Symbol.toPrimitive]: function() {
return null;
}
};
$262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab);
var start = Date.now();
$262.agent.report(Atomics.wait(int32Array, 0, 0, null));
$262.agent.report(Atomics.wait(int32Array, 0, 0, valueOf));
$262.agent.report(Atomics.wait(int32Array, 0, 0, toPrimitive));
$262.agent.report(Date.now() - start);
$262.agent.leaving();
})
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(int32Array.buffer);
$262.agent.sleep(150);
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
var timeDiffReport = getReport();
assert(timeDiffReport >= 0, 'timeout should be a min of 0ms');
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -1,52 +1,37 @@
// 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: >
Null timeout arg should result in an +0 timeout Throws a TypeError if index arg can not be converted to an Integer
info: | info: |
Atomics.wait( typedArray, index, value, timeout ) Atomics.wait( typedArray, index, value, timeout )
4.Let q be ? ToNumber(timeout). 4. Let q be ? ToNumber(timeout).
...
Null Return +0. Null -> Return +0.
Boolean If argument is true, return 1. If argument is false, return +0.
features: [ Atomics ] features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
includes: [ atomicsHelper.js ] flags: [CanBlockIsFalse]
---*/ ---*/
function getReport() { var buffer = new SharedArrayBuffer(1024);
var r; var int32Array = new Int32Array(buffer);
while ((r = $262.agent.getReport()) == null)
$262.agent.sleep(100);
return r;
}
$262.agent.start( var valueOf = {
` valueOf: function() {
$262.agent.receiveBroadcast(function (sab) { return null;
var int32Array = new Int32Array(sab); }
var start = Date.now(); };
$262.agent.report(Atomics.wait(int32Array, 0, 0, null)); // null => +0
$262.agent.report(Date.now() - start);
$262.agent.leaving();
})
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)); var toPrimitive = {
[Symbol.toPrimitive]: function() {
return null;
}
};
$262.agent.broadcast(int32Array.buffer); assert.sameValue(Atomics.wait(int32Array, 0, 0, null), "timed-out");
assert.sameValue(Atomics.wait(int32Array, 0, 0, valueOf), "timed-out");
assert.sameValue(Atomics.wait(int32Array, 0, 0, toPrimitive), "timed-out");
$262.agent.sleep(150);
var atomicsReport = getReport();
var timeDiffReport = getReport();
assert.sameValue(atomicsReport, 'timed-out');
assert(timeDiffReport >= 0, 'timeout should be a min of 0ms');
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -0,0 +1,75 @@
// Copyright (C) 2018 Amal Hussein. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
False timeout arg should result in an +0 timeout
info: |
Atomics.wait( typedArray, index, value, timeout )
4. Let q be ? ToNumber(timeout).
Null -> Return +0.
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100);
}
return r;
}
$262.agent.start(
`
var valueOf = {
valueOf: function() {
return 0;
}
};
var toString = {
toString: function() {
return "0";
}
};
var toPrimitive = {
[Symbol.toPrimitive]: function() {
return 0;
}
};
$262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab);
var start = Date.now();
$262.agent.report(Atomics.wait(int32Array, 0, 0, valueOf));
$262.agent.report(Atomics.wait(int32Array, 0, 0, toString));
$262.agent.report(Atomics.wait(int32Array, 0, 0, toPrimitive));
$262.agent.report(Date.now() - start);
$262.agent.leaving();
})
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(int32Array.buffer);
$262.agent.sleep(150);
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
var timeDiffReport = getReport();
assert(timeDiffReport >= 0, 'timeout should be a min of 0ms');
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -1,47 +1,45 @@
// 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: >
False timeout arg should result in a timeout value of 1 Throws a TypeError if index arg can not be converted to an Integer
info: | info: |
Atomics.wait( typedArray, index, value, timeout ) Atomics.wait( typedArray, index, value, timeout )
4.Let q be ? ToNumber(timeout). 4. Let q be ? ToNumber(timeout).
...
Object Object -> Apply the following steps:
Apply the following steps:
Let primValue be ? ToPrimitive(argument, hint Number). Let primValue be ? ToPrimitive(argument, hint Number).
Return ? ToNumber(primValue). Return ? ToNumber(primValue).
features: [ Atomics ]
includes: [atomicsHelper.js] features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
flags: [CanBlockIsFalse]
---*/ ---*/
function getReport() { var buffer = new SharedArrayBuffer(1024);
var r; var int32Array = new Int32Array(buffer);
while ((r = $262.agent.getReport()) == null)
$262.agent.sleep(100);
return r;
}
var valueOf = {
valueOf: function() {
return 0;
}
};
$262.agent.start( var toString = {
` toString: function() {
$262.agent.receiveBroadcast(function (sab) { return "0";
var int32Array = new Int32Array(sab); }
$262.agent.report("A " + Atomics.wait(int32Array, 0, 0, {})); // {} => NaN => Infinity };
$262.agent.leaving();
})
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)); var toPrimitive = {
[Symbol.toPrimitive]: function() {
return 0;
}
};
$262.agent.broadcast(int32Array.buffer); assert.sameValue(Atomics.wait(int32Array, 0, 0, valueOf), "timed-out");
assert.sameValue(Atomics.wait(int32Array, 0, 0, toString), "timed-out");
$262.agent.sleep(500); // Ample time assert.sameValue(Atomics.wait(int32Array, 0, 0, toPrimitive), "timed-out");
assert.sameValue(Atomics.wake(int32Array, 0), 1);
assert.sameValue(getReport(), "A ok");

View File

@ -13,16 +13,23 @@ info: |
2.Let accessIndex be ? ToIndex(requestIndex). 2.Let accessIndex be ? ToIndex(requestIndex).
... ...
5. If accessIndex length, throw a RangeError exception. 5. If accessIndex length, throw a RangeError exception.
features: [ Atomics, SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var int32Array = new Int32Array(new SharedArrayBuffer(4)); var int32Array = new Int32Array(new SharedArrayBuffer(4));
var poisoned = { var poisoned = {
valueOf: function() { valueOf: function() {
throw new Test262Error("should not evaluate this code"); throw new Test262Error("should not evaluate this code");
} }
}; };
assert.throws(RangeError, () => Atomics.wait(int32Array, Infinity, poisoned, poisoned)); assert.throws(RangeError, function() {
assert.throws(RangeError, () => Atomics.wait(int32Array, 2, poisoned, poisoned)); Atomics.wait(int32Array, Infinity, poisoned, poisoned);
assert.throws(RangeError, () => Atomics.wait(int32Array, 200, poisoned, poisoned)); });
assert.throws(RangeError, function() {
Atomics.wait(int32Array, 2, poisoned, poisoned);
});
assert.throws(RangeError, function() {
Atomics.wait(int32Array, 200, poisoned, poisoned);
});

View File

@ -0,0 +1,74 @@
// Copyright (C) 2018 Amal Hussein. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
False timeout arg should result in an +0 timeout
info: |
Atomics.wait( typedArray, index, value, timeout )
4. Let q be ? ToNumber(timeout).
Null -> Return +0.
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100);
}
return r;
}
$262.agent.start(
`
var poisonedValueOf = {
valueOf: function() {
throw new Error("should not evaluate this code");
}
};
var poisonedToPrimitive = {
[Symbol.toPrimitive]: function() {
throw new Error("passing a poisoned object using @@ToPrimitive");
}
};
$262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab);
var start = Date.now();
try {
Atomics.wait(int32Array, 0, 0, poisonedValueOf);
} catch (error) {
$262.agent.report("poisonedValueOf");
}
try {
Atomics.wait(int32Array, 0, 0, poisonedToPrimitive);
} catch (error) {
$262.agent.report("poisonedToPrimitive");
}
$262.agent.report(Date.now() - start);
$262.agent.leaving();
});
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(int32Array.buffer);
$262.agent.sleep(150);
assert.sameValue(getReport(), "poisonedValueOf");
assert.sameValue(getReport(), "poisonedToPrimitive");
var timeDiffReport = getReport();
assert(timeDiffReport >= 0, "timeout should be a min of 0ms");
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, "timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON");
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -1,60 +1,42 @@
// 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: >
Passing an object with no callable methods for the timeout param throws Throws a TypeError if index arg can not be converted to an Integer
info: | info: |
Atomics.wait( typedArray, index, value, timeout ) Atomics.wait( typedArray, index, value, timeout )
4.Let q be ? ToNumber(timeout). 4. Let q be ? ToNumber(timeout).
...
Object Object -> Apply the following steps:
Apply the following steps:
Let primValue be ? ToPrimitive(argument, hint Number). Let primValue be ? ToPrimitive(argument, hint Number).
... Return ? ToNumber(primValue).
g. Return ? OrdinaryToPrimitive(input, hint).
... features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
6.Throw a TypeError exception.
features: [ Atomics ]
---*/ ---*/
function getReport() { var buffer = new SharedArrayBuffer(1024);
var r; var int32Array = new Int32Array(buffer);
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100); var poisonedValueOf = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
} }
return r; };
}
$262.agent.start( var poisonedToPrimitive = {
` [Symbol.toPrimitive]: function() {
$262.agent.receiveBroadcast(function (sab) { throw new Test262Error("passing a poisoned object using @@ToPrimitive");
var int32Array = new Int32Array(sab);
var poisoned = {
valueOf: false,
toString: false
};
var err;
try {
Atomics.wait(int32Array, 0, 0, poisoned);
} catch(e) {
err = e.name;
} }
};
$262.agent.report(err);
$262.agent.leaving();
})
`);
var sab = new SharedArrayBuffer(4); assert.throws(Test262Error, function() {
var int32Array = new Int32Array(sab); Atomics.wait(int32Array, 0, 0, poisonedValueOf);
});
$262.agent.broadcast(int32Array.buffer); assert.throws(Test262Error, function() {
Atomics.wait(int32Array, 0, 0, poisonedToPrimitive);
assert.sameValue(getReport(), 'TypeError'); });
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -0,0 +1,86 @@
// Copyright (C) 2018 Amal Hussein. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
Throws a TypeError if index arg can not be converted to an Integer
info: |
Atomics.wait( typedArray, index, value, timeout )
2. Let i be ? ValidateAtomicAccess(typedArray, index).
ValidateAtomicAccess( typedArray, requestIndex )
2. Let accessIndex be ? ToIndex(requestIndex).
ToIndex ( value )
2. Else,
a. Let integerIndex be ? ToInteger(value).
ToInteger(value)
1. Let number be ? ToNumber(argument).
Symbol --> Throw a TypeError exception.
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100);
}
return r;
}
$262.agent.start(
`
var poisonedValueOf = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
}
};
var poisonedToPrimitive = {
[Symbol.toPrimitive]: function() {
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
}
};
$262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab);
var start = Date.now();
try {
Atomics.wait(int32Array, Symbol("1"), poisonedValueOf, poisonedValueOf);
} catch (error) {
$262.agent.report('Symbol("1")');
}
try {
Atomics.wait(int32Array, Symbol("2"), poisonedToPrimitive, poisonedToPrimitive);
} catch (error) {
$262.agent.report('Symbol("2")');
}
$262.agent.report(Date.now() - start);
$262.agent.leaving();
});
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(int32Array.buffer);
$262.agent.sleep(150);
assert.sameValue(getReport(), 'Symbol("1")');
assert.sameValue(getReport(), 'Symbol("2")');
var timeDiffReport = getReport();
assert(timeDiffReport >= 0, "timeout should be a min of 0ms");
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, "timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON");
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -8,40 +8,53 @@ description: >
info: | info: |
Atomics.wait( typedArray, index, value, timeout ) Atomics.wait( typedArray, index, value, timeout )
3.Let v be ? ToInt32(value). 2. Let i be ? ValidateAtomicAccess(typedArray, index).
...
1.Let number be ? ToNumber(argument). ValidateAtomicAccess( typedArray, requestIndex )
Symbol --> Throw a TypeError exception.
features: [ Atomics, SharedArrayBuffer, TypedArray, Symbol, Symbol.toPrimitive] 2. Let accessIndex be ? ToIndex(requestIndex).
ToIndex ( value )
2. Else,
a. Let integerIndex be ? ToInteger(value).
ToInteger(value)
1. Let number be ? ToNumber(argument).
Symbol --> Throw a TypeError exception.
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
var int32Array = new Int32Array(sab); var int32Array = new Int32Array(buffer);
var poisoned = { var poisonedValueOf = {
valueOf: function() { valueOf: function() {
throw new Test262Error("should not evaluate this code"); throw new Test262Error("should not evaluate this code");
} }
}; };
var poisonedWithString = {
get valueOf() { throw "should not evaluate this code"; }
};
var poisonedToPrimitive = { var poisonedToPrimitive = {
get [Symbol.ToPrimitive]() { [Symbol.toPrimitive]: function() {
throw new Test262Error('passing a poisoned object using @@ToPrimitive'); throw new Test262Error("passing a poisoned object using @@ToPrimitive");
} }
}; };
assert.throws(Test262Error, function() {
Atomics.wait(int32Array, poisonedValueOf, poisonedValueOf, poisonedValueOf);
});
assert.throws(Test262Error, function() {
Atomics.wait(int32Array, poisonedToPrimitive, poisonedToPrimitive, poisonedToPrimitive);
});
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wait(int32Array, Symbol('foo'), poisonedWithString, poisonedWithString) Atomics.wait(int32Array, Symbol("foo"), poisonedValueOf, poisonedValueOf);
}, 'Symbol'); });
assert.throws(Test262Error, function() { assert.throws(TypeError, function() {
Atomics.wait(int32Array, poisoned, poisonedWithString, poisonedWithString) Atomics.wait(int32Array, Symbol("foo"), poisonedToPrimitive, poisonedToPrimitive);
}, 'passing a poisoned object using valueOf'); });
assert.throws(Test262Error, function() {
Atomics.wait(int32Array, poisoned, poisonedToPrimitive, poisonedToPrimitive);
}, 'passing a poisoned object using @@ToPrimitive');

View File

@ -0,0 +1,59 @@
// Copyright (C) 2018 Amal Hussein. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
Throws a TypeError if index arg can not be converted to an Integer
info: |
Atomics.wait( typedArray, index, value, timeout )
4. Let q be ? ToNumber(timeout).
Symbol --> Throw a TypeError exception.
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100);
}
return r;
}
$262.agent.start(
`
$262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab);
var start = Date.now();
try {
Atomics.wait(int32Array, 0, 0, Symbol("1"));
} catch (error) {
$262.agent.report('Symbol("1")');
}
try {
Atomics.wait(int32Array, 0, 0, Symbol("2"));
} catch (error) {
$262.agent.report('Symbol("2")');
}
$262.agent.report(Date.now() - start);
$262.agent.leaving();
});
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(int32Array.buffer);
$262.agent.sleep(150);
assert.sameValue(getReport(), 'Symbol("1")');
assert.sameValue(getReport(), 'Symbol("2")');
var timeDiffReport = getReport();
assert(timeDiffReport >= 0, "timeout should be a min of 0ms");
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, "timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON");
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -1,48 +1,47 @@
// 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: >
Throws a TypeError if timeout arg is a Symbol Throws a TypeError if index arg can not be converted to an Integer
info: | info: |
Atomics.wait( typedArray, index, value, timeout ) Atomics.wait( typedArray, index, value, timeout )
4.Let q be ? ToNumber(timeout). 4. Let q be ? ToNumber(timeout).
...
Symbol Throw a TypeError exception. Symbol --> Throw a TypeError exception.
features: [Atomics, SharedArrayBuffer, TypedArray, Symbol]
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
---*/ ---*/
function getReport() { var buffer = new SharedArrayBuffer(1024);
var r; var int32Array = new Int32Array(buffer);
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100); var poisonedValueOf = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
} }
return r; };
}
$262.agent.start( var poisonedToPrimitive = {
` [Symbol.toPrimitive]: function() {
$262.agent.receiveBroadcast(function (sab) { throw new Test262Error("passing a poisoned object using @@ToPrimitive");
var int32Array = new Int32Array(sab);
var err;
try {
Atomics.wait(int32Array, 0, 0, Symbol('foo'));
} catch(e) {
err = e.name;
} }
};
$262.agent.report(err);
$262.agent.leaving();
})
`);
var sab = new SharedArrayBuffer(4); assert.throws(Test262Error, function() {
var int32Array = new Int32Array(sab); Atomics.wait(int32Array, 0, 0, poisonedValueOf);
});
$262.agent.broadcast(int32Array.buffer); assert.throws(Test262Error, function() {
Atomics.wait(int32Array, 0, 0, poisonedToPrimitive);
});
assert.sameValue(getReport(), 'TypeError'); assert.throws(TypeError, function() {
Atomics.wait(int32Array, 0, 0, Symbol("foo"));
});
assert.throws(TypeError, function() {
Atomics.wait(int32Array, 0, 0, Symbol("foo"));
});

View File

@ -0,0 +1,76 @@
// Copyright (C) 2018 Amal Hussein. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
Throws a TypeError if value arg is a Symbol
info: |
Atomics.wait( typedArray, index, value, timeout )
3. Let v be ? ToInt32(value).
ToInt32(value)
1.Let number be ? ToNumber(argument).
Symbol --> Throw a TypeError exception.
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100);
}
return r;
}
$262.agent.start(
`
var poisonedValueOf = {
valueOf: function() {
throw new Test262Error("should not evaluate this code");
}
};
var poisonedToPrimitive = {
[Symbol.toPrimitive]: function() {
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
}
};
$262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab);
var start = Date.now();
try {
Atomics.wait(int32Array, 0, Symbol("1"), poisonedValueOf);
} catch (error) {
$262.agent.report('Symbol("1")');
}
try {
Atomics.wait(int32Array, 0, Symbol("2"), poisonedToPrimitive);
} catch (error) {
$262.agent.report('Symbol("2")');
}
$262.agent.report(Date.now() - start);
$262.agent.leaving();
});
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(int32Array.buffer);
$262.agent.sleep(150);
assert.sameValue(getReport(), 'Symbol("1")');
assert.sameValue(getReport(), 'Symbol("2")');
var timeDiffReport = getReport();
assert(timeDiffReport >= 0, "timeout should be a min of 0ms");
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, "timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON");
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -8,41 +8,45 @@ description: >
info: | info: |
Atomics.wait( typedArray, index, value, timeout ) Atomics.wait( typedArray, index, value, timeout )
3.Let v be ? ToInt32(value). 3. Let v be ? ToInt32(value).
...
1.Let number be ? ToNumber(argument). ToInt32(value)
...
Symbol Throw a TypeError exception. 1.Let number be ? ToNumber(argument).
features: [Atomics, SharedArrayBuffer, TypedArray, Symbol]
Symbol --> Throw a TypeError exception.
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
var int32Array = new Int32Array(sab); var int32Array = new Int32Array(buffer);
var poisoned = { var poisonedValueOf = {
valueOf: function() { valueOf: function() {
throw new Test262Error("should not evaluate this code"); throw new Test262Error("should not evaluate this code");
} }
}; };
var poisonedWithString = {
get valueOf() { throw "should not evaluate this code"; }
};
var poisonedToPrimitive = { var poisonedToPrimitive = {
get [Symbol.ToPrimitive]() { [Symbol.toPrimitive]: function() {
throw new Test262Error('passing a poisoned object using @@ToPrimitive'); throw new Test262Error("passing a poisoned object using @@ToPrimitive");
} }
}; };
assert.throws(Test262Error, function() {
Atomics.wait(int32Array, 0, poisonedValueOf, poisonedValueOf);
});
assert.throws(Test262Error, function() {
Atomics.wait(int32Array, 0, poisonedToPrimitive, poisonedToPrimitive);
});
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wait(int32Array, 0, Symbol('foo'), poisonedWithString) Atomics.wait(int32Array, 0, Symbol("foo"), poisonedValueOf);
}, 'Symbol'); });
assert.throws(Test262Error, function() { assert.throws(TypeError, function() {
Atomics.wait(int32Array, 0, poisoned, poisonedWithString) Atomics.wait(int32Array, 0, Symbol("foo"), poisonedToPrimitive);
}, 'passing a poisoned object using valueOf'); });
assert.throws(Test262Error, function() {
Atomics.wait(int32Array, 0, poisoned, poisonedToPrimitive);
}, 'passing a poisoned object using @@ToPrimitive');

View File

@ -0,0 +1,68 @@
// Copyright (C) 2018 Amal Hussein. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.wait
description: >
True timeout arg should result in an +0 timeout
info: |
Atomics.wait( typedArray, index, value, timeout )
4. Let q be ? ToNumber(timeout).
Boolean -> If argument is true, return 1. If argument is false, return +0.
features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [ atomicsHelper.js ]
---*/
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100);
}
return r;
}
$262.agent.start(
`
var valueOf = {
valueOf: function() {
return true;
}
};
var toPrimitive = {
[Symbol.toPrimitive]: function() {
return true;
}
};
$262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab);
var start = Date.now();
$262.agent.report(Atomics.wait(int32Array, 0, 0, true));
$262.agent.report(Atomics.wait(int32Array, 0, 0, valueOf));
$262.agent.report(Atomics.wait(int32Array, 0, 0, toPrimitive));
$262.agent.report(Date.now() - start);
$262.agent.leaving();
})
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(int32Array.buffer);
$262.agent.sleep(150);
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
assert.sameValue(getReport(), 'timed-out');
var timeDiffReport = getReport();
assert(timeDiffReport >= 0, 'timeout should be a min of 0ms');
assert(timeDiffReport <= $ATOMICS_MAX_TIME_EPSILON, 'timeout should be a max of $$ATOMICS_MAX_TIME_EPSILON');
assert.sameValue(Atomics.wake(int32Array, 0), 0);

View File

@ -1,48 +1,37 @@
// 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: >
True timeout arg should result in a timeout value of 1 Throws a TypeError if index arg can not be converted to an Integer
info: | info: |
Atomics.wait( typedArray, index, value, timeout ) Atomics.wait( typedArray, index, value, timeout )
4.Let q be ? ToNumber(timeout). 4. Let q be ? ToNumber(timeout).
...
Boolean If argument is true, return 1. If argument is false, return +0. Boolean -> If argument is true, return 1. If argument is false, return +0.
features: [ Atomics, SharedArrayBuffer, TypedArray ]
includes: [atomicsHelper.js] features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
flags: [CanBlockIsFalse]
---*/ ---*/
function getReport() { var buffer = new SharedArrayBuffer(1024);
var r; var int32Array = new Int32Array(buffer);
while ((r = $262.agent.getReport()) == null)
$262.agent.sleep(100);
return r;
}
var valueOf = {
valueOf: function() {
return true;
}
};
$262.agent.start( var toPrimitive = {
` [Symbol.toPrimitive]: function() {
$262.agent.receiveBroadcast(function (sab) { return true;
var int32Array = new Int32Array(sab); }
var start = Date.now(); };
$262.agent.report(Atomics.wait(int32Array, 0, 0, true)); // true => 1
$262.agent.report(Date.now() - start);
$262.agent.leaving();
})
`);
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)); assert.sameValue(Atomics.wait(int32Array, 0, 0, true), "timed-out");
assert.sameValue(Atomics.wait(int32Array, 0, 0, valueOf), "timed-out");
assert.sameValue(Atomics.wait(int32Array, 0, 0, toPrimitive), "timed-out");
$262.agent.broadcast(int32Array.buffer);
$262.agent.sleep(2);
var r1 = getReport();
var r2 = getReport();
assert.sameValue(r1, "timed-out");
assert(r2 >= 1, "timeout should be a min of 1ms");
assert(r2 <= $ATOMICS_MAX_TIME_EPSILON + 1, "timeout should be a max of $ATOMICS_MAX_TIME_EPSILON + 1ms");

View File

@ -12,7 +12,7 @@ info: |
... ...
Undefined Return NaN. Undefined Return NaN.
5.If q is NaN, let t be +, else let t be max(q, 0) 5.If q is NaN, let t be +, else let t be max(q, 0)
features: [ Atomics, SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var NUMAGENT = 2; // Total number of agents started var NUMAGENT = 2; // Total number of agents started
@ -21,8 +21,9 @@ var WAKECOUNT = 2; // Total number of agents to wake up
function getReport() { function getReport() {
var r; var r;
while ((r = $262.agent.getReport()) == null) while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100); $262.agent.sleep(100);
}
return r; return r;
} }

View File

@ -17,12 +17,12 @@ info: |
If value is undefined, then If value is undefined, then
Let index be 0. Let index be 0.
features: [ Atomics, SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
$262.agent.start( $262.agent.start(
` `
$262.agent.receiveBroadcast(function (sab) { $262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab); var int32Array = new Int32Array(sab);
$262.agent.report(Atomics.wait(int32Array, undefined, 0, 1000)); // undefined index => 0 $262.agent.report(Atomics.wait(int32Array, undefined, 0, 1000)); // undefined index => 0
$262.agent.leaving(); $262.agent.leaving();
@ -43,7 +43,8 @@ assert.sameValue(getReport(), "ok");
function getReport() { function getReport() {
var r; var r;
while ((r = $262.agent.getReport()) == null) while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100); $262.agent.sleep(100);
}
return r; return r;
} }

View File

@ -14,28 +14,29 @@ info: |
a.Perform LeaveCriticalSection(WL). a.Perform LeaveCriticalSection(WL).
b. Return the String "not-equal". b. Return the String "not-equal".
features: [ Atomics, SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
includes: [atomicsHelper.js] includes: [atomicsHelper.js]
---*/ ---*/
function getReport() { function getReport() {
var r; var r;
while ((r = $262.agent.getReport()) == null) while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100); $262.agent.sleep(100);
}
return r; return r;
} }
var value = 42; var value = 42;
$262.agent.start( $262.agent.start(
` `
$262.agent.receiveBroadcast(function (sab) { $262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab); var int32Array = new Int32Array(sab);
$262.agent.report(Atomics.store(int32Array, 0, ${value})); $262.agent.report(Atomics.store(int32Array, 0, ${value}));
$262.agent.report(Atomics.wait(int32Array, 0, 0)); $262.agent.report(Atomics.wait(int32Array, 0, 0));
$262.agent.leaving(); $262.agent.leaving();
}) })
`); `);

View File

@ -12,7 +12,7 @@ info: |
a.Perform LeaveCriticalSection(WL). a.Perform LeaveCriticalSection(WL).
b. Return the String "not-equal". b. Return the String "not-equal".
features: [ Atomics, SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
function getReport() { function getReport() {
@ -24,12 +24,12 @@ function getReport() {
} }
$262.agent.start( $262.agent.start(
` `
$262.agent.receiveBroadcast(function (sab) { $262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab); var int32Array = new Int32Array(sab);
$262.agent.report(Atomics.wait(int32Array, 0, 44, 1000)); $262.agent.report(Atomics.wait(int32Array, 0, 44, 1000));
$262.agent.report(Atomics.wait(int32Array, 0, 251.4, 1000)); $262.agent.report(Atomics.wait(int32Array, 0, 251.4, 1000));
$262.agent.leaving(); $262.agent.leaving();

View File

@ -12,7 +12,7 @@ info: |
... ...
3.Add W to the end of the list of waiters in WL. 3.Add W to the end of the list of waiters in WL.
features: [ Atomics, SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
function getReport() { function getReport() {
@ -28,14 +28,14 @@ var agent2 = '2';
var agent3 = '3'; var agent3 = '3';
$262.agent.start( $262.agent.start(
` `
$262.agent.receiveBroadcast(function (sab) { $262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab); var int32Array = new Int32Array(sab);
$262.agent.report(${agent1}); $262.agent.report(${agent1});
Atomics.wait(int32Array, 0, 0); Atomics.wait(int32Array, 0, 0);
$262.agent.report(${agent1}); $262.agent.report(${agent1});
$262.agent.leaving(); $262.agent.leaving();
}) })
`); `);
@ -44,12 +44,12 @@ $262.agent.start(
` `
$262.agent.receiveBroadcast(function (sab) { $262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab); var int32Array = new Int32Array(sab);
$262.agent.report(${agent2}); $262.agent.report(${agent2});
Atomics.wait(int32Array, 0, 0); Atomics.wait(int32Array, 0, 0);
$262.agent.report(${agent2}); $262.agent.report(${agent2});
$262.agent.leaving(); $262.agent.leaving();
}) })
`); `);
@ -58,12 +58,12 @@ $262.agent.start(
` `
$262.agent.receiveBroadcast(function (sab) { $262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab); var int32Array = new Int32Array(sab);
$262.agent.report(${agent3}); $262.agent.report(${agent3});
Atomics.wait(int32Array, 0, 0); Atomics.wait(int32Array, 0, 0);
$262.agent.report(${agent3}); $262.agent.report(${agent3});
$262.agent.leaving(); $262.agent.leaving();
}) })
`); `);

View File

@ -21,34 +21,36 @@ info: |
features: [Atomics, SharedArrayBuffer, TypedArray] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sleeping = 100;
var timeout = 20000; var timeout = 20000;
$262.agent.start(
`
$262.agent.receiveBroadcast(function (sab) {
var int32Array = new Int32Array(sab);
$262.agent.report(Atomics.wait(int32Array, 0, 0, ${timeout}));
$262.agent.leaving();
})
`);
var sab = new SharedArrayBuffer(4);
var int32Array = new Int32Array(sab);
var sleeping = 100;
$262.agent.broadcast(int32Array.buffer); function getReport() {
$262.agent.sleep(sleeping); var r;
while ((r = $262.agent.getReport()) == null) {
assert.sameValue(Atomics.wake(int32Array, 0), 1); sleeping += 100;
$262.agent.sleep(100);
assert.sameValue(getReport(), "ok");
assert(sleeping < timeout, "this test assumes it won't last for more than 20 seconds");
function getReport() {
var r;
while ((r = $262.agent.getReport()) == null) {
sleeping += 100;
$262.agent.sleep(100);
}
return r;
} }
return r;
}
$262.agent.start(
`
$262.agent.receiveBroadcast(function(sab) {
var int32Array = new Int32Array(sab);
$262.agent.report(Atomics.wait(int32Array, 0, 0, ${timeout}));
$262.agent.leaving();
});
`);
var sab = new SharedArrayBuffer(4);
var int32Array = new Int32Array(sab);
$262.agent.broadcast(int32Array.buffer);
$262.agent.sleep(sleeping);
assert.sameValue(Atomics.wake(int32Array, 0), 1);
assert.sameValue(getReport(), "ok");
assert(sleeping < timeout, "this test assumes it won't last for more than 20 seconds");

View File

@ -5,25 +5,9 @@
esid: sec-atomics.wait esid: sec-atomics.wait
description: > description: >
Test that Atomics.wait returns the right result when it was awoken. Test that Atomics.wait returns the right result when it was awoken.
features: [Atomics] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
$262.agent.start(
`
$262.agent.receiveBroadcast(function (sab, id) {
var ia = new Int32Array(sab);
$262.agent.report(Atomics.wait(ia, 0, 0)); // No timeout => Infinity
$262.agent.leaving();
})
`);
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(ia.buffer);
$262.agent.sleep(500); // Give the agent a chance to wait
Atomics.wake(ia, 0);
assert.sameValue(getReport(), "ok");
function getReport() { function getReport() {
var r; var r;
while ((r = $262.agent.getReport()) == null) { while ((r = $262.agent.getReport()) == null) {
@ -31,3 +15,19 @@ function getReport() {
} }
return r; return r;
} }
$262.agent.start(
`
$262.agent.receiveBroadcast(function (sab, id) {
var ia = new Int32Array(sab);
$262.agent.report(Atomics.wait(ia, 0, 0)); // No timeout => Infinity
$262.agent.leaving();
});
`);
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
$262.agent.broadcast(ia.buffer);
$262.agent.sleep(500); // Give the agent a chance to wait
Atomics.wake(ia, 0);
assert.sameValue(getReport(), "ok");

View File

@ -6,7 +6,7 @@ esid: sec-atomics.wake
description: > description: >
Test range checking of Atomics.wake on arrays that allow atomic operations Test range checking of Atomics.wake on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js] includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, TypedArray, arrow-function, let, for-of] features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(8); var sab = new SharedArrayBuffer(8);
@ -16,8 +16,8 @@ if (typeof BigInt !== "undefined") {
views.push(BigInt64Array); views.push(BigInt64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
let view = new View(sab); let view = new TA(sab);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
let Idx = IdxGen(view); let Idx = IdxGen(view);
assert.throws(RangeError, () => Atomics.wake(view, Idx, 0)); // Even with waking zero assert.throws(RangeError, () => Atomics.wake(view, Idx, 0)); // Even with waking zero

View File

@ -5,7 +5,7 @@
esid: sec-atomics.wake esid: sec-atomics.wake
description: > description: >
Allowed boundary cases of the third 'count' argument to Atomics.wake Allowed boundary cases of the third 'count' argument to Atomics.wake
features: [Atomics] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(4); var sab = new SharedArrayBuffer(4);

View File

@ -7,12 +7,12 @@ description: >
Test Atomics.wait on arrays that allow atomic operations, Test Atomics.wait on arrays that allow atomic operations,
in an Agent that is allowed to wait. There is only the one Agent. in an Agent that is allowed to wait. There is only the one Agent.
includes: [testAtomics.js] includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);
var ab = new ArrayBuffer(16); var ab = new ArrayBuffer(16);
var int_views = [Int32Array]; var views = [Int32Array];
var view = new Int32Array(sab, 32, 20); var view = new Int32Array(sab, 32, 20);
view[0] = 0; view[0] = 0;

View File

@ -10,7 +10,7 @@ info: |
3.If count is undefined, let c be +. 3.If count is undefined, let c be +.
features: [ Atomics, SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var NUMAGENT = 4; // Total number of agents started var NUMAGENT = 4; // Total number of agents started

View File

@ -5,7 +5,7 @@
esid: sec-atomics.wake esid: sec-atomics.wake
description: > description: >
Test that Atomics.wake wakes zero waiters if the count is negative Test that Atomics.wake wakes zero waiters if the count is negative
features: [Atomics] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
$262.agent.start( $262.agent.start(

View File

@ -13,7 +13,7 @@ info: |
2.Let accessIndex be ? ToIndex(requestIndex). 2.Let accessIndex be ? ToIndex(requestIndex).
... ...
2.b If integerIndex < 0, throw a RangeError exception 2.b If integerIndex < 0, throw a RangeError exception
features: [ Atomics , SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var sab = new SharedArrayBuffer(1024);

View File

@ -12,7 +12,7 @@ info: |
... ...
5.If onlyInt32 is true, then 5.If onlyInt32 is true, then
If typeName is not "Int32Array", throw a TypeError exception. If typeName is not "Int32Array", throw a TypeError exception.
features: [ Atomics, TypedArray ] features: [Atomics, Float32Array, Float64Array, Int8Array, TypedArray, Uint16Array, Uint8Array, Uint8ClampedArray]
---*/ ---*/
var poisoned = { var poisoned = {

View File

@ -12,7 +12,7 @@ info: |
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception. 9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
... ...
4.If bufferData is a Data Block, return false. 4.If bufferData is a Data Block, return false.
features: [ Atomics, ArrayBuffer, TypedArray ] features: [ArrayBuffer, Atomics, TypedArray]
---*/ ---*/
var int32Array = new Int32Array(new ArrayBuffer(4)); var int32Array = new Int32Array(new ArrayBuffer(4));

View File

@ -6,7 +6,7 @@ esid: sec-atomics.wake
description: > description: >
Test Atomics.wake on view values other than TypedArrays Test Atomics.wake on view values other than TypedArrays
includes: [testAtomics.js] includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of] features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer]
---*/ ---*/
testWithAtomicsNonViewValues(function(view) { testWithAtomicsNonViewValues(function(view) {

View File

@ -6,20 +6,18 @@ esid: sec-atomics.wake
description: > description: >
Test Atomics.wake on non-shared integer TypedArrays Test Atomics.wake on non-shared integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/ ---*/
var ab = new ArrayBuffer(16); var buffer = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
if (typeof BigInt !== "undefined") { if (typeof BigInt !== "undefined") {
int_views.push(BigInt64Array); views.push(BigInt64Array);
int_views.push(BigUint64Array); views.push(BigUint64Array);
} }
testWithTypedArrayConstructors(function(View) { testWithTypedArrayConstructors(function(TA) {
var view = new View(ab); // Should fail even if waking zero waiters
assert.throws(TypeError, (() => Atomics.wake(new TA(buffer), 0, 0)));
assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Should fail even if waking zero waiters }, views);
}, int_views);

View File

@ -11,7 +11,7 @@ info: |
... ...
3.If typedArray does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. 3.If typedArray does not have a [[TypedArrayName]] internal slot, throw a TypeError exception.
features: [ Atomics ] features: [Atomics]
---*/ ---*/
var poisoned = { var poisoned = {
@ -21,9 +21,9 @@ var poisoned = {
}; };
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wait({}, 0, 0, 0) Atomics.wait({}, 0, 0, 0);
}); });
assert.throws(TypeError, function () { assert.throws(TypeError, function () {
Atomics.wait({}, poisoned, poisoned, poisoned) Atomics.wait({}, poisoned, poisoned, poisoned);
}); });

View File

@ -10,7 +10,7 @@ info: |
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true). 1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
... ...
2. if Type(typedArray) is not Object, throw a TypeError exception 2. if Type(typedArray) is not Object, throw a TypeError exception
features: [ Atomics, Symbol ] features: [Atomics, Symbol]
---*/ ---*/
var poisoned = { var poisoned = {
@ -19,16 +19,30 @@ var poisoned = {
} }
}; };
assert.throws(TypeError, function() { Atomics.wake(null,poisoned,poisoned) }, 'null'); assert.throws(TypeError, function() {
Atomics.wake(null, poisoned, poisoned);
}, 'null');
assert.throws(TypeError, function() { Atomics.wake(undefined,poisoned,poisoned) }, 'undefined'); assert.throws(TypeError, function() {
Atomics.wake(undefined, poisoned, poisoned);
}, 'undefined');
assert.throws(TypeError, function() { Atomics.wake(true,poisoned,poisoned) }, 'true'); assert.throws(TypeError, function() {
Atomics.wake(true, poisoned, poisoned);
}, 'true');
assert.throws(TypeError, function() { Atomics.wake(false,poisoned,poisoned) }, 'false'); assert.throws(TypeError, function() {
Atomics.wake(false, poisoned, poisoned);
}, 'false');
assert.throws(TypeError, function() { Atomics.wake('***string***',poisoned,poisoned) }, 'String'); assert.throws(TypeError, function() {
Atomics.wake('***string***', poisoned, poisoned);
}, 'String');
assert.throws(TypeError, function() { Atomics.wake(Number.NEGATIVE_INFINITY,poisoned,poisoned) }, '-Infinity'); assert.throws(TypeError, function() {
Atomics.wake(Number.NEGATIVE_INFINITY, poisoned, poisoned);
}, '-Infinity');
assert.throws(TypeError, function() { Atomics.wake(Symbol('***symbol***'),poisoned,poisoned) }, 'Symbol'); assert.throws(TypeError, function() {
Atomics.wake(Symbol('***symbol***'), poisoned, poisoned);
}, 'Symbol');

View File

@ -13,7 +13,7 @@ info: |
... ...
3.If bufferData is null, return false. 3.If bufferData is null, return false.
includes: [detachArrayBuffer.js] includes: [detachArrayBuffer.js]
features: [ Atomics, ArrayBuffer, TypedArray ] features: [ArrayBuffer, Atomics, TypedArray]
---*/ ---*/
var int32Array = new Int32Array(new ArrayBuffer(1024)); var int32Array = new Int32Array(new ArrayBuffer(1024));
@ -25,4 +25,6 @@ var poisoned = {
$DETACHBUFFER(int32Array.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null $DETACHBUFFER(int32Array.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
assert.throws(TypeError, () => Atomics.wake(int32Array, poisoned, poisoned)); assert.throws(TypeError, function() {
Atomics.wake(int32Array, poisoned, poisoned);
});

View File

@ -13,7 +13,7 @@ info: |
2.Let accessIndex be ? ToIndex(requestIndex). 2.Let accessIndex be ? ToIndex(requestIndex).
... ...
5. If accessIndex length, throw a RangeError exception. 5. If accessIndex length, throw a RangeError exception.
features: [ Atomics, SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var int32Array = new Int32Array(new SharedArrayBuffer(4)); var int32Array = new Int32Array(new SharedArrayBuffer(4));
@ -23,6 +23,12 @@ var poisoned = {
} }
}; };
assert.throws(RangeError, () => Atomics.wake(int32Array, Infinity, poisoned)); assert.throws(RangeError, function() {
assert.throws(RangeError, () => Atomics.wake(int32Array, 2, poisoned)); Atomics.wake(int32Array, Infinity, poisoned);
assert.throws(RangeError, () => Atomics.wake(int32Array, 200, poisoned)); });
assert.throws(RangeError, function() {
Atomics.wake(int32Array, 2, poisoned);
});
assert.throws(RangeError, function() {
Atomics.wake(int32Array, 200, poisoned);
});

View File

@ -6,17 +6,14 @@ esid: sec-atomics.wake
description: > description: >
Test Atomics.wake on shared non-integer TypedArrays Test Atomics.wake on shared non-integer TypedArrays
includes: [testTypedArray.js] includes: [testTypedArray.js]
features: [Atomics, TypedArray] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, (() => Atomics.wake(new TA(buffer), 0, 0)));
}, floatArrayConstructors);
var other_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
Uint8ClampedArray, Float32Array, Float64Array];
testWithTypedArrayConstructors(function(View) {
var view = new View(sab);
// Even with timout zero this should fail
assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Even with 0 to wake this should fail
}, other_views);

View File

@ -3,45 +3,58 @@
/*--- /*---
esid: sec-atomics.wake esid: sec-atomics.wake
description: description: >
Throws a TypeError if index arg can not be converted to an Integer Throws a TypeError if index arg can not be converted to an Integer
info: | info: |
Atomics.wake( typedArray, index, count ) Atomics.wake( typedArray, index, value, timeout )
3.Let v be ? ToInt32(value). 2. Let i be ? ValidateAtomicAccess(typedArray, index).
...
1.Let number be ? ToNumber(argument). ValidateAtomicAccess( typedArray, requestIndex )
Symbol --> Throw a TypeError exception.
features: [ Atomics, SharedArrayBuffer, TypedArray, Symbol, Symbol.toPrimitive] 2. Let accessIndex be ? ToIndex(requestIndex).
ToIndex ( value )
2. Else,
a. Let integerIndex be ? ToInteger(value).
ToInteger(value)
1. Let number be ? ToNumber(argument).
Symbol --> Throw a TypeError exception.
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
---*/ ---*/
var sab = new SharedArrayBuffer(1024); var buffer = new SharedArrayBuffer(1024);
var int32Array = new Int32Array(sab); var int32Array = new Int32Array(buffer);
var poisoned = { var poisonedValueOf = {
valueOf: function() { valueOf: function() {
throw new Test262Error("should not evaluate this code"); throw new Test262Error("should not evaluate this code");
} }
}; };
var poisonedWithString = {
get valueOf() { throw "should not evaluate this code"; }
};
var poisonedToPrimitive = { var poisonedToPrimitive = {
get [Symbol.ToPrimitive]() { [Symbol.toPrimitive]: function() {
throw new Test262Error('passing a poisoned object using @@ToPrimitive'); throw new Test262Error("passing a poisoned object using @@ToPrimitive");
} }
}; };
assert.throws(Test262Error, function() {
Atomics.wake(int32Array, poisonedValueOf, poisonedValueOf);
});
assert.throws(Test262Error, function() {
Atomics.wake(int32Array, poisonedToPrimitive, poisonedToPrimitive);
});
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
Atomics.wake(int32Array, Symbol('foo'), poisonedWithString, poisonedWithString) Atomics.wake(int32Array, Symbol("foo"), poisonedValueOf);
}, 'Symbol'); });
assert.throws(Test262Error, function() { assert.throws(TypeError, function() {
Atomics.wake(int32Array, poisoned, poisonedWithString, poisonedWithString) Atomics.wake(int32Array, Symbol("foo"), poisonedToPrimitive);
}, 'passing a poisoned object using valueOf'); });
assert.throws(Test262Error, function() {
Atomics.wake(int32Array, poisoned, poisonedToPrimitive, poisonedToPrimitive);
}, 'passing a poisoned object using @@ToPrimitive');

View File

@ -10,7 +10,7 @@ info: |
3.If count is undefined, let c be +. 3.If count is undefined, let c be +.
features: [ Atomics, SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var NUMAGENT = 4; // Total number of agents started var NUMAGENT = 4; // Total number of agents started

View File

@ -18,7 +18,7 @@ info: |
If value is undefined, then If value is undefined, then
Let index be 0. Let index be 0.
features: [ Atomics, SharedArrayBuffer, TypedArray ] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
$262.agent.start( $262.agent.start(

View File

@ -6,7 +6,7 @@ esid: sec-atomics.wake
description: > description: >
Test that Atomics.wake wakes all waiters on a location, but does not Test that Atomics.wake wakes all waiters on a location, but does not
wake waiters on other locations. wake waiters on other locations.
features: [Atomics] features: [Atomics, SharedArrayBuffer, TypedArray]
---*/ ---*/
var WAKEUP = 0; // Waiters on this will be woken var WAKEUP = 0; // Waiters on this will be woken
@ -53,18 +53,21 @@ $262.agent.sleep(500);
assert.sameValue(Atomics.wake(ia, WAKEUP), NUMAGENT); assert.sameValue(Atomics.wake(ia, WAKEUP), NUMAGENT);
var rs = []; var rs = [];
for (var i = 0; i < NUMAGENT + 1; i++) for (var i = 0; i < NUMAGENT + 1; i++) {
rs.push(getReport()); rs.push(getReport());
}
rs.sort(); rs.sort();
for (var i = 0; i < NUMAGENT; i++) for (var i = 0; i < NUMAGENT; i++) {
assert.sameValue(rs[i], "A ok"); assert.sameValue(rs[i], "A ok");
}
assert.sameValue(rs[NUMAGENT], "B timed-out"); assert.sameValue(rs[NUMAGENT], "B timed-out");
function getReport() { function getReport() {
var r; var r;
while ((r = $262.agent.getReport()) == null) while ((r = $262.agent.getReport()) == null) {
$262.agent.sleep(100); $262.agent.sleep(100);
}
return r; return r;
} }

Some files were not shown because too many files have changed in this diff Show More