Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/wait/false-for-timeout.js

raw
1 // |reftest| skip-if(!xulRuntime.shell||!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- browser cannot block main thread, Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics
2 // Copyright (C) 2018 Amal Hussein. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-atomics.wait
7 description: >
8 False timeout arg should result in an +0 timeout
9 info: |
10 Atomics.wait( typedArray, index, value, timeout )
11
12 4. Let q be ? ToNumber(timeout).
13
14 Boolean -> If argument is true, return 1. If argument is false, return +0.
15
16 features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
17 flags: [CanBlockIsTrue]
18 ---*/
19
20 const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4));
21
22 const valueOf = {
23 valueOf: function() {
24 return false;
25 }
26 };
27
28 const toPrimitive = {
29 [Symbol.toPrimitive]: function() {
30 return false;
31 }
32 };
33
34 assert.sameValue(
35 Atomics.wait(i32a, 0, 0, false),
36 'timed-out',
37 'Atomics.wait(i32a, 0, 0, false) returns "timed-out"'
38 );
39 assert.sameValue(
40 Atomics.wait(i32a, 0, 0, valueOf),
41 'timed-out',
42 'Atomics.wait(i32a, 0, 0, valueOf) returns "timed-out"'
43 );
44 assert.sameValue(
45 Atomics.wait(i32a, 0, 0, toPrimitive),
46 'timed-out',
47 'Atomics.wait(i32a, 0, 0, toPrimitive) returns "timed-out"'
48 );
49
50 reportCompare(0, 0);