Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/notify/notify-nan.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.notify
7 description: >
8 Test that Atomics.nofity nofities zero waiters if the count is NaN
9 includes: [atomicsHelper.js]
10 features: [Atomics, SharedArrayBuffer, TypedArray]
11 ---*/
12
13 const RUNNING = 1;
14 const TIMEOUT = $262.agent.timeouts.long;
15
16 $262.agent.start(`
17 $262.agent.receiveBroadcast(function(sab) {
18 const i32a = new Int32Array(sab);
19 Atomics.add(i32a, ${RUNNING}, 1);
20
21 $262.agent.report(Atomics.wait(i32a, 0, 0, ${TIMEOUT})); // We will timeout eventually
22 $262.agent.leaving();
23 });
24 `);
25
26 const i32a = new Int32Array(
27 new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
28 );
29
30 $262.agent.safeBroadcast(i32a);
31 $262.agent.waitUntil(i32a, RUNNING, 1);
32
33 // Try to yield control to ensure the agent actually started to wait.
34 $262.agent.tryYield();
35
36 assert.sameValue(Atomics.notify(i32a, 0, NaN), 0, 'Atomics.notify(i32a, 0, NaN) returns 0');
37
38 // Try to sleep past the timeout.
39 $262.agent.trySleep(TIMEOUT);
40
41 assert.sameValue($262.agent.getReport(), 'timed-out', '$262.agent.getReport() returns "timed-out"');
42
43 reportCompare(0, 0);