Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/waitAsync/bigint/undefined-for-timeout.js

raw
1 // |reftest| shell-option(--setpref=atomics_wait_async) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!this.hasOwnProperty('Atomics')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))||!xulRuntime.shell) async -- 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 esid: sec-atomics.waitasync
6 description: >
7 Undefined timeout arg is coerced to zero
8 info: |
9 Atomics.waitAsync( typedArray, index, value, timeout )
10
11 1. Return DoWait(async, typedArray, index, value, timeout).
12
13 DoWait ( mode, typedArray, index, value, timeout )
14
15 6. Let q be ? ToNumber(timeout).
16 ...
17 Undefined Return NaN.
18
19 5.If q is NaN, let t be +∞, else let t be max(q, 0)
20
21 flags: [async]
22 features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
23 ---*/
24 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
25 const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
26
27 const valueOf = {
28 valueOf() {
29 return undefined;
30 }
31 };
32
33 const toPrimitive = {
34 [Symbol.toPrimitive]() {
35 return undefined;
36 }
37 };
38
39 Promise.all([
40 Atomics.waitAsync(i64a, 0, 0n).value,
41 Atomics.waitAsync(i64a, 0, 0n, undefined).value,
42 Atomics.waitAsync(i64a, 0, 0n, valueOf).value,
43 Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value
44 ]).then(outcomes => {
45 assert.sameValue(outcomes[0], 'ok', 'The value of outcomes[0] is "ok"');
46 assert.sameValue(outcomes[1], 'ok', 'The value of outcomes[1] is "ok"');
47 assert.sameValue(outcomes[2], 'ok', 'The value of outcomes[2] is "ok"');
48 assert.sameValue(outcomes[3], 'ok', 'The value of outcomes[3] is "ok"');
49 }).then($DONE, $DONE);
50
51 Atomics.notify(i64a, 0);