2018-04-25 23:29:53 +02:00
|
|
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
|
|
esid: sec-atomics.exchange
|
|
|
|
description: >
|
|
|
|
Test range checking of Atomics.exchange on arrays that allow atomic operations
|
|
|
|
includes: [testAtomics.js, testBigIntTypedArray.js]
|
|
|
|
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
|
|
|
|
---*/
|
2018-06-27 18:58:02 +02:00
|
|
|
var buffer = new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
2018-04-25 23:29:53 +02:00
|
|
|
|
|
|
|
testWithBigIntTypedArrayConstructors(function(TA) {
|
|
|
|
let view = new TA(buffer);
|
2018-06-27 18:58:02 +02:00
|
|
|
|
2018-04-25 23:29:53 +02:00
|
|
|
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
|
2018-05-18 21:00:10 +02:00
|
|
|
assert.throws(RangeError, function() {
|
2018-06-27 18:58:02 +02:00
|
|
|
Atomics.exchange(view, IdxGen(view), 10n, 0n);
|
|
|
|
}, '`Atomics.exchange(view, IdxGen(view), 10n, 0n)` throws RangeError');
|
2018-04-25 23:29:53 +02:00
|
|
|
});
|
2018-06-27 18:58:02 +02:00
|
|
|
});
|