test262/test/built-ins/Atomics/add/bad-range.js

25 lines
796 B
JavaScript
Raw Normal View History

// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
2017-07-26 23:49:55 +02:00
esid: sec-atomics.add
description: >
Test range checking of Atomics.add on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [ArrayBuffer, arrow-function, Atomics, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/
2018-04-19 16:11:50 +02:00
var buffer = new SharedArrayBuffer(8);
var views = intArrayConstructors.slice();
2018-04-19 16:11:50 +02:00
testWithTypedArrayConstructors(function(TA) {
let view = new TA(buffer);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
2018-05-17 20:06:22 +02:00
assert.throws(
RangeError,
() => Atomics.add(view, IdxGen(view), 10),
'Atomics.add(view, IdxGen(view), 10) throws RangeError'
);
});
}, views);