Skip to content

Commit de8c4b8

Browse files
committed
Clean up tests broken by use of the TypedArray constructor argument factory
1 parent b6f110f commit de8c4b8

File tree

8 files changed

+33
-33
lines changed

8 files changed

+33
-33
lines changed

test/built-ins/TypedArray/prototype/copyWithin/bit-precision.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ includes: [nans.js, compareArray.js, testTypedArray.js]
1616
features: [TypedArray]
1717
---*/
1818

19-
function body(FloatArray) {
19+
testWithTypedArrayConstructors(function body(FloatArray) {
2020
var subject = new FloatArray(NaNs.length * 2);
2121

2222
NaNs.forEach(function(v, i) {
@@ -39,6 +39,4 @@ function body(FloatArray) {
3939
);
4040

4141
assert(compareArray(originalBytes, copiedBytes));
42-
}
43-
44-
testWithTypedArrayConstructors((body), floatArrayConstructors);
42+
}, floatArrayConstructors);

test/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ includes: [nans.js, testTypedArray.js, compareArray.js]
5353
features: [TypedArray]
5454
---*/
5555

56-
function body(FloatArray) {
56+
testWithTypedArrayConstructors(function body(FloatArray) {
5757
var sample = new FloatArray(NaNs);
5858
var sampleBytes, resultBytes;
5959
var i = 0;
@@ -66,6 +66,4 @@ function body(FloatArray) {
6666
resultBytes = new Uint8Array(result.buffer);
6767

6868
assert(compareArray(sampleBytes, resultBytes));
69-
}
70-
71-
testWithTypedArrayConstructors((body), floatArrayConstructors);
69+
}, floatArrayConstructors);

test/built-ins/TypedArray/prototype/set/bit-precision.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ includes: [nans.js, compareArray.js, testTypedArray.js]
1919
features: [TypedArray]
2020
---*/
2121

22-
function body(FA) {
22+
testWithTypedArrayConstructors(function body(FA) {
2323
var source = new FA(NaNs);
2424
var target = new FA(NaNs.length);
2525
var sourceBytes, targetBytes;
@@ -30,6 +30,4 @@ function body(FA) {
3030
targetBytes = new Uint8Array(target.buffer);
3131

3232
assert(compareArray(sourceBytes, targetBytes))
33-
}
34-
35-
testWithTypedArrayConstructors((body), floatArrayConstructors);
33+
}, floatArrayConstructors);

test/built-ins/TypedArray/prototype/slice/bit-precision.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ includes: [nans.js, compareArray.js, testTypedArray.js]
2424
features: [TypedArray]
2525
---*/
2626

27-
function body(FloatArray) {
27+
testWithTypedArrayConstructors(function body(FloatArray) {
2828
var subject = new FloatArray(NaNs);
2929
var sliced, subjectBytes, slicedBytes;
3030

@@ -34,6 +34,4 @@ function body(FloatArray) {
3434
slicedBytes = new Uint8Array(sliced.buffer);
3535

3636
assert(compareArray(subjectBytes, slicedBytes));
37-
}
38-
39-
testWithTypedArrayConstructors((body), floatArrayConstructors);
37+
}, floatArrayConstructors);

test/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ info: |
88
22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
99
1010
...
11+
15. If O.[[ArrayLength]] is auto and end is undefined, then
12+
a. Let argumentsList be « buffer, 𝔽(beginByteOffset) ».
13+
16. Else,
14+
...
15+
f. Let argumentsList be « buffer, 𝔽(beginByteOffset), 𝔽(newLength) ».
1116
17. Return ? TypedArraySpeciesCreate(O, argumentsList).
1217
1318
22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
@@ -31,7 +36,7 @@ info: |
3136
3. If argumentList is a List of a single Number, then
3237
...
3338
4. Return newTypedArray.
34-
includes: [testTypedArray.js]
39+
includes: [compareArray.js, testTypedArray.js]
3540
features: [BigInt, Symbol.species, TypedArray]
3641
---*/
3742

@@ -49,10 +54,10 @@ testWithBigIntTypedArrayConstructors(function(TA, makeCtorArg) {
4954

5055
sample.subarray(1);
5156

52-
assert.sameValue(result.length, 3, "called with 3 arguments");
53-
assert.sameValue(result[0], sample.buffer, "[0] is sample.buffer");
54-
assert.sameValue(result[1], expectedOffset, "[1] is the byte offset pos");
55-
assert.sameValue(result[2], 2, "[2] is expected length");
57+
var expectArgs = sample.buffer.resizable
58+
? [sample.buffer, expectedOffset]
59+
: [sample.buffer, expectedOffset, 2];
60+
assert.compareArray(result, expectArgs, "Constructor called with arguments");
5661

5762
assert(
5863
ctorThis instanceof sample.constructor[Symbol.species],

test/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ info: |
88
22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
99
1010
...
11+
15. If O.[[ArrayLength]] is auto and end is undefined, then
12+
a. Let argumentsList be « buffer, 𝔽(beginByteOffset) ».
13+
16. Else,
14+
...
15+
f. Let argumentsList be « buffer, 𝔽(beginByteOffset), 𝔽(newLength) ».
1116
17. Return ? TypedArraySpeciesCreate(O, argumentsList).
1217
1318
22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
@@ -31,7 +36,7 @@ info: |
3136
3. If argumentList is a List of a single Number, then
3237
...
3338
4. Return newTypedArray.
34-
includes: [testTypedArray.js]
39+
includes: [compareArray.js, testTypedArray.js]
3540
features: [Symbol.species, TypedArray]
3641
---*/
3742

@@ -49,10 +54,10 @@ testWithTypedArrayConstructors(function(TA, makeCtorArg) {
4954

5055
sample.subarray(1);
5156

52-
assert.sameValue(result.length, 3, "called with 3 arguments");
53-
assert.sameValue(result[0], sample.buffer, "[0] is sample.buffer");
54-
assert.sameValue(result[1], expectedOffset, "[1] is the byte offset pos");
55-
assert.sameValue(result[2], 2, "[2] is expected length");
57+
var expectArgs = sample.buffer.resizable
58+
? [sample.buffer, expectedOffset]
59+
: [sample.buffer, expectedOffset, 2];
60+
assert.compareArray(result, expectArgs, "Constructor called with arguments");
5661

5762
assert(
5863
ctorThis instanceof sample.constructor[Symbol.species],

test/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation-consistent-nan.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,11 @@ includes: [nans.js, testTypedArray.js, compareArray.js]
5858
features: [TypedArray]
5959
---*/
6060

61-
function body(FloatArray) {
61+
testWithTypedArrayConstructors(function body(FloatArray) {
6262
var first = new FloatArray(NaNs);
6363
var second = new FloatArray(NaNs);
6464
var firstBytes = new Uint8Array(first.buffer);
6565
var secondBytes = new Uint8Array(second.buffer);
6666

6767
assert(compareArray(firstBytes, secondBytes));
68-
}
69-
70-
testWithTypedArrayConstructors((body), floatArrayConstructors);
68+
}, floatArrayConstructors);

test/built-ins/TypedArrayConstructors/ctors/object-arg/iterated-array-with-modified-array-iterator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ ArrayIteratorPrototype.next = function() {
3434
return {value, done};
3535
};
3636

37-
testWithTypedArrayConstructors(function(TypedArray, makeCtorArg) {
37+
testWithTypedArrayConstructors(function(TypedArray) {
3838
// Reset `values` array.
3939
values = [1, 2, 3, 4];
4040

4141
// Constructor called with array which uses the modified array iterator.
42-
var ta = new TypedArray(makeCtorArg([0]));
42+
var ta = new TypedArray([0]);
4343

4444
assert.sameValue(ta.length, 4);
4545
assert.sameValue(ta[0], 4);
4646
assert.sameValue(ta[1], 3);
4747
assert.sameValue(ta[2], 2);
4848
assert.sameValue(ta[3], 1);
49-
});
49+
}, null, ["passthrough"]);

0 commit comments

Comments
 (0)