| 1 |
// |reftest| shell-option(--setpref=atomics_wait_async) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!this.hasOwnProperty('Atomics')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))||!xulRuntime.shell) -- SharedArrayBuffer,Atomics is not enabled unconditionally, ARM64 Simulator cannot emulate atomics, requires shell-options |
| 2 |
// Copyright (C) 2020 Rick Waldron. All rights reserved. |
| 3 |
// This code is governed by the BSD license found in the LICENSE file. |
| 4 |
|
| 5 |
/*--- |
| 6 |
esid: sec-atomics.waitasync |
| 7 |
description: > |
| 8 |
Throws a RangeError is index < 0 |
| 9 |
info: | |
| 10 |
Atomics.waitAsync( typedArray, index, value, timeout ) |
| 11 |
|
| 12 |
1. Return DoWait(async, typedArray, index, value, timeout). |
| 13 |
|
| 14 |
DoWait ( mode, typedArray, index, value, timeout ) |
| 15 |
|
| 16 |
1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true). |
| 17 |
2. Let i be ? ValidateAtomicAccess(typedArray, index). |
| 18 |
|
| 19 |
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt] |
| 20 |
---*/ |
| 21 |
assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"'); |
| 22 |
const i64a = new BigInt64Array( |
| 23 |
new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4) |
| 24 |
); |
| 25 |
|
| 26 |
const poisoned = { |
| 27 |
valueOf() { |
| 28 |
throw new Test262Error('should not evaluate this code'); |
| 29 |
} |
| 30 |
}; |
| 31 |
|
| 32 |
assert.throws(RangeError, function() { |
| 33 |
Atomics.waitAsync(i64a, -Infinity, poisoned, poisoned); |
| 34 |
}, '`Atomics.waitAsync(i64a, -Infinity, poisoned, poisoned)` throws a RangeError exception'); |
| 35 |
assert.throws(RangeError, function() { |
| 36 |
Atomics.waitAsync(i64a, -7.999, poisoned, poisoned); |
| 37 |
}, '`Atomics.waitAsync(i64a, -7.999, poisoned, poisoned)` throws a RangeError exception'); |
| 38 |
assert.throws(RangeError, function() { |
| 39 |
Atomics.waitAsync(i64a, -1, poisoned, poisoned); |
| 40 |
}, '`Atomics.waitAsync(i64a, -1, poisoned, poisoned)` throws a RangeError exception'); |
| 41 |
assert.throws(RangeError, function() { |
| 42 |
Atomics.waitAsync(i64a, -300, poisoned, poisoned); |
| 43 |
}, '`Atomics.waitAsync(i64a, -300, poisoned, poisoned)` throws a RangeError exception'); |
| 44 |
|
| 45 |
|
| 46 |
reportCompare(0, 0); |