Skip to content

Commit 94c4b3d

Browse files
committed
Increase TypedArray/ArrayBuffer coverage for Atomics
1 parent 6afaaa0 commit 94c4b3d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+134
-134
lines changed

harness/testTypedArray.js

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -322,26 +322,46 @@ var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Ui
322322
*
323323
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
324324
* @param {Array} selected - An optional Array with filtered typed arrays
325+
* @param {typedArrayArgFactoryFeature[]} [includeArgFactories] - for selecting
326+
* initial constructor argument factory functions, rather than starting with
327+
* all argument factories
328+
* @param {typedArrayArgFactoryFeature[]} [excludeArgFactories] - for excluding
329+
* constructor argument factory functions, after an initial selection
325330
*/
326-
function testWithNonAtomicsFriendlyTypedArrayConstructors(f) {
327-
testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors);
331+
function testWithNonAtomicsFriendlyTypedArrayConstructors(f, includeArgFactories, excludeArgFactories) {
332+
testWithAllTypedArrayConstructors(
333+
f,
334+
nonAtomicsFriendlyTypedArrayConstructors,
335+
includeArgFactories,
336+
excludeArgFactories
337+
);
328338
}
329339

330340
/**
331341
* Calls the provided function for every "Atomics Friendly" typed array constructor.
332342
*
333343
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
334344
* @param {Array} selected - An optional Array with filtered typed arrays
345+
* @param {typedArrayArgFactoryFeature[]} [includeArgFactories] - for selecting
346+
* initial constructor argument factory functions, rather than starting with
347+
* all argument factories
348+
* @param {typedArrayArgFactoryFeature[]} [excludeArgFactories] - for excluding
349+
* constructor argument factory functions, after an initial selection
335350
*/
336-
function testWithAtomicsFriendlyTypedArrayConstructors(f) {
337-
testWithTypedArrayConstructors(f, [
338-
Int32Array,
339-
Int16Array,
340-
Int8Array,
341-
Uint32Array,
342-
Uint16Array,
343-
Uint8Array,
344-
]);
351+
function testWithAtomicsFriendlyTypedArrayConstructors(f, includeArgFactories, excludeArgFactories) {
352+
testWithAllTypedArrayConstructors(
353+
f,
354+
[
355+
Int32Array,
356+
Int16Array,
357+
Int8Array,
358+
Uint32Array,
359+
Uint16Array,
360+
Uint8Array,
361+
],
362+
includeArgFactories,
363+
excludeArgFactories
364+
);
345365
}
346366

347367
/**
@@ -368,7 +388,7 @@ function testTypedArrayConversions(byteConversionValues, fn) {
368388
}
369389
fn(TA, value, exp, initial);
370390
});
371-
});
391+
}, null, ["passthrough"]);
372392
}
373393

374394
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ testWithTypedArrayConstructors(function(TA) {
1919
Atomics.add(view, IdxGen(view), 10);
2020
});
2121
});
22-
}, views);
22+
}, views, ["passthrough"]);

test/built-ins/Atomics/add/bigint/non-shared-bufferdata.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ description: >
77
includes: [testTypedArray.js]
88
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
99
---*/
10-
testWithBigIntTypedArrayConstructors(TA => {
11-
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
10+
testWithBigIntTypedArrayConstructors((TA, makeCtorArg) => {
11+
const buffer = makeCtorArg(4);
1212
const view = new TA(buffer);
1313
assert.sameValue(Atomics.add(view, 0, 1n), 0n, 'Atomics.add(view, 0, 1n) returns 0n');
1414
assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n');
15-
}, null, ["passthrough"]);
15+
}, null, ["arraybuffer"], ["immutable"]);

test/built-ins/Atomics/add/good-views.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ testWithTypedArrayConstructors(function(TA) {
5151
Atomics.store(view, Idx, 37);
5252
assert.sameValue(Atomics.add(view, Idx, 0), 37, 'Atomics.add(view, Idx, 0) returns 37');
5353
});
54-
}, views);
54+
}, views, ["passthrough"]);

test/built-ins/Atomics/add/non-shared-bufferdata.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ description: >
88
includes: [testTypedArray.js]
99
features: [ArrayBuffer, Atomics, TypedArray]
1010
---*/
11-
testWithAtomicsFriendlyTypedArrayConstructors(TA => {
12-
const view = new TA(
13-
new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4)
14-
);
11+
testWithAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => {
12+
const view = new TA(makeCtorArg(4));
1513

1614
assert.sameValue(Atomics.add(view, 0, 1), 0, 'Atomics.add(view, 0, 1) returns 0');
1715
assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1');
18-
}, null, ["passthrough"]);
16+
}, ["arraybuffer"], ["immutable"]);

test/built-ins/Atomics/add/non-shared-int-views-throws.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ description: >
88
includes: [testTypedArray.js]
99
features: [ArrayBuffer, Atomics, TypedArray]
1010
---*/
11-
testWithNonAtomicsFriendlyTypedArrayConstructors(TA => {
12-
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
11+
testWithNonAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => {
12+
const buffer = makeCtorArg(4);
1313
const view = new TA(buffer);
1414

1515
assert.throws(TypeError, function() {
1616
Atomics.add(view, 0, 1);
1717
}, `Atomics.add(new ${TA.name}(buffer), 0, 1) throws TypeError`);
18-
}, null, ["passthrough"]);
18+
}, ["arraybuffer"]);

test/built-ins/Atomics/and/bad-range.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ testWithTypedArrayConstructors(function(TA) {
1919
Atomics.and(view, IdxGen(view), 10);
2020
});
2121
});
22-
}, views);
22+
}, views, ["passthrough"]);

test/built-ins/Atomics/and/bigint/non-shared-bufferdata.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ description: >
77
includes: [testTypedArray.js]
88
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
99
---*/
10-
testWithBigIntTypedArrayConstructors(TA => {
11-
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
10+
testWithBigIntTypedArrayConstructors((TA, makeCtorArg) => {
11+
const buffer = makeCtorArg(4);
1212
const view = new TA(buffer);
1313
assert.sameValue(Atomics.and(view, 0, 1n), 0n, 'Atomics.and(view, 0, 1n) returns 0n');
1414
assert.sameValue(Atomics.load(view, 0), 0n, 'Atomics.load(view, 0) returns 0n');
15-
}, null, ["passthrough"]);
15+
}, null, ["arraybuffer"], ["immutable"]);

test/built-ins/Atomics/and/good-views.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ testWithTypedArrayConstructors(function(TA) {
6666
Atomics.store(view, Idx, 37);
6767
assert.sameValue(Atomics.and(view, Idx, 0), 37, 'Atomics.and(view, Idx, 0) returns 37');
6868
});
69-
}, views);
69+
}, views, ["passthrough"]);

test/built-ins/Atomics/and/non-shared-bufferdata.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ description: >
88
includes: [testTypedArray.js]
99
features: [ArrayBuffer, Atomics, TypedArray]
1010
---*/
11-
testWithAtomicsFriendlyTypedArrayConstructors(TA => {
12-
const view = new TA(
13-
new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4)
14-
);
11+
testWithAtomicsFriendlyTypedArrayConstructors((TA, makeCtorArg) => {
12+
const view = new TA(makeCtorArg(4));
1513

1614
assert.sameValue(Atomics.and(view, 0, 1), 0, 'Atomics.and(view, 0, 1) returns 0');
1715
assert.sameValue(Atomics.load(view, 0), 0, 'Atomics.load(view, 0) returns 0');
18-
}, null, ["passthrough"]);
16+
}, ["arraybuffer"], ["immutable"]);

0 commit comments

Comments
 (0)