mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Atomics: updates to tests
This commit is contained in:
parent
251a69acca
commit
ac65ecab7c
@ -20,6 +20,9 @@ var typedArrayConstructors = [
|
||||
Uint8ClampedArray
|
||||
];
|
||||
|
||||
var floatArrayConstructors = typedArrayConstructors.slice(0, 2);
|
||||
var intArrayConstructors = typedArrayConstructors.slice(2, 7);
|
||||
|
||||
/**
|
||||
* The %TypedArray% intrinsic constructor function.
|
||||
*/
|
||||
|
@ -11,7 +11,7 @@ info: |
|
||||
This property has the attributes { [[Writable]]: false, [[Enumerable]]:
|
||||
false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Atomics, Symbol.toStringTag]
|
||||
features: [Atomics, Symbol, Symbol.toStringTag]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Atomics[Symbol.toStringTag], 'Atomics');
|
||||
|
@ -6,21 +6,20 @@ esid: sec-atomics.add
|
||||
description: >
|
||||
Test range checking of Atomics.add on arrays that allow atomic operations
|
||||
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 views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
let view = new View(sab);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
let Idx = IdxGen(view);
|
||||
assert.throws(RangeError, () => Atomics.add(view, Idx, 10));
|
||||
assert.throws(RangeError, () => Atomics.add(view, IdxGen(view), 10));
|
||||
});
|
||||
}, views);
|
||||
|
@ -5,19 +5,18 @@
|
||||
esid: sec-atomics.add
|
||||
description: Test Atomics.add on arrays that allow atomic operations.
|
||||
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 ab = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new View(sab, 32, 20);
|
||||
var control = new View(ab, 0, 2);
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
// Add positive number
|
||||
view[8] = 0;
|
||||
@ -52,4 +51,4 @@ testWithTypedArrayConstructors(function(View) {
|
||||
Atomics.store(view, Idx, 37);
|
||||
assert.sameValue(Atomics.add(view, Idx, 0), 37);
|
||||
});
|
||||
}, int_views);
|
||||
}, views);
|
||||
|
@ -6,7 +6,7 @@ esid: sec-atomics.add
|
||||
description: >
|
||||
Test Atomics.add on view values other than TypedArrays
|
||||
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) {
|
||||
|
@ -6,20 +6,17 @@ esid: sec-atomics.add
|
||||
description: >
|
||||
Test Atomics.add on non-shared integer TypedArrays
|
||||
includes: [testTypedArray.js]
|
||||
features: [Atomics, TypedArray]
|
||||
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
int_views.push(BigInt64Array);
|
||||
int_views.push(BigUint64Array);
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
var view = new View(ab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
|
||||
}, int_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.add(new TA(ab), 0, 0)));
|
||||
}, views);
|
||||
|
@ -6,15 +6,11 @@ esid: sec-atomics.add
|
||||
description: >
|
||||
Test Atomics.add on shared non-integer TypedArrays
|
||||
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(View) {
|
||||
var view = new View(sab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
|
||||
}, other_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.add(new TA(buffer), 0, 0)));
|
||||
}, floatArrayConstructors);
|
||||
|
@ -6,21 +6,20 @@ esid: sec-atomics.and
|
||||
description: >
|
||||
Test range checking of Atomics.and on arrays that allow atomic operations
|
||||
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 views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
let view = new View(sab);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
let Idx = IdxGen(view);
|
||||
assert.throws(RangeError, () => Atomics.and(view, Idx, 10));
|
||||
assert.throws(RangeError, () => Atomics.and(view, IdxGen(view), 10));
|
||||
});
|
||||
}, views);
|
||||
|
@ -5,19 +5,18 @@
|
||||
esid: sec-atomics.and
|
||||
description: Test Atomics.and on arrays that allow atomic operations
|
||||
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 ab = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new View(sab, 32, 20);
|
||||
var control = new View(ab, 0, 2);
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
view[8] = 0x33333333;
|
||||
control[0] = 0x33333333;
|
||||
@ -59,4 +58,4 @@ testWithTypedArrayConstructors(function(View) {
|
||||
Atomics.store(view, Idx, 37);
|
||||
assert.sameValue(Atomics.and(view, Idx, 0), 37);
|
||||
});
|
||||
}, int_views);
|
||||
}, views);
|
||||
|
@ -6,7 +6,7 @@ esid: sec-atomics.and
|
||||
description: >
|
||||
Test Atomics.and on view values other than TypedArrays
|
||||
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) {
|
||||
|
@ -6,20 +6,17 @@ esid: sec-atomics.and
|
||||
description: >
|
||||
Test Atomics.and on non-shared integer TypedArrays
|
||||
includes: [testTypedArray.js]
|
||||
features: [Atomics, TypedArray]
|
||||
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
int_views.push(BigInt64Array);
|
||||
int_views.push(BigUint64Array);
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
var view = new View(ab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
|
||||
}, int_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.and(new TA(buffer), 0, 0)));
|
||||
}, views);
|
||||
|
@ -6,15 +6,11 @@ esid: sec-atomics.and
|
||||
description: >
|
||||
Test Atomics.and on shared non-integer TypedArrays
|
||||
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(View) {
|
||||
var view = new View(sab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
|
||||
}, other_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.and(new TA(buffer), 0, 0)));
|
||||
}, floatArrayConstructors);
|
||||
|
@ -6,21 +6,20 @@ esid: sec-atomics.compareexchange
|
||||
description: >
|
||||
Test range checking of Atomics.compareExchange on arrays that allow atomic operations
|
||||
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 views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
let view = new View(sab);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
let Idx = IdxGen(view);
|
||||
assert.throws(RangeError, () => Atomics.compareExchange(view, Idx, 10, 0));
|
||||
assert.throws(RangeError, () => Atomics.compareExchange(view, IdxGen(view), 10, 0));
|
||||
});
|
||||
}, views);
|
||||
|
@ -5,26 +5,18 @@
|
||||
esid: sec-atomics.compareexchange
|
||||
description: Test Atomics.compareExchange on arrays that allow atomic operations.
|
||||
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 ab = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
|
||||
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) {
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new View(sab, 32, 20);
|
||||
var control = new View(ab, 0, 2);
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
// Performs the exchange
|
||||
view[8] = 0;
|
||||
@ -71,4 +63,4 @@ testWithTypedArrayConstructors(function(View) {
|
||||
Atomics.store(view, Idx, 37);
|
||||
assert.sameValue(Atomics.compareExchange(view, Idx, 37, 0), 37);
|
||||
});
|
||||
}, int_views);
|
||||
}, views);
|
||||
|
@ -6,7 +6,7 @@ esid: sec-atomics.compareexchange
|
||||
description: >
|
||||
Test Atomics.compareExchange on view values other than TypedArrays
|
||||
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) {
|
||||
|
@ -6,20 +6,17 @@ esid: sec-atomics.compareexchange
|
||||
description: >
|
||||
Test Atomics.compareExchange on non-shared integer TypedArrays
|
||||
includes: [testTypedArray.js]
|
||||
features: [Atomics, TypedArray]
|
||||
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
int_views.push(BigInt64Array);
|
||||
int_views.push(BigUint64Array);
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
var view = new View(ab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
|
||||
}, int_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.compareExchange(new TA(buffer), 0, 0, 0)));
|
||||
}, views);
|
||||
|
@ -6,15 +6,11 @@ esid: sec-atomics.compareexchange
|
||||
description: >
|
||||
Test Atomics.compareExchange on shared non-integer TypedArrays
|
||||
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(View) {
|
||||
var view = new View(sab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
|
||||
}, other_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.compareExchange(new TA(buffer), 0, 0, 0)));
|
||||
}, floatArrayConstructors);
|
||||
|
@ -6,21 +6,20 @@ esid: sec-atomics.exchange
|
||||
description: >
|
||||
Test range checking of Atomics.exchange on arrays that allow atomic operations
|
||||
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 views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
let view = new View(sab);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
let Idx = IdxGen(view);
|
||||
assert.throws(RangeError, () => Atomics.exchange(view, Idx, 10, 0));
|
||||
assert.throws(RangeError, () => Atomics.exchange(view, IdxGen(view), 10, 0));
|
||||
});
|
||||
}, views);
|
||||
|
@ -5,19 +5,18 @@
|
||||
esid: sec-atomics.exchange
|
||||
description: Test Atomics.exchange on arrays that allow atomic operations.
|
||||
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 ab = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new View(sab, 32, 20);
|
||||
var control = new View(ab, 0, 2);
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
view[8] = 0;
|
||||
assert.sameValue(Atomics.exchange(view, 8, 10), 0,
|
||||
@ -53,4 +52,4 @@ testWithTypedArrayConstructors(function(View) {
|
||||
Atomics.store(view, Idx, 37);
|
||||
assert.sameValue(Atomics.exchange(view, Idx, 0), 37);
|
||||
});
|
||||
}, int_views);
|
||||
}, views);
|
||||
|
@ -6,7 +6,7 @@ esid: sec-atomics.exchange
|
||||
description: >
|
||||
Test Atomics.exchange on view values other than TypedArrays
|
||||
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) {
|
||||
|
@ -6,20 +6,17 @@ esid: sec-atomics.exchange
|
||||
description: >
|
||||
Test Atomics.exchange on non-shared integer TypedArrays
|
||||
includes: [testTypedArray.js]
|
||||
features: [Atomics, TypedArray]
|
||||
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
int_views.push(BigInt64Array);
|
||||
int_views.push(BigUint64Array);
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
var view = new View(ab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
|
||||
}, int_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.exchange(new TA(buffer), 0, 0)));
|
||||
}, views);
|
||||
|
@ -6,15 +6,11 @@ esid: sec-atomics.exchange
|
||||
description: >
|
||||
Test Atomics.exchange on shared non-integer TypedArrays
|
||||
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(View) {
|
||||
var view = new View(sab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
|
||||
}, other_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.exchange(new TA(buffer), 0, 0)));
|
||||
}, floatArrayConstructors);
|
||||
|
@ -8,10 +8,10 @@ description: >
|
||||
features: [Atomics]
|
||||
---*/
|
||||
|
||||
assert.sameValue(false, Atomics.isLockFree(hide(3, Number.NaN)));
|
||||
assert.sameValue(false, Atomics.isLockFree(hide(3, -1)));
|
||||
assert.sameValue(false, Atomics.isLockFree(hide(3, 3.14)));
|
||||
assert.sameValue(false, Atomics.isLockFree(hide(3, 0)));
|
||||
assert.sameValue(Atomics.isLockFree(hide(3, Number.NaN)), false);
|
||||
assert.sameValue(Atomics.isLockFree(hide(3, -1)), false);
|
||||
assert.sameValue(Atomics.isLockFree(hide(3, 3.14)), false);
|
||||
assert.sameValue(Atomics.isLockFree(hide(3, 0)), false);
|
||||
|
||||
assert.sameValue(Atomics.isLockFree('1'), Atomics.isLockFree(1));
|
||||
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'}));
|
||||
|
||||
function hide(k, x) {
|
||||
if (k)
|
||||
if (k) {
|
||||
return hide(k - 3, x) + x;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -13,36 +13,33 @@ var sizes = [ 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
var answers = [ {}, {}, false, true, 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++) {
|
||||
var v = Atomics.isLockFree(sizes[i]);
|
||||
var a = answers[i];
|
||||
assert.sameValue(typeof v, 'boolean');
|
||||
if (typeof a == 'boolean')
|
||||
assert.sameValue(v, a);
|
||||
else
|
||||
saved[sizes[i]] = v;
|
||||
for (var i = 0; i < sizes.length; i++) {
|
||||
var v = Atomics.isLockFree(sizes[i]);
|
||||
var a = answers[i];
|
||||
assert.sameValue(typeof v, 'boolean');
|
||||
if (typeof a == 'boolean') {
|
||||
assert.sameValue(v, a);
|
||||
} else {
|
||||
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);
|
||||
|
@ -6,21 +6,20 @@ esid: sec-atomics.load
|
||||
description: >
|
||||
Test range checking of Atomics.load on arrays that allow atomic operations
|
||||
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 views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
let view = new View(sab);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
let Idx = IdxGen(view);
|
||||
assert.throws(RangeError, () => Atomics.load(view, Idx));
|
||||
assert.throws(RangeError, () => Atomics.load(view, IdxGen(view)));
|
||||
});
|
||||
}, views);
|
||||
|
@ -5,19 +5,19 @@
|
||||
esid: sec-atomics.load
|
||||
description: Test Atomics.load on arrays that allow atomic operations.
|
||||
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 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.
|
||||
|
||||
var view = new View(sab, 32, 20);
|
||||
var control = new View(ab, 0, 2);
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
view[3] = -5;
|
||||
control[0] = -5;
|
||||
@ -43,4 +43,4 @@ testWithTypedArrayConstructors(function(View) {
|
||||
Atomics.store(view, Idx, 37);
|
||||
assert.sameValue(Atomics.load(view, Idx), 37);
|
||||
});
|
||||
}, int_views);
|
||||
}, views);
|
||||
|
@ -6,7 +6,7 @@ esid: sec-atomics.load
|
||||
description: >
|
||||
Test Atomics.load on view values other than TypedArrays
|
||||
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) {
|
||||
|
@ -6,20 +6,20 @@ esid: sec-atomics.load
|
||||
description: >
|
||||
Test Atomics.load on non-shared integer TypedArrays
|
||||
includes: [testTypedArray.js]
|
||||
features: [Atomics, TypedArray]
|
||||
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
int_views.push(BigInt64Array);
|
||||
int_views.push(BigUint64Array);
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
var view = new View(ab);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var view = new TA(ab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.load(view, 0)));
|
||||
}, int_views);
|
||||
}, views);
|
||||
|
@ -6,15 +6,10 @@ esid: sec-atomics.load
|
||||
description: >
|
||||
Test Atomics.load on shared non-integer TypedArrays
|
||||
includes: [testTypedArray.js]
|
||||
features: [Atomics, TypedArray]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
|
||||
var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
var view = new View(sab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.load(view, 0)));
|
||||
}, other_views);
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.load(new TA(buffer), 0)));
|
||||
}, floatArrayConstructors);
|
||||
|
@ -6,21 +6,20 @@ esid: sec-atomics.or
|
||||
description: >
|
||||
Test range checking of Atomics.or on arrays that allow atomic operations
|
||||
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 views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
let view = new View(sab);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
let Idx = IdxGen(view);
|
||||
assert.throws(RangeError, () => Atomics.or(view, Idx, 10));
|
||||
assert.throws(RangeError, () => Atomics.or(view, IdxGen(view), 10));
|
||||
});
|
||||
}, views);
|
||||
|
@ -5,18 +5,18 @@
|
||||
esid: sec-atomics.or
|
||||
description: Test Atomics.or on arrays that allow atomic operations
|
||||
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 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.
|
||||
|
||||
var view = new View(sab, 32, 20);
|
||||
var control = new View(ab, 0, 2);
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
view[8] = 0x33333333;
|
||||
control[0] = 0x33333333;
|
||||
@ -58,4 +58,4 @@ testWithTypedArrayConstructors(function(View) {
|
||||
Atomics.store(view, Idx, 37);
|
||||
assert.sameValue(Atomics.or(view, Idx, 0), 37);
|
||||
});
|
||||
}, int_views);
|
||||
}, views);
|
||||
|
@ -6,7 +6,7 @@ esid: sec-atomics.or
|
||||
description: >
|
||||
Test Atomics.or on view values other than TypedArrays
|
||||
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) {
|
||||
|
@ -6,20 +6,17 @@ esid: sec-atomics.or
|
||||
description: >
|
||||
Test Atomics.or on non-shared integer TypedArrays
|
||||
includes: [testTypedArray.js]
|
||||
features: [Atomics, TypedArray]
|
||||
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
int_views.push(BigInt64Array);
|
||||
int_views.push(BigUint64Array);
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
var view = new View(ab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
|
||||
}, int_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.or(new TA(buffer), 0, 0)));
|
||||
}, views);
|
||||
|
@ -6,15 +6,13 @@ esid: sec-atomics.or
|
||||
description: >
|
||||
Test Atomics.or on shared non-integer TypedArrays
|
||||
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);
|
||||
|
@ -6,21 +6,20 @@ esid: sec-atomics.store
|
||||
description: >
|
||||
Test range checking of Atomics.store on arrays that allow atomic operations
|
||||
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 views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
let view = new View(sab);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
let Idx = IdxGen(view);
|
||||
assert.throws(RangeError, () => Atomics.store(view, Idx, 10));
|
||||
assert.throws(RangeError, () => Atomics.store(view, IdxGen(view), 10));
|
||||
});
|
||||
}, views);
|
||||
|
@ -5,19 +5,18 @@
|
||||
esid: sec-atomics.store
|
||||
description: Test Atomics.store on arrays that allow atomic operations.
|
||||
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 ab = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new View(sab, 32, 20);
|
||||
var control = new View(ab, 0, 2);
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
for (let val of [10, -5,
|
||||
12345,
|
||||
@ -44,15 +43,18 @@ testWithTypedArrayConstructors(function(View) {
|
||||
Atomics.store(view, Idx, 37);
|
||||
assert.sameValue(Atomics.load(view, Idx), 37);
|
||||
});
|
||||
}, int_views);
|
||||
}, views);
|
||||
|
||||
function ToInteger(v) {
|
||||
v = +v;
|
||||
if (isNaN(v))
|
||||
if (isNaN(v)) {
|
||||
return 0;
|
||||
if (v == 0 || !isFinite(v))
|
||||
}
|
||||
if (v == 0 || !isFinite(v)) {
|
||||
return v;
|
||||
if (v < 0)
|
||||
}
|
||||
if (v < 0) {
|
||||
return -Math.floor(Math.abs(v));
|
||||
}
|
||||
return Math.floor(v);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ esid: sec-atomics.store
|
||||
description: >
|
||||
Test Atomics.store on view values other than TypedArrays
|
||||
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) {
|
||||
|
@ -6,20 +6,17 @@ esid: sec-atomics.store
|
||||
description: >
|
||||
Test Atomics.store on non-shared integer TypedArrays
|
||||
includes: [testTypedArray.js]
|
||||
features: [Atomics, TypedArray]
|
||||
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
int_views.push(BigInt64Array);
|
||||
int_views.push(BigUint64Array);
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
var view = new View(ab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
|
||||
}, int_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.store(new TA(ab), 0, 0)));
|
||||
}, views);
|
||||
|
@ -6,15 +6,14 @@ esid: sec-atomics.store
|
||||
description: >
|
||||
Test Atomics.store on shared non-integer TypedArrays
|
||||
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);
|
||||
|
@ -6,21 +6,20 @@ esid: sec-atomics.sub
|
||||
description: >
|
||||
Test range checking of Atomics.sub on arrays that allow atomic operations
|
||||
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 views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new SharedArrayBuffer(8);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
let view = new View(sab);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(buffer);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
let Idx = IdxGen(view);
|
||||
assert.throws(RangeError, () => Atomics.sub(view, Idx, 10));
|
||||
assert.throws(RangeError, () => Atomics.sub(view, IdxGen(view), 10));
|
||||
});
|
||||
}, views);
|
||||
|
@ -5,19 +5,18 @@
|
||||
esid: sec-atomics.sub
|
||||
description: Test Atomics.sub on arrays that allow atomic operations
|
||||
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 ab = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
// Make it interesting - use non-zero byteOffsets and non-zero indexes.
|
||||
|
||||
var view = new View(sab, 32, 20);
|
||||
var control = new View(ab, 0, 2);
|
||||
var view = new TA(sab, 32, 20);
|
||||
var control = new TA(ab, 0, 2);
|
||||
|
||||
view[8] = 100;
|
||||
assert.sameValue(Atomics.sub(view, 8, 10), 100,
|
||||
@ -52,4 +51,4 @@ testWithTypedArrayConstructors(function(View) {
|
||||
Atomics.store(view, Idx, 37);
|
||||
assert.sameValue(Atomics.sub(view, Idx, 0), 37);
|
||||
});
|
||||
}, int_views);
|
||||
}, views);
|
||||
|
@ -6,7 +6,7 @@ esid: sec-atomics.sub
|
||||
description: >
|
||||
Test Atomics.sub on view values other than TypedArrays
|
||||
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) {
|
||||
|
@ -6,20 +6,17 @@ esid: sec-atomics.sub
|
||||
description: >
|
||||
Test Atomics.sub on non-shared integer TypedArrays
|
||||
includes: [testTypedArray.js]
|
||||
features: [Atomics, TypedArray]
|
||||
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
int_views.push(BigInt64Array);
|
||||
int_views.push(BigUint64Array);
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
var view = new View(ab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
|
||||
}, int_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert.throws(TypeError, (() => Atomics.sub(new TA(ab), 0, 0)));
|
||||
}, views);
|
||||
|
@ -6,15 +6,14 @@ esid: sec-atomics.sub
|
||||
description: >
|
||||
Test Atomics.sub on shared non-integer TypedArrays
|
||||
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);
|
||||
|
@ -14,12 +14,13 @@ info: |
|
||||
6. Let B be AgentCanSuspend().
|
||||
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 int32Array = new Int32Array(sab);
|
||||
|
||||
var buffer = new SharedArrayBuffer(4);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, 0, 0, 0);
|
||||
});
|
||||
|
@ -13,9 +13,17 @@ description: >
|
||||
19. Else,
|
||||
a.Perform RemoveWaiter(WL, W).
|
||||
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.receiveBroadcast(function (sab, id) {
|
||||
@ -33,9 +41,3 @@ $262.agent.broadcast(ia.buffer);
|
||||
assert.sameValue(getReport(), "timed-out");
|
||||
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;
|
||||
}
|
||||
|
68
test/built-ins/Atomics/wait/false-for-timeout-agent.js
Normal file
68
test/built-ins/Atomics/wait/false-for-timeout-agent.js
Normal 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);
|
||||
|
@ -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.
|
||||
|
||||
/*---
|
||||
@ -8,45 +8,30 @@ description: >
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
4.Let q be ? ToNumber(timeout).
|
||||
...
|
||||
Null Return +0.
|
||||
Boolean If argument is true, return 1. If argument is false, return +0.
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray ]
|
||||
includes: [ atomicsHelper.js ]
|
||||
4. Let q be ? ToNumber(timeout).
|
||||
|
||||
Boolean -> If argument is true, return 1. If argument is false, return +0.
|
||||
|
||||
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
||||
flags: [CanBlockIsFalse]
|
||||
---*/
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
$262.agent.sleep(100);
|
||||
return r;
|
||||
}
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
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 valueOf = {
|
||||
valueOf: function() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
|
@ -42,17 +42,19 @@ for ( let IdxGen of good_indices ) {
|
||||
|
||||
$262.agent.report("done");
|
||||
$262.agent.leaving();
|
||||
`)
|
||||
`);
|
||||
|
||||
assert.sameValue(getReport(), "A timed-out");
|
||||
assert.sameValue(getReport(), "B not-equal"); // Even with zero timeout
|
||||
var r;
|
||||
while ((r = getReport()) != "done")
|
||||
while ((r = getReport()) != "done") {
|
||||
assert.sameValue(r, "C not-equal");
|
||||
}
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -12,13 +12,15 @@ info: |
|
||||
...
|
||||
Undefined Return NaN.
|
||||
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() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -34,11 +36,7 @@ $262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
|
||||
$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(getReport(), "ok");
|
||||
|
@ -13,7 +13,7 @@ info: |
|
||||
2.Let accessIndex be ? ToIndex(requestIndex).
|
||||
...
|
||||
2.b If integerIndex < 0, throw a RangeError exception
|
||||
features: [ Atomics , SharedArrayBuffer, TypedArray ]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
@ -24,7 +24,15 @@ var poisoned = {
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(RangeError, () => Atomics.wait(int32Array, -Infinity, poisoned, poisoned));
|
||||
assert.throws(RangeError, () => Atomics.wait(int32Array, -7.999, 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, -Infinity, 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);
|
||||
});
|
||||
|
33
test/built-ins/Atomics/wait/negative-timeout-agent.js
Normal file
33
test/built-ins/Atomics/wait/negative-timeout-agent.js
Normal 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);
|
@ -5,26 +5,11 @@
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
Test that Atomics.wait times out with a negative timeout
|
||||
features: [Atomics]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
flags: [CanBlockIsFalse]
|
||||
---*/
|
||||
|
||||
$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);
|
||||
|
||||
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
|
||||
$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;
|
||||
}
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, -1), "timed-out");
|
||||
|
@ -7,7 +7,7 @@ description: >
|
||||
Test that Atomics.wait actually waits and does not spuriously wake
|
||||
up when the memory value is changed.
|
||||
includes: [atomicsHelper.js]
|
||||
features: [Atomics]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
$262.agent.start(
|
||||
@ -33,7 +33,8 @@ assert.sameValue((getReport() | 0) >= 1000 - $ATOMICS_MAX_TIME_EPSILON, true);
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ info: |
|
||||
...
|
||||
5.If onlyInt32 is true, then
|
||||
If typeName is not "Int32Array", throw a TypeError exception.
|
||||
features: [ Atomics, TypedArray ]
|
||||
features: [Atomics, Float32Array, Float64Array, Int8Array, TypedArray, Uint16Array, Uint8Array, Uint8ClampedArray]
|
||||
---*/
|
||||
|
||||
var poisoned = {
|
||||
|
@ -12,7 +12,7 @@ info: |
|
||||
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
|
||||
...
|
||||
4.If bufferData is a Data Block, return false.
|
||||
features: [ Atomics, ArrayBuffer, TypedArray ]
|
||||
features: [ArrayBuffer, Atomics, TypedArray]
|
||||
---*/
|
||||
|
||||
var int32Array = new Int32Array(new ArrayBuffer(4));
|
||||
@ -23,9 +23,9 @@ var poisoned = {
|
||||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, 0, 0, 0)
|
||||
Atomics.wait(int32Array, 0, 0, 0);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, poisoned, poisoned, poisoned)
|
||||
Atomics.wait(int32Array, poisoned, poisoned, poisoned);
|
||||
});
|
||||
|
@ -11,7 +11,7 @@ info: |
|
||||
...
|
||||
3.If typedArray does not have a [[TypedArrayName]] internal slot, throw a TypeError exception.
|
||||
|
||||
features: [ Atomics ]
|
||||
features: [Atomics]
|
||||
---*/
|
||||
|
||||
var poisoned = {
|
||||
@ -20,5 +20,10 @@ var poisoned = {
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(TypeError, () => Atomics.wait({}, 0, 0, 0));
|
||||
assert.throws(TypeError, () => Atomics.wait({}, poisoned, poisoned, poisoned));
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait({}, 0, 0, 0);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait({}, poisoned, poisoned, poisoned);
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ info: |
|
||||
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
...
|
||||
2. if Type(typedArray) is not Object, throw a TypeError exception
|
||||
features: [ Atomics, Symbol ]
|
||||
features: [Atomics, Symbol]
|
||||
---*/
|
||||
|
||||
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');
|
||||
|
@ -13,7 +13,7 @@ info: |
|
||||
...
|
||||
3.If bufferData is null, return false.
|
||||
includes: [detachArrayBuffer.js]
|
||||
features: [ Atomics, ArrayBuffer, TypedArray ]
|
||||
features: [ArrayBuffer, Atomics, TypedArray]
|
||||
---*/
|
||||
|
||||
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
|
||||
|
||||
assert.throws(TypeError, () => Atomics.wait(int32Array, poisoned, poisoned, poisoned));
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, poisoned, poisoned, poisoned);
|
||||
});
|
||||
|
68
test/built-ins/Atomics/wait/null-for-timeout-agent.js
Normal file
68
test/built-ins/Atomics/wait/null-for-timeout-agent.js
Normal 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);
|
||||
|
@ -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.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
Null timeout arg should result in an +0 timeout
|
||||
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).
|
||||
...
|
||||
Null Return +0.
|
||||
Boolean If argument is true, return 1. If argument is false, return +0.
|
||||
features: [ Atomics ]
|
||||
includes: [ atomicsHelper.js ]
|
||||
4. Let q be ? ToNumber(timeout).
|
||||
|
||||
Null -> Return +0.
|
||||
|
||||
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
||||
flags: [CanBlockIsFalse]
|
||||
---*/
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
$262.agent.sleep(100);
|
||||
return r;
|
||||
}
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
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 valueOf = {
|
||||
valueOf: function() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
|
75
test/built-ins/Atomics/wait/object-for-timeout-agent.js
Normal file
75
test/built-ins/Atomics/wait/object-for-timeout-agent.js
Normal 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);
|
||||
|
@ -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.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
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: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
4.Let q be ? ToNumber(timeout).
|
||||
...
|
||||
Object
|
||||
Apply the following steps:
|
||||
4. Let q be ? ToNumber(timeout).
|
||||
|
||||
Object -> Apply the following steps:
|
||||
|
||||
Let primValue be ? ToPrimitive(argument, hint Number).
|
||||
Return ? ToNumber(primValue).
|
||||
features: [ Atomics ]
|
||||
includes: [atomicsHelper.js]
|
||||
|
||||
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
||||
flags: [CanBlockIsFalse]
|
||||
---*/
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
$262.agent.sleep(100);
|
||||
return r;
|
||||
}
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
|
||||
var valueOf = {
|
||||
valueOf: function() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report("A " + Atomics.wait(int32Array, 0, 0, {})); // {} => NaN => Infinity
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
var toString = {
|
||||
toString: function() {
|
||||
return "0";
|
||||
}
|
||||
};
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
||||
var toPrimitive = {
|
||||
[Symbol.toPrimitive]: function() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
|
||||
$262.agent.sleep(500); // Ample time
|
||||
|
||||
assert.sameValue(Atomics.wake(int32Array, 0), 1);
|
||||
|
||||
assert.sameValue(getReport(), "A ok");
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, valueOf), "timed-out");
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, toString), "timed-out");
|
||||
assert.sameValue(Atomics.wait(int32Array, 0, 0, toPrimitive), "timed-out");
|
||||
|
@ -13,16 +13,23 @@ info: |
|
||||
2.Let accessIndex be ? ToIndex(requestIndex).
|
||||
...
|
||||
5. If accessIndex ≥ length, throw a RangeError exception.
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray ]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(4));
|
||||
|
||||
var poisoned = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(RangeError, () => Atomics.wait(int32Array, Infinity, poisoned, poisoned));
|
||||
assert.throws(RangeError, () => Atomics.wait(int32Array, 2, poisoned, poisoned));
|
||||
assert.throws(RangeError, () => Atomics.wait(int32Array, 200, poisoned, poisoned));
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(int32Array, Infinity, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(int32Array, 2, poisoned, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wait(int32Array, 200, poisoned, poisoned);
|
||||
});
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
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: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
4.Let q be ? ToNumber(timeout).
|
||||
...
|
||||
Object
|
||||
Apply the following steps:
|
||||
4. Let q be ? ToNumber(timeout).
|
||||
|
||||
Object -> Apply the following steps:
|
||||
|
||||
Let primValue be ? ToPrimitive(argument, hint Number).
|
||||
...
|
||||
g. Return ? OrdinaryToPrimitive(input, hint).
|
||||
...
|
||||
6.Throw a TypeError exception.
|
||||
features: [ Atomics ]
|
||||
Return ? ToNumber(primValue).
|
||||
|
||||
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
||||
---*/
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
|
||||
var poisonedValueOf = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
|
||||
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;
|
||||
var poisonedToPrimitive = {
|
||||
[Symbol.toPrimitive]: function() {
|
||||
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
|
||||
}
|
||||
|
||||
$262.agent.report(err);
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
};
|
||||
|
||||
var sab = new SharedArrayBuffer(4);
|
||||
var int32Array = new Int32Array(sab);
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, 0, 0, poisonedValueOf);
|
||||
});
|
||||
|
||||
$262.agent.broadcast(int32Array.buffer);
|
||||
|
||||
assert.sameValue(getReport(), 'TypeError');
|
||||
|
||||
assert.sameValue(Atomics.wake(int32Array, 0), 0);
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, 0, 0, poisonedToPrimitive);
|
||||
});
|
||||
|
86
test/built-ins/Atomics/wait/symbol-for-index-throws-agent.js
Normal file
86
test/built-ins/Atomics/wait/symbol-for-index-throws-agent.js
Normal 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);
|
||||
|
@ -8,40 +8,53 @@ description: >
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
3.Let v be ? ToInt32(value).
|
||||
...
|
||||
1.Let number be ? ToNumber(argument).
|
||||
Symbol --> Throw a TypeError exception.
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray, Symbol, Symbol.toPrimitive]
|
||||
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]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(sab);
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
|
||||
var poisoned = {
|
||||
var poisonedValueOf = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
var poisonedWithString = {
|
||||
get valueOf() { throw "should not evaluate this code"; }
|
||||
};
|
||||
|
||||
var poisonedToPrimitive = {
|
||||
get [Symbol.ToPrimitive]() {
|
||||
throw new Test262Error('passing a poisoned object using @@ToPrimitive');
|
||||
[Symbol.toPrimitive]: function() {
|
||||
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() {
|
||||
Atomics.wait(int32Array, Symbol('foo'), poisonedWithString, poisonedWithString)
|
||||
}, 'Symbol');
|
||||
Atomics.wait(int32Array, Symbol("foo"), poisonedValueOf, poisonedValueOf);
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, poisoned, poisonedWithString, poisonedWithString)
|
||||
}, 'passing a poisoned object using valueOf');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, poisoned, poisonedToPrimitive, poisonedToPrimitive);
|
||||
}, 'passing a poisoned object using @@ToPrimitive');
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, Symbol("foo"), poisonedToPrimitive, poisonedToPrimitive);
|
||||
});
|
||||
|
@ -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);
|
@ -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.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
Throws a TypeError if timeout arg is a Symbol
|
||||
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, TypedArray, Symbol]
|
||||
4. Let q be ? ToNumber(timeout).
|
||||
|
||||
Symbol --> Throw a TypeError exception.
|
||||
|
||||
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
||||
---*/
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
|
||||
var poisonedValueOf = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
|
||||
var int32Array = new Int32Array(sab);
|
||||
var err;
|
||||
|
||||
try {
|
||||
Atomics.wait(int32Array, 0, 0, Symbol('foo'));
|
||||
} catch(e) {
|
||||
err = e.name;
|
||||
var poisonedToPrimitive = {
|
||||
[Symbol.toPrimitive]: function() {
|
||||
throw new Test262Error("passing a poisoned object using @@ToPrimitive");
|
||||
}
|
||||
|
||||
$262.agent.report(err);
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
};
|
||||
|
||||
var sab = new SharedArrayBuffer(4);
|
||||
var int32Array = new Int32Array(sab);
|
||||
assert.throws(Test262Error, function() {
|
||||
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"));
|
||||
});
|
||||
|
76
test/built-ins/Atomics/wait/symbol-for-value-throws-agent.js
Normal file
76
test/built-ins/Atomics/wait/symbol-for-value-throws-agent.js
Normal 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);
|
@ -8,41 +8,45 @@ description: >
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
3.Let v be ? ToInt32(value).
|
||||
...
|
||||
1.Let number be ? ToNumber(argument).
|
||||
...
|
||||
Symbol Throw a TypeError exception.
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray, Symbol]
|
||||
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]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(sab);
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
|
||||
var poisoned = {
|
||||
var poisonedValueOf = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
var poisonedWithString = {
|
||||
get valueOf() { throw "should not evaluate this code"; }
|
||||
};
|
||||
|
||||
var poisonedToPrimitive = {
|
||||
get [Symbol.ToPrimitive]() {
|
||||
throw new Test262Error('passing a poisoned object using @@ToPrimitive');
|
||||
[Symbol.toPrimitive]: function() {
|
||||
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() {
|
||||
Atomics.wait(int32Array, 0, Symbol('foo'), poisonedWithString)
|
||||
}, 'Symbol');
|
||||
Atomics.wait(int32Array, 0, Symbol("foo"), poisonedValueOf);
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, 0, poisoned, poisonedWithString)
|
||||
}, 'passing a poisoned object using valueOf');
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait(int32Array, 0, Symbol("foo"), poisonedToPrimitive);
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wait(int32Array, 0, poisoned, poisonedToPrimitive);
|
||||
}, 'passing a poisoned object using @@ToPrimitive');
|
||||
|
68
test/built-ins/Atomics/wait/true-for-timeout-agent.js
Normal file
68
test/built-ins/Atomics/wait/true-for-timeout-agent.js
Normal 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);
|
||||
|
@ -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.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
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: |
|
||||
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]
|
||||
4. Let q be ? ToNumber(timeout).
|
||||
|
||||
Boolean -> If argument is true, return 1. If argument is false, return +0.
|
||||
|
||||
features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
|
||||
flags: [CanBlockIsFalse]
|
||||
---*/
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
$262.agent.sleep(100);
|
||||
return r;
|
||||
}
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
|
||||
var valueOf = {
|
||||
valueOf: function() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
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 toPrimitive = {
|
||||
[Symbol.toPrimitive]: function() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
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");
|
||||
|
@ -12,7 +12,7 @@ info: |
|
||||
...
|
||||
Undefined Return NaN.
|
||||
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
|
||||
@ -21,8 +21,9 @@ var WAKECOUNT = 2; // Total number of agents to wake up
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,12 @@ info: |
|
||||
|
||||
If value is undefined, then
|
||||
Let index be 0.
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray ]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
$262.agent.report(Atomics.wait(int32Array, undefined, 0, 1000)); // undefined index => 0
|
||||
$262.agent.leaving();
|
||||
@ -43,7 +43,8 @@ assert.sameValue(getReport(), "ok");
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -14,28 +14,29 @@ info: |
|
||||
a.Perform LeaveCriticalSection(WL).
|
||||
b. Return the String "not-equal".
|
||||
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray ]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
includes: [atomicsHelper.js]
|
||||
---*/
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
var value = 42;
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
|
||||
|
||||
$262.agent.report(Atomics.store(int32Array, 0, ${value}));
|
||||
|
||||
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 0));
|
||||
|
||||
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
|
@ -12,7 +12,7 @@ info: |
|
||||
a.Perform LeaveCriticalSection(WL).
|
||||
b. Return the String "not-equal".
|
||||
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray ]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
function getReport() {
|
||||
@ -24,12 +24,12 @@ function getReport() {
|
||||
}
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
|
||||
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 44, 1000));
|
||||
|
||||
|
||||
$262.agent.report(Atomics.wait(int32Array, 0, 251.4, 1000));
|
||||
|
||||
$262.agent.leaving();
|
||||
|
@ -12,7 +12,7 @@ info: |
|
||||
...
|
||||
3.Add W to the end of the list of waiters in WL.
|
||||
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray ]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
function getReport() {
|
||||
@ -28,14 +28,14 @@ var agent2 = '2';
|
||||
var agent3 = '3';
|
||||
|
||||
$262.agent.start(
|
||||
`
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
|
||||
$262.agent.report(${agent1});
|
||||
|
||||
$262.agent.report(${agent1});
|
||||
Atomics.wait(int32Array, 0, 0);
|
||||
$262.agent.report(${agent1});
|
||||
|
||||
$262.agent.report(${agent1});
|
||||
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
@ -44,12 +44,12 @@ $262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
|
||||
|
||||
$262.agent.report(${agent2});
|
||||
|
||||
Atomics.wait(int32Array, 0, 0);
|
||||
$262.agent.report(${agent2});
|
||||
|
||||
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
@ -58,12 +58,12 @@ $262.agent.start(
|
||||
`
|
||||
$262.agent.receiveBroadcast(function (sab) {
|
||||
var int32Array = new Int32Array(sab);
|
||||
|
||||
|
||||
$262.agent.report(${agent3});
|
||||
|
||||
|
||||
Atomics.wait(int32Array, 0, 0);
|
||||
$262.agent.report(${agent3});
|
||||
|
||||
|
||||
$262.agent.leaving();
|
||||
})
|
||||
`);
|
||||
|
@ -21,34 +21,36 @@ info: |
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sleeping = 100;
|
||||
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);
|
||||
$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");
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
sleeping += 100;
|
||||
$262.agent.sleep(100);
|
||||
}
|
||||
return r;
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
sleeping += 100;
|
||||
$262.agent.sleep(100);
|
||||
}
|
||||
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");
|
||||
|
||||
|
@ -5,25 +5,9 @@
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
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() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
@ -31,3 +15,19 @@ function getReport() {
|
||||
}
|
||||
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");
|
||||
|
@ -6,7 +6,7 @@ esid: sec-atomics.wake
|
||||
description: >
|
||||
Test range checking of Atomics.wake on arrays that allow atomic operations
|
||||
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);
|
||||
@ -16,8 +16,8 @@ if (typeof BigInt !== "undefined") {
|
||||
views.push(BigInt64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
let view = new View(sab);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(sab);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
let Idx = IdxGen(view);
|
||||
assert.throws(RangeError, () => Atomics.wake(view, Idx, 0)); // Even with waking zero
|
||||
|
@ -5,7 +5,7 @@
|
||||
esid: sec-atomics.wake
|
||||
description: >
|
||||
Allowed boundary cases of the third 'count' argument to Atomics.wake
|
||||
features: [Atomics]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(4);
|
||||
|
@ -7,12 +7,12 @@ description: >
|
||||
Test Atomics.wait on arrays that allow atomic operations,
|
||||
in an Agent that is allowed to wait. There is only the one Agent.
|
||||
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 ab = new ArrayBuffer(16);
|
||||
var int_views = [Int32Array];
|
||||
var views = [Int32Array];
|
||||
var view = new Int32Array(sab, 32, 20);
|
||||
|
||||
view[0] = 0;
|
||||
|
@ -10,7 +10,7 @@ info: |
|
||||
|
||||
3.If count is undefined, let c be +∞.
|
||||
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray ]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var NUMAGENT = 4; // Total number of agents started
|
||||
|
@ -5,7 +5,7 @@
|
||||
esid: sec-atomics.wake
|
||||
description: >
|
||||
Test that Atomics.wake wakes zero waiters if the count is negative
|
||||
features: [Atomics]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
$262.agent.start(
|
||||
|
@ -13,7 +13,7 @@ info: |
|
||||
2.Let accessIndex be ? ToIndex(requestIndex).
|
||||
...
|
||||
2.b If integerIndex < 0, throw a RangeError exception
|
||||
features: [ Atomics , SharedArrayBuffer, TypedArray ]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
|
@ -12,7 +12,7 @@ info: |
|
||||
...
|
||||
5.If onlyInt32 is true, then
|
||||
If typeName is not "Int32Array", throw a TypeError exception.
|
||||
features: [ Atomics, TypedArray ]
|
||||
features: [Atomics, Float32Array, Float64Array, Int8Array, TypedArray, Uint16Array, Uint8Array, Uint8ClampedArray]
|
||||
---*/
|
||||
|
||||
var poisoned = {
|
||||
|
@ -12,7 +12,7 @@ info: |
|
||||
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
|
||||
...
|
||||
4.If bufferData is a Data Block, return false.
|
||||
features: [ Atomics, ArrayBuffer, TypedArray ]
|
||||
features: [ArrayBuffer, Atomics, TypedArray]
|
||||
---*/
|
||||
|
||||
var int32Array = new Int32Array(new ArrayBuffer(4));
|
||||
|
@ -6,7 +6,7 @@ esid: sec-atomics.wake
|
||||
description: >
|
||||
Test Atomics.wake on view values other than TypedArrays
|
||||
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) {
|
||||
|
@ -6,20 +6,18 @@ esid: sec-atomics.wake
|
||||
description: >
|
||||
Test Atomics.wake on non-shared integer TypedArrays
|
||||
includes: [testTypedArray.js]
|
||||
features: [Atomics, TypedArray]
|
||||
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var ab = new ArrayBuffer(16);
|
||||
|
||||
var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
|
||||
var buffer = new ArrayBuffer(16);
|
||||
var views = intArrayConstructors.slice();
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
int_views.push(BigInt64Array);
|
||||
int_views.push(BigUint64Array);
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(View) {
|
||||
var view = new View(ab);
|
||||
|
||||
assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Should fail even if waking zero waiters
|
||||
}, int_views);
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
// Should fail even if waking zero waiters
|
||||
assert.throws(TypeError, (() => Atomics.wake(new TA(buffer), 0, 0)));
|
||||
}, views);
|
||||
|
@ -11,7 +11,7 @@ info: |
|
||||
...
|
||||
3.If typedArray does not have a [[TypedArrayName]] internal slot, throw a TypeError exception.
|
||||
|
||||
features: [ Atomics ]
|
||||
features: [Atomics]
|
||||
---*/
|
||||
|
||||
var poisoned = {
|
||||
@ -21,9 +21,9 @@ var poisoned = {
|
||||
};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wait({}, 0, 0, 0)
|
||||
Atomics.wait({}, 0, 0, 0);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function () {
|
||||
Atomics.wait({}, poisoned, poisoned, poisoned)
|
||||
Atomics.wait({}, poisoned, poisoned, poisoned);
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ info: |
|
||||
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
...
|
||||
2. if Type(typedArray) is not Object, throw a TypeError exception
|
||||
features: [ Atomics, Symbol ]
|
||||
features: [Atomics, Symbol]
|
||||
---*/
|
||||
|
||||
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');
|
||||
|
@ -13,7 +13,7 @@ info: |
|
||||
...
|
||||
3.If bufferData is null, return false.
|
||||
includes: [detachArrayBuffer.js]
|
||||
features: [ Atomics, ArrayBuffer, TypedArray ]
|
||||
features: [ArrayBuffer, Atomics, TypedArray]
|
||||
---*/
|
||||
|
||||
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
|
||||
|
||||
assert.throws(TypeError, () => Atomics.wake(int32Array, poisoned, poisoned));
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wake(int32Array, poisoned, poisoned);
|
||||
});
|
||||
|
@ -13,7 +13,7 @@ info: |
|
||||
2.Let accessIndex be ? ToIndex(requestIndex).
|
||||
...
|
||||
5. If accessIndex ≥ length, throw a RangeError exception.
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray ]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var int32Array = new Int32Array(new SharedArrayBuffer(4));
|
||||
@ -23,6 +23,12 @@ var poisoned = {
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(RangeError, () => Atomics.wake(int32Array, Infinity, poisoned));
|
||||
assert.throws(RangeError, () => Atomics.wake(int32Array, 2, poisoned));
|
||||
assert.throws(RangeError, () => Atomics.wake(int32Array, 200, poisoned));
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wake(int32Array, Infinity, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wake(int32Array, 2, poisoned);
|
||||
});
|
||||
assert.throws(RangeError, function() {
|
||||
Atomics.wake(int32Array, 200, poisoned);
|
||||
});
|
||||
|
@ -6,17 +6,14 @@ esid: sec-atomics.wake
|
||||
description: >
|
||||
Test Atomics.wake on shared non-integer TypedArrays
|
||||
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);
|
||||
|
@ -3,45 +3,58 @@
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wake
|
||||
description:
|
||||
description: >
|
||||
Throws a TypeError if index arg can not be converted to an Integer
|
||||
info: |
|
||||
Atomics.wake( typedArray, index, count )
|
||||
Atomics.wake( typedArray, index, value, timeout )
|
||||
|
||||
3.Let v be ? ToInt32(value).
|
||||
...
|
||||
1.Let number be ? ToNumber(argument).
|
||||
Symbol --> Throw a TypeError exception.
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray, Symbol, Symbol.toPrimitive]
|
||||
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]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(sab);
|
||||
var buffer = new SharedArrayBuffer(1024);
|
||||
var int32Array = new Int32Array(buffer);
|
||||
|
||||
var poisoned = {
|
||||
var poisonedValueOf = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error("should not evaluate this code");
|
||||
}
|
||||
};
|
||||
|
||||
var poisonedWithString = {
|
||||
get valueOf() { throw "should not evaluate this code"; }
|
||||
};
|
||||
|
||||
var poisonedToPrimitive = {
|
||||
get [Symbol.ToPrimitive]() {
|
||||
throw new Test262Error('passing a poisoned object using @@ToPrimitive');
|
||||
[Symbol.toPrimitive]: function() {
|
||||
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() {
|
||||
Atomics.wake(int32Array, Symbol('foo'), poisonedWithString, poisonedWithString)
|
||||
}, 'Symbol');
|
||||
Atomics.wake(int32Array, Symbol("foo"), poisonedValueOf);
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wake(int32Array, poisoned, poisonedWithString, poisonedWithString)
|
||||
}, 'passing a poisoned object using valueOf');
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Atomics.wake(int32Array, poisoned, poisonedToPrimitive, poisonedToPrimitive);
|
||||
}, 'passing a poisoned object using @@ToPrimitive');
|
||||
assert.throws(TypeError, function() {
|
||||
Atomics.wake(int32Array, Symbol("foo"), poisonedToPrimitive);
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ info: |
|
||||
|
||||
3.If count is undefined, let c be +∞.
|
||||
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray ]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var NUMAGENT = 4; // Total number of agents started
|
||||
|
@ -18,7 +18,7 @@ info: |
|
||||
|
||||
If value is undefined, then
|
||||
Let index be 0.
|
||||
features: [ Atomics, SharedArrayBuffer, TypedArray ]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
$262.agent.start(
|
||||
|
@ -6,7 +6,7 @@ esid: sec-atomics.wake
|
||||
description: >
|
||||
Test that Atomics.wake wakes all waiters on a location, but does not
|
||||
wake waiters on other locations.
|
||||
features: [Atomics]
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var WAKEUP = 0; // Waiters on this will be woken
|
||||
@ -53,18 +53,21 @@ $262.agent.sleep(500);
|
||||
assert.sameValue(Atomics.wake(ia, WAKEUP), NUMAGENT);
|
||||
|
||||
var rs = [];
|
||||
for (var i = 0; i < NUMAGENT + 1; i++)
|
||||
for (var i = 0; i < NUMAGENT + 1; i++) {
|
||||
rs.push(getReport());
|
||||
}
|
||||
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[NUMAGENT], "B timed-out");
|
||||
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null)
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(100);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user