Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/wait/wait-index-value-not-equal.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 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 Returns "not-equal" when value of index is not equal
9 info: |
10 Atomics.wait( typedArray, index, value, timeout )
11
12 14.If v is not equal to w, then
13 a.Perform LeaveCriticalSection(WL).
14 b. Return the String "not-equal".
15
16 includes: [atomicsHelper.js]
17 features: [Atomics, SharedArrayBuffer, TypedArray]
18 ---*/
19
20 const RUNNING = 1;
21 const TIMEOUT = $262.agent.timeouts.small;
22
23 $262.agent.start(`
24 $262.agent.receiveBroadcast(function(sab) {
25 const i32a = new Int32Array(sab);
26 Atomics.add(i32a, ${RUNNING}, 1);
27
28 $262.agent.report(Atomics.wait(i32a, 0, 44, ${TIMEOUT}));
29 $262.agent.report(Atomics.wait(i32a, 0, 251.4, ${TIMEOUT}));
30 $262.agent.leaving();
31 });
32 `);
33
34 const i32a = new Int32Array(
35 new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
36 );
37
38 // NB: We don't actually explicitly need to wait for the agent to start in this
39 // test case, we only do it for consistency with other test cases which do
40 // require the main agent to wait and yield control.
41
42 $262.agent.safeBroadcast(i32a);
43 $262.agent.waitUntil(i32a, RUNNING, 1);
44
45 // Try to yield control to ensure the agent actually started to wait.
46 $262.agent.tryYield();
47
48 assert.sameValue(
49 $262.agent.getReport(),
50 'not-equal',
51 '$262.agent.getReport() returns "not-equal"'
52 );
53 assert.sameValue(
54 $262.agent.getReport(),
55 'not-equal',
56 '$262.agent.getReport() returns "not-equal"'
57 );
58 assert.sameValue(Atomics.notify(i32a, 0), 0, 'Atomics.notify(i32a, 0) returns 0');
59
60 reportCompare(0, 0);