forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RAB: Integrate staging tests for the .every method
of Array.prototype and TypedArray.prototype This is part of PR tc39#3888 to make reviewing easier. Includes changes to use the helper ./harness/resizableArrayBufferUtils.js
- Loading branch information
Showing
4 changed files
with
321 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
test/built-ins/Array/prototype/every/resizable-buffer-grow-mid-iteration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright 2023 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-array.prototype.every | ||
description: > | ||
Array.p.every behaves correctly when receiver is backed by resizable | ||
buffer that is grown mid-iteration | ||
includes: [compareArray.js] | ||
features: [resizable-arraybuffer] | ||
---*/ | ||
|
||
const ArrayEveryHelper = (ta, values, rab, resizeAfter, resizeTo) => { | ||
return Array.prototype.every.call( | ||
ta, | ||
(n) => CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo)); | ||
}; | ||
|
||
function EveryGrowMidIteration() { | ||
// Orig. array: [0, 2, 4, 6] | ||
// [0, 2, 4, 6] << fixedLength | ||
// [4, 6] << fixedLengthWithOffset | ||
// [0, 2, 4, 6, ...] << lengthTracking | ||
// [4, 6, ...] << lengthTrackingWithOffset | ||
let values; | ||
let rab; | ||
let resizeAfter; | ||
let resizeTo; | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const fixedLength = new ctor(rab, 0, 4); | ||
values = []; | ||
resizeAfter = 2; | ||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; | ||
assert(ArrayEveryHelper(fixedLength, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
0, | ||
2, | ||
4, | ||
6 | ||
]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); | ||
values = []; | ||
resizeAfter = 1; | ||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; | ||
assert(ArrayEveryHelper(fixedLengthWithOffset, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
4, | ||
6 | ||
]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const lengthTracking = new ctor(rab, 0); | ||
values = []; | ||
resizeAfter = 2; | ||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; | ||
assert(ArrayEveryHelper(lengthTracking, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
0, | ||
2, | ||
4, | ||
6 | ||
]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); | ||
values = []; | ||
resizeAfter = 1; | ||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; | ||
assert(ArrayEveryHelper(lengthTrackingWithOffset, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
4, | ||
6 | ||
]); | ||
} | ||
} | ||
|
||
EveryGrowMidIteration(); |
74 changes: 74 additions & 0 deletions
74
test/built-ins/Array/prototype/every/resizable-buffer-shrink-mid-iteration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2023 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-array.prototype.every | ||
description: > | ||
Array.p.every behaves correctly when receiver is backed by resizable | ||
buffer that is shrunk mid-iteration | ||
includes: [compareArray.js] | ||
features: [resizable-arraybuffer] | ||
---*/ | ||
|
||
const ArrayEveryHelper = (ta, values, rab, resizeAfter, resizeTo) => { | ||
return Array.prototype.every.call( | ||
ta, | ||
(n) => CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo)); | ||
}; | ||
|
||
function EveryShrinkMidIteration() { | ||
// Orig. array: [0, 2, 4, 6] | ||
// [0, 2, 4, 6] << fixedLength | ||
// [4, 6] << fixedLengthWithOffset | ||
// [0, 2, 4, 6, ...] << lengthTracking | ||
// [4, 6, ...] << lengthTrackingWithOffset | ||
let values; | ||
let rab; | ||
let resizeAfter; | ||
let resizeTo; | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const fixedLength = new ctor(rab, 0, 4); | ||
values = []; | ||
resizeAfter = 2; | ||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT; | ||
assert(ArrayEveryHelper(fixedLength, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
0, | ||
2 | ||
]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); | ||
values = []; | ||
resizeAfter = 1; | ||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT; | ||
assert(ArrayEveryHelper(fixedLengthWithOffset, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [4]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const lengthTracking = new ctor(rab, 0); | ||
values = []; | ||
resizeAfter = 2; | ||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT; | ||
assert(ArrayEveryHelper(lengthTracking, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
0, | ||
2, | ||
4 | ||
]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); | ||
values = []; | ||
resizeAfter = 1; | ||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT; | ||
assert(ArrayEveryHelper(lengthTrackingWithOffset, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [4]); | ||
} | ||
} | ||
|
||
EveryShrinkMidIteration(); |
82 changes: 82 additions & 0 deletions
82
test/built-ins/TypedArray/prototype/every/resizable-buffer-grow-mid-iteration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright 2023 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-%typedarray%.prototype.every | ||
description: > | ||
TypedArray.p.every behaves correctly when receiver is backed by resizable | ||
buffer that is grown mid-iteration | ||
includes: [compareArray.js] | ||
features: [resizable-arraybuffer] | ||
---*/ | ||
|
||
const TypedArrayEveryHelper = (ta, values, rab, resizeAfter, resizeTo) => { | ||
return ta.every( | ||
(n) => CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo)); | ||
}; | ||
|
||
function EveryGrowMidIteration() { | ||
// Orig. array: [0, 2, 4, 6] | ||
// [0, 2, 4, 6] << fixedLength | ||
// [4, 6] << fixedLengthWithOffset | ||
// [0, 2, 4, 6, ...] << lengthTracking | ||
// [4, 6, ...] << lengthTrackingWithOffset | ||
let values; | ||
let rab; | ||
let resizeAfter; | ||
let resizeTo; | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const fixedLength = new ctor(rab, 0, 4); | ||
values = []; | ||
resizeAfter = 2; | ||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; | ||
assert(TypedArrayEveryHelper(fixedLength, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
0, | ||
2, | ||
4, | ||
6 | ||
]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); | ||
values = []; | ||
resizeAfter = 1; | ||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; | ||
assert(TypedArrayEveryHelper(fixedLengthWithOffset, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
4, | ||
6 | ||
]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const lengthTracking = new ctor(rab, 0); | ||
values = []; | ||
resizeAfter = 2; | ||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; | ||
assert(TypedArrayEveryHelper(lengthTracking, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
0, | ||
2, | ||
4, | ||
6 | ||
]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); | ||
values = []; | ||
resizeAfter = 1; | ||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; | ||
assert(TypedArrayEveryHelper(lengthTrackingWithOffset, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
4, | ||
6 | ||
]); | ||
} | ||
} | ||
|
||
EveryGrowMidIteration(); |
82 changes: 82 additions & 0 deletions
82
test/built-ins/TypedArray/prototype/every/resizable-buffer-shrink-mid-iteration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright 2023 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-%typedarray%.prototype.every | ||
description: > | ||
TypedArray.p.every behaves correctly when receiver is backed by resizable | ||
buffer that is shrunk mid-iteration | ||
includes: [compareArray.js] | ||
features: [resizable-arraybuffer] | ||
---*/ | ||
|
||
const TypedArrayEveryHelper = (ta, values, rab, resizeAfter, resizeTo) => { | ||
return ta.every( | ||
(n) => CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo)); | ||
}; | ||
|
||
function EveryShrinkMidIteration() { | ||
// Orig. array: [0, 2, 4, 6] | ||
// [0, 2, 4, 6] << fixedLength | ||
// [4, 6] << fixedLengthWithOffset | ||
// [0, 2, 4, 6, ...] << lengthTracking | ||
// [4, 6, ...] << lengthTrackingWithOffset | ||
let values; | ||
let rab; | ||
let resizeAfter; | ||
let resizeTo; | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const fixedLength = new ctor(rab, 0, 4); | ||
values = []; | ||
resizeAfter = 2; | ||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT; | ||
assert(TypedArrayEveryHelper(fixedLength, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
0, | ||
2, | ||
undefined, | ||
undefined | ||
]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); | ||
values = []; | ||
resizeAfter = 1; | ||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT; | ||
assert(TypedArrayEveryHelper(fixedLengthWithOffset, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
4, | ||
undefined | ||
]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const lengthTracking = new ctor(rab, 0); | ||
values = []; | ||
resizeAfter = 2; | ||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT; | ||
assert(TypedArrayEveryHelper(lengthTracking, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
0, | ||
2, | ||
4, | ||
undefined | ||
]); | ||
} | ||
for (let ctor of ctors) { | ||
rab = CreateRabForTest(ctor); | ||
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); | ||
values = []; | ||
resizeAfter = 1; | ||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT; | ||
assert(TypedArrayEveryHelper(lengthTrackingWithOffset, values, rab, resizeAfter, resizeTo)); | ||
assert.compareArray(values, [ | ||
4, | ||
undefined | ||
]); | ||
} | ||
} | ||
|
||
EveryShrinkMidIteration(); |