Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/wait/bigint/negative-timeout-agent.js

raw
1 // |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics
2 // Copyright (C) 2018 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.wait
7 description: >
8 Test that Atomics.wait times out with a negative timeout
9 includes: [atomicsHelper.js]
10 features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
11 ---*/
12
13 const i64a = new BigInt64Array(
14 new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
15 );
16
17 const RUNNING = 1;
18
19 $262.agent.start(`
20 $262.agent.receiveBroadcast(function(sab) {
21 const i64a = new BigInt64Array(sab);
22 Atomics.add(i64a, ${RUNNING}, 1n);
23
24 $262.agent.report(Atomics.wait(i64a, 0, 0n, -5)); // -5 => 0
25 $262.agent.leaving();
26 });
27 `);
28
29 $262.agent.safeBroadcast(i64a);
30 $262.agent.waitUntil(i64a, RUNNING, 1n);
31
32 // Try to yield control to ensure the agent actually started to wait.
33 $262.agent.tryYield();
34
35 assert.sameValue(
36 $262.agent.getReport(),
37 'timed-out',
38 '$262.agent.getReport() returns "timed-out"'
39 );
40 assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
41
42 reportCompare(0, 0);