Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Atomics/wake/good-views.js

raw
1 // Copyright (C) 2017 Mozilla Corporation. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-atomics.wake
6 description: >
7 Test Atomics.wait on arrays that allow atomic operations,
8 in an Agent that is allowed to wait. There is only the one Agent.
9 includes: [testAtomics.js]
10 features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
11 ---*/
12
13 var sab = new SharedArrayBuffer(1024);
14 var ab = new ArrayBuffer(16);
15 var int_views = [Int32Array];
16 var view = new Int32Array(sab, 32, 20);
17
18 view[0] = 0;
19 assert.sameValue(Atomics.wake(view, 0, 1), 0);
20
21 // In-bounds boundary cases for indexing
22 testWithAtomicsInBoundsIndices(function(IdxGen) {
23 let Idx = IdxGen(view);
24 view.fill(0);
25 // Atomics.store() computes an index from Idx in the same way as other
26 // Atomics operations, not quite like view[Idx].
27 Atomics.store(view, Idx, 37);
28 assert.sameValue(Atomics.wake(view, Idx, 1), 0);
29 });