mirror of https://github.com/tc39/test262.git
Atomics.wait: additional coverage. Completes gh-1466
This commit is contained in:
parent
d12d7d270e
commit
a43777651c
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wake
|
||||
description: >
|
||||
Test range checking of Atomics.wake on arrays that allow atomic operations
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
|
||||
...
|
||||
|
||||
includes: [testAtomics.js, testTypedArray.js]
|
||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
var sab = new SharedArrayBuffer(8);
|
||||
var views = [Int32Array];
|
||||
|
||||
if (typeof BigInt !== "undefined") {
|
||||
views.push(BigInt64Array);
|
||||
views.push(BigUint64Array);
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let view = new TA(sab);
|
||||
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
||||
assert.throws(RangeError, () => Atomics.wake(view, IdxGen(view), 0)); // Even with waking zero
|
||||
});
|
||||
}, views);
|
|
@ -0,0 +1,62 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-atomics.wait
|
||||
description: >
|
||||
Get the correct WaiterList
|
||||
info: |
|
||||
Atomics.wait( typedArray, index, value, timeout )
|
||||
|
||||
...
|
||||
11. Let WL be GetWaiterList(block, indexedPosition).
|
||||
...
|
||||
|
||||
|
||||
GetWaiterList( block, i )
|
||||
|
||||
...
|
||||
4. Return the WaiterList that is referenced by the pair (block, i).
|
||||
|
||||
features: [Atomics, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
function getReport() {
|
||||
var r;
|
||||
while ((r = $262.agent.getReport()) == null) {
|
||||
$262.agent.sleep(10);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32 = new Int32Array(sab);
|
||||
|
||||
// Wait on index 0
|
||||
Atomics.wait(i32, 0, 0, 200);
|
||||
$262.agent.report("fail");
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
$262.agent.start(`
|
||||
$262.agent.receiveBroadcast(function(sab) {
|
||||
var i32 = new Int32Array(sab);
|
||||
|
||||
// Wait on index 2
|
||||
Atomics.wait(i32, 2, 0, 200);
|
||||
$262.agent.report("pass");
|
||||
$262.agent.leaving();
|
||||
});
|
||||
`);
|
||||
|
||||
var length = 4 * Int32Array.BYTES_PER_ELEMENT;
|
||||
var i32 = new Int32Array(new SharedArrayBuffer(length));
|
||||
|
||||
$262.agent.broadcast(i32.buffer);
|
||||
$262.agent.sleep(10);
|
||||
|
||||
// Wake index 2
|
||||
Atomics.wake(i32, 2, 1);
|
||||
|
||||
assert.sameValue(getReport(), "pass");
|
Loading…
Reference in New Issue