Debian Codegraph @

js/src/tests/test262/built-ins/Atomics/load/bigint/good-views.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 esid: sec-atomics.load
6 description: Test Atomics.load on arrays that allow atomic operations.
7 includes: [testAtomics.js, testBigIntTypedArray.js]
8 features: [ArrayBuffer, Atomics, BigInt, DataView, SharedArrayBuffer, Symbol, TypedArray]
9 ---*/
10 const sab = new SharedArrayBuffer(1024);
11 const ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
12
13 testWithBigIntTypedArrayConstructors(function(TA) {
14 const view = new TA(sab, 32, 20);
15 const control = new TA(ab, 0, 2);
16 view[3] = -5n;
17 control[0] = -5n;
18
19 assert.sameValue(
20 Atomics.load(view, 3),
21 control[0],
22 'Atomics.load(view, 3) returns the value of `control[0]` (-5n)'
23 );
24
25 control[0] = 12345n;
26 view[3] = 12345n;
27
28 assert.sameValue(
29 Atomics.load(view, 3),
30 control[0],
31 'Atomics.load(view, 3) returns the value of `control[0]` (12345n)'
32 );
33
34 control[0] = 123456789n;
35 view[3] = 123456789n;
36
37 assert.sameValue(
38 Atomics.load(view, 3),
39 control[0],
40 'Atomics.load(view, 3) returns the value of `control[0]` (123456789n)'
41 );
42
43 testWithAtomicsInBoundsIndices(function(IdxGen) {
44 let Idx = IdxGen(view);
45 view.fill(0n);
46 Atomics.store(view, Idx, 37n);
47 assert.sameValue(Atomics.load(view, Idx), 37n, 'Atomics.load(view, Idx) returns 37n');
48 });
49 });
50
51 reportCompare(0, 0);