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

26 lines
822 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.sub
description: >
Test range checking of Atomics.sub on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
2018-04-19 16:11:50 +02:00
features: [ArrayBuffer, arrow-function, Atomics, BigInt, DataView, for-of, let, SharedArrayBuffer, TypedArray]
---*/
2018-04-19 16:11:50 +02:00
var buffer = new SharedArrayBuffer(8);
var views = intArrayConstructors.slice();
2018-01-23 02:40:35 +01:00
if (typeof BigInt !== "undefined") {
views.push(BigInt64Array);
views.push(BigUint64Array);
}
2018-04-19 16:11:50 +02:00
testWithTypedArrayConstructors(function(TA) {
let view = new TA(buffer);
testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
2018-04-19 16:11:50 +02:00
assert.throws(RangeError, () => Atomics.sub(view, IdxGen(view), 10));
});
}, views);