Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/waitAsync/false-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 /*---
6 esid: sec-atomics.waitasync
7 description: >
8 False timeout arg should result in an +0 timeout
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 6. Let q be ? ToNumber(timeout).
17
18 flags: [async]
19 features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
20 ---*/
21 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
22 const i32a = new Int32Array(
23 new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
24 );
25
26 const valueOf = {
27 valueOf() {
28 return false;
29 }
30 };
31
32 const toPrimitive = {
33 [Symbol.toPrimitive]() {
34 return false;
35 }
36 };
37
38 assert.sameValue(
39 Atomics.waitAsync(i32a, 0, 0, false).value,
40 'timed-out',
41 'The value of Atomics.waitAsync(i32a, 0, 0, false).value is "timed-out"'
42 );
43
44 assert.sameValue(
45 Atomics.waitAsync(i32a, 0, 0, valueOf).value,
46 'timed-out',
47 'The value of Atomics.waitAsync(i32a, 0, 0, valueOf).value is "timed-out"'
48 );
49
50 assert.sameValue(
51 Atomics.waitAsync(i32a, 0, 0, toPrimitive).value,
52 'timed-out',
53 'The value of Atomics.waitAsync(i32a, 0, 0, toPrimitive).value is "timed-out"'
54 );
55
56 Promise.all([
57 Atomics.waitAsync(i32a, 0, 0, false).value,
58 Atomics.waitAsync(i32a, 0, 0, valueOf).value,
59 Atomics.waitAsync(i32a, 0, 0, toPrimitive).value,
60 ]).then(outcomes => {
61 assert.sameValue(outcomes[0], 'timed-out', 'The value of outcomes[0] is "timed-out"');
62 assert.sameValue(outcomes[1], 'timed-out', 'The value of outcomes[1] is "timed-out"');
63 assert.sameValue(outcomes[2], 'timed-out', 'The value of outcomes[2] is "timed-out"');
64 }).then($DONE, $DONE);