| 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.exchange |
| 6 |
description: > |
| 7 |
Test range checking of Atomics.exchange on arrays that allow atomic operations |
| 8 |
includes: [testAtomics.js, testTypedArray.js] |
| 9 |
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of] |
| 10 |
---*/ |
| 11 |
|
| 12 |
var sab = new SharedArrayBuffer(8); |
| 13 |
var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; |
| 14 |
|
| 15 |
if (typeof BigInt !== "undefined") { |
| 16 |
views.push(BigInt64Array); |
| 17 |
views.push(BigUint64Array); |
| 18 |
} |
| 19 |
|
| 20 |
testWithTypedArrayConstructors(function(View) { |
| 21 |
let view = new View(sab); |
| 22 |
testWithAtomicsOutOfBoundsIndices(function(IdxGen) { |
| 23 |
let Idx = IdxGen(view); |
| 24 |
assert.throws(RangeError, () => Atomics.exchange(view, Idx, 10, 0)); |
| 25 |
}); |
| 26 |
}, views); |