mirror of https://github.com/tc39/test262.git
Atomics.load will operate on TA when TA.buffer is not a SharedArrayBuffer
This commit is contained in:
parent
302f37eeff
commit
11a1eabcc6
|
@ -3,7 +3,10 @@
|
||||||
/*---
|
/*---
|
||||||
description: |
|
description: |
|
||||||
Collection of functions used to assert the correctness of BigInt TypedArray objects.
|
Collection of functions used to assert the correctness of BigInt TypedArray objects.
|
||||||
defines: [TypedArray, testWithBigIntTypedArrayConstructors]
|
defines:
|
||||||
|
- TypedArray
|
||||||
|
- testWithBigIntTypedArrayConstructors
|
||||||
|
- testWithNonShareableBigIntTypedArrayConstructors
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,12 +18,13 @@ var TypedArray = Object.getPrototypeOf(Int8Array);
|
||||||
* Calls the provided function for every typed array constructor.
|
* Calls the provided function for every typed array constructor.
|
||||||
*
|
*
|
||||||
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
|
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
|
||||||
|
* @param {Array} selected - An optional Array with filtered typed arrays
|
||||||
*/
|
*/
|
||||||
function testWithBigIntTypedArrayConstructors(f) {
|
function testWithBigIntTypedArrayConstructors(f, selected) {
|
||||||
/**
|
/**
|
||||||
* Array containing every BigInt typed array constructor.
|
* Array containing every BigInt typed array constructor.
|
||||||
*/
|
*/
|
||||||
var constructors = [
|
var constructors = selected || [
|
||||||
BigInt64Array,
|
BigInt64Array,
|
||||||
BigUint64Array
|
BigUint64Array
|
||||||
];
|
];
|
||||||
|
@ -35,3 +39,12 @@ function testWithBigIntTypedArrayConstructors(f) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the provided function for every NON SHARABLE bigint typed array constructor.
|
||||||
|
*
|
||||||
|
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
|
||||||
|
*/
|
||||||
|
function testWithNonShareableBigIntTypedArrayConstructors(f) {
|
||||||
|
testWithBigIntTypedArrayConstructors(f, [BigUint64Array]);
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ defines:
|
||||||
- intArrayConstructors
|
- intArrayConstructors
|
||||||
- TypedArray
|
- TypedArray
|
||||||
- testWithTypedArrayConstructors
|
- testWithTypedArrayConstructors
|
||||||
|
- testWithNonSharableTypedArrayConstructors
|
||||||
- testTypedArrayConversions
|
- testTypedArrayConversions
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -61,6 +62,25 @@ function testWithTypedArrayConstructors(f, selected) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the provided function for every NON SHARABLE typed array constructor.
|
||||||
|
*
|
||||||
|
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
|
||||||
|
* @param {Array} selected - An optional Array with filtered typed arrays
|
||||||
|
*/
|
||||||
|
function testWithNonSharableTypedArrayConstructors(f) {
|
||||||
|
testWithTypedArrayConstructors(f, [
|
||||||
|
Float64Array,
|
||||||
|
Float32Array,
|
||||||
|
Int16Array,
|
||||||
|
Int8Array,
|
||||||
|
Uint32Array,
|
||||||
|
Uint16Array,
|
||||||
|
Uint8Array,
|
||||||
|
Uint8ClampedArray
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for conversion operations on TypedArrays, the expected values
|
* Helper for conversion operations on TypedArrays, the expected values
|
||||||
* properties are indexed in order to match the respective value for each
|
* properties are indexed in order to match the respective value for each
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.load
|
||||||
|
description: >
|
||||||
|
Atomics.load will operate on TA when TA.buffer is not a SharedArrayBuffer
|
||||||
|
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const i64a = new BigInt64Array(
|
||||||
|
new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.load(i64a, 0), 0n);
|
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.load
|
||||||
|
description: >
|
||||||
|
Atomics.load throws when operating on non-sharable integer TypedArrays
|
||||||
|
includes: [testBigIntTypedArray.js]
|
||||||
|
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4);
|
||||||
|
|
||||||
|
testWithNonShareableBigIntTypedArrayConstructors(function(TA) {
|
||||||
|
const view = new TA(buffer);
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Atomics.load(view, 0);
|
||||||
|
}, `Atomics.load(new ${TA.name}(view), 0) throws TypeError`);
|
||||||
|
});
|
|
@ -1,21 +0,0 @@
|
||||||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-atomics.load
|
|
||||||
description: >
|
|
||||||
Test Atomics.load on non-shared integer TypedArrays
|
|
||||||
includes: [testBigIntTypedArray.js]
|
|
||||||
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
|
|
||||||
|
|
||||||
|
|
||||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
|
||||||
var view = new TA(ab);
|
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Atomics.load(view, 0);
|
|
||||||
}, '`Atomics.load(view, 0)` throws TypeError');
|
|
||||||
});
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-atomics.load
|
||||||
|
description: >
|
||||||
|
Atomics.load will operate on TA when TA.buffer is not a SharedArrayBuffer
|
||||||
|
features: [ArrayBuffer, Atomics, TypedArray]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const i32a = new Int32Array(
|
||||||
|
new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(Atomics.load(i32a, 0), 0);
|
|
@ -4,18 +4,16 @@
|
||||||
/*---
|
/*---
|
||||||
esid: sec-atomics.load
|
esid: sec-atomics.load
|
||||||
description: >
|
description: >
|
||||||
Test Atomics.load on non-shared integer TypedArrays
|
Atomics.load throws when operating on non-sharable integer TypedArrays
|
||||||
includes: [testTypedArray.js]
|
includes: [testTypedArray.js]
|
||||||
features: [ArrayBuffer, Atomics, TypedArray]
|
features: [ArrayBuffer, Atomics, TypedArray]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const buffer = new ArrayBuffer(16);
|
const buffer = new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4);
|
||||||
const views = intArrayConstructors.slice();
|
|
||||||
|
|
||||||
testWithTypedArrayConstructors(function(TA) {
|
testWithNonSharableTypedArrayConstructors(function(TA) {
|
||||||
const view = new TA(buffer);
|
const view = new TA(buffer);
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Atomics.load(view, 0);
|
Atomics.load(view, 0);
|
||||||
}, '`Atomics.load(view, 0)` throws TypeError');
|
}, `Atomics.load(new ${TA.name}(view), 0) throws TypeError`);
|
||||||
}, views);
|
});
|
Loading…
Reference in New Issue