Backed out 2 changesets (bug 1900622) for causing Bug 1908553 and ktlint failure...
[gecko.git] / js / src / tests / test262 / built-ins / Atomics / and / expected-return-value.js
blob29605ae3f2a2ceeaf5f0d8e93cb6523ec0f0cb95
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.
5 /*---
6 esid: sec-atomics.and
7 description: >
8   Atomics.and returns the value that existed at the
9   index prior to the operation.
10 info: |
11   Atomics.and( typedArray, index, value )
13   1. Return ? AtomicReadModifyWrite(typedArray, index, value, and).
15   AtomicReadModifyWrite( typedArray, index, value, op )
17   ...
18   9. Return GetModifySetValueInBuffer(buffer, indexedPosition,
19                                       elementType, v, op).
22   GetModifySetValueInBuffer( arrayBuffer,
23     byteIndex, type, value, op [ , isLittleEndian ] )
25   ...
26   16. Return RawBytesToNumber(type, rawBytesRead, isLittleEndian).
28 features: [Atomics, SharedArrayBuffer, TypedArray]
29 ---*/
31 const i32a = new Int32Array(
32   new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
34 const a = 0b00000001000000001000000010000001;
35 const b = 0b00000001111111111000000011111111;
36 const c = 0b00000001000000001000000010000001;
38 i32a[0] = a;
40 assert.sameValue(
41   Atomics.and(i32a, 0, b),
42   a,
43   'Atomics.and(i32a, 0, b) returns the value of `a` (0b00000001000000001000000010000001)'
46 assert.sameValue(i32a[0], c, 'The value of i32a[0] equals the value of `c` (0b00000001000000001000000010000001)');
48 reportCompare(0, 0);