Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/wait/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) 2017 Mozilla Corporation. 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, SharedArrayBuffer, TypedArray]
11 ---*/
12
13 const RUNNING = 1;
14
15 $262.agent.start(`
16 $262.agent.receiveBroadcast(function(sab) {
17 var i32a = new Int32Array(sab);
18 Atomics.add(i32a, ${RUNNING}, 1);
19
20 $262.agent.report(Atomics.wait(i32a, 0, 0, -5)); // -5 => 0
21 $262.agent.leaving();
22 });
23 `);
24
25 const i32a = new Int32Array(
26 new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
27 );
28
29 $262.agent.safeBroadcast(i32a);
30 $262.agent.waitUntil(i32a, RUNNING, 1);
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(i32a, 0), 0, 'Atomics.notify(i32a, 0) returns 0');
41
42 reportCompare(0, 0);