Commit 07add521 authored by Marja Hölttä's avatar Marja Hölttä Committed by V8 LUCI CQ

[rab/gsab] Tests for Array.p methods, part 13

In this part: filter

Bug: v8:11111
Change-Id: I8ca08e94ad2ab56605e9a32ba52de426f8100da8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3758213Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81713}
parent f20e4e71
...@@ -1903,7 +1903,7 @@ function FindLastIndexGrowMidIteration(findLastIndexHelper) { ...@@ -1903,7 +1903,7 @@ function FindLastIndexGrowMidIteration(findLastIndexHelper) {
FindLastIndexGrowMidIteration(TypedArrayFindLastIndexHelper); FindLastIndexGrowMidIteration(TypedArrayFindLastIndexHelper);
FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
(function Filter() { function Filter(filterHelper) {
for (let ctor of ctors) { for (let ctor of ctors) {
const gsab = CreateGrowableSharedArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, const gsab = CreateGrowableSharedArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT); 8 * ctor.BYTES_PER_ELEMENT);
...@@ -1928,10 +1928,11 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -1928,10 +1928,11 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
return n != undefined && Number(n) % 2 == 0; return n != undefined && Number(n) % 2 == 0;
} }
assertEquals([0, 2], ToNumbers(fixedLength.filter(isEven))); assertEquals([0, 2], ToNumbers(filterHelper(fixedLength, isEven)));
assertEquals([2], ToNumbers(fixedLengthWithOffset.filter(isEven))); assertEquals([2], ToNumbers(filterHelper(fixedLengthWithOffset, isEven)));
assertEquals([0, 2], ToNumbers(lengthTracking.filter(isEven))); assertEquals([0, 2], ToNumbers(filterHelper(lengthTracking, isEven)));
assertEquals([2], ToNumbers(lengthTrackingWithOffset.filter(isEven))); assertEquals([2],
ToNumbers(filterHelper(lengthTrackingWithOffset, isEven)));
// Grow. // Grow.
gsab.grow(6 * ctor.BYTES_PER_ELEMENT); gsab.grow(6 * ctor.BYTES_PER_ELEMENT);
...@@ -1945,14 +1946,17 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -1945,14 +1946,17 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
// [0, 1, 2, 3, 4, 5, ...] << lengthTracking // [0, 1, 2, 3, 4, 5, ...] << lengthTracking
// [2, 3, 4, 5, ...] << lengthTrackingWithOffset // [2, 3, 4, 5, ...] << lengthTrackingWithOffset
assertEquals([0, 2], ToNumbers(fixedLength.filter(isEven))); assertEquals([0, 2], ToNumbers(filterHelper(fixedLength, isEven)));
assertEquals([2], ToNumbers(fixedLengthWithOffset.filter(isEven))); assertEquals([2], ToNumbers(filterHelper(fixedLengthWithOffset, isEven)));
assertEquals([0, 2, 4], ToNumbers(lengthTracking.filter(isEven))); assertEquals([0, 2, 4], ToNumbers(filterHelper(lengthTracking, isEven)));
assertEquals([2, 4], ToNumbers(lengthTrackingWithOffset.filter(isEven))); assertEquals([2, 4],
ToNumbers(filterHelper(lengthTrackingWithOffset, isEven)));
} }
})(); }
Filter(TypedArrayFilterHelper);
Filter(ArrayFilterHelper);
(function FilterGrowMidIteration() { function FilterGrowMidIteration(filterHelper) {
// Orig. array: [0, 2, 4, 6] // Orig. array: [0, 2, 4, 6]
// [0, 2, 4, 6] << fixedLength // [0, 2, 4, 6] << fixedLength
// [4, 6] << fixedLengthWithOffset // [4, 6] << fixedLengthWithOffset
...@@ -1991,7 +1995,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -1991,7 +1995,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
values = []; values = [];
growAfter = 2; growAfter = 2;
growTo = 5 * ctor.BYTES_PER_ELEMENT; growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertEquals([], ToNumbers(fixedLength.filter(CollectValuesAndGrow))); assertEquals([],
ToNumbers(filterHelper(fixedLength, CollectValuesAndGrow)));
assertEquals([0, 2, 4, 6], values); assertEquals([0, 2, 4, 6], values);
} }
...@@ -2001,7 +2006,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -2001,7 +2006,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
values = []; values = [];
growAfter = 1; growAfter = 1;
growTo = 5 * ctor.BYTES_PER_ELEMENT; growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertEquals([], ToNumbers(fixedLengthWithOffset.filter(CollectValuesAndGrow))); assertEquals([],
ToNumbers(filterHelper(fixedLengthWithOffset, CollectValuesAndGrow)));
assertEquals([4, 6], values); assertEquals([4, 6], values);
} }
...@@ -2011,7 +2017,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -2011,7 +2017,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
values = []; values = [];
growAfter = 2; growAfter = 2;
growTo = 5 * ctor.BYTES_PER_ELEMENT; growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertEquals([], ToNumbers(lengthTracking.filter(CollectValuesAndGrow))); assertEquals([],
ToNumbers(filterHelper(lengthTracking, CollectValuesAndGrow)));
assertEquals([0, 2, 4, 6], values); assertEquals([0, 2, 4, 6], values);
} }
...@@ -2021,10 +2028,13 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -2021,10 +2028,13 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
values = []; values = [];
growAfter = 1; growAfter = 1;
growTo = 5 * ctor.BYTES_PER_ELEMENT; growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertEquals([], ToNumbers(lengthTrackingWithOffset.filter(CollectValuesAndGrow))); assertEquals([],
ToNumbers(filterHelper(lengthTrackingWithOffset, CollectValuesAndGrow)));
assertEquals([4, 6], values); assertEquals([4, 6], values);
} }
})(); }
FilterGrowMidIteration(TypedArrayFilterHelper);
FilterGrowMidIteration(ArrayFilterHelper);
function ForEachReduceReduceRight( function ForEachReduceReduceRight(
forEachHelper, reduceHelper, reduceRightHelper) { forEachHelper, reduceHelper, reduceRightHelper) {
......
...@@ -476,3 +476,8 @@ const TypedArrayReduceRightHelper = (ta, ...rest) => { ...@@ -476,3 +476,8 @@ const TypedArrayReduceRightHelper = (ta, ...rest) => {
return ta.reduceRight(...rest); } return ta.reduceRight(...rest); }
const ArrayReduceRightHelper = (ta, ...rest) => { const ArrayReduceRightHelper = (ta, ...rest) => {
return Array.prototype.reduceRight.call(ta, ...rest); }; return Array.prototype.reduceRight.call(ta, ...rest); };
const TypedArrayFilterHelper = (ta, ...rest) => {
return ta.filter(...rest); }
const ArrayFilterHelper = (ta, ...rest) => {
return Array.prototype.filter.call(ta, ...rest); };
...@@ -1119,3 +1119,156 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js'); ...@@ -1119,3 +1119,156 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
assertEquals([6], ReduceRightHelper(lengthTrackingWithOffset)); assertEquals([6], ReduceRightHelper(lengthTrackingWithOffset));
} }
})(); })();
(function FilterShrinkMidIteration() {
const filterHelper = ArrayFilterHelper;
// Orig. array: [0, 2, 4, 6]
// [0, 2, 4, 6] << fixedLength
// [4, 6] << fixedLengthWithOffset
// [0, 2, 4, 6, ...] << lengthTracking
// [4, 6, ...] << lengthTrackingWithOffset
function CreateRabForTest(ctor) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT);
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
}
return rab;
}
let values;
let rab;
let resizeAfter;
let resizeTo;
function CollectValuesAndResize(n) {
if (typeof n == 'bigint') {
values.push(Number(n));
} else {
values.push(n);
}
if (values.length == resizeAfter) {
rab.resize(resizeTo);
}
return false;
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const fixedLength = new ctor(rab, 0, 4);
values = [];
resizeAfter = 2;
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
assertEquals([],
ToNumbers(filterHelper(fixedLength, CollectValuesAndResize)));
assertEquals([0, 2], values);
}
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;
assertEquals([],ToNumbers(filterHelper(
fixedLengthWithOffset, CollectValuesAndResize)));
assertEquals([4], values);
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const lengthTracking = new ctor(rab, 0);
values = [];
resizeAfter = 2;
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
assertEquals([], ToNumbers(filterHelper(
lengthTracking, CollectValuesAndResize)));
assertEquals([0, 2, 4], values);
}
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;
assertEquals([], ToNumbers(filterHelper(
lengthTrackingWithOffset, CollectValuesAndResize)));
assertEquals([4], values);
}
})();
(function FilterDetachMidIteration() {
const filterHelper = ArrayFilterHelper;
// Orig. array: [0, 2, 4, 6]
// [0, 2, 4, 6] << fixedLength
// [4, 6] << fixedLengthWithOffset
// [0, 2, 4, 6, ...] << lengthTracking
// [4, 6, ...] << lengthTrackingWithOffset
function CreateRabForTest(ctor) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT);
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
}
return rab;
}
let values;
let rab;
let detachAfter;
function CollectValuesAndDetach(n) {
if (n == undefined) {
values.push(n);
} else {
values.push(Number(n));
}
if (values.length == detachAfter) {
%ArrayBufferDetach(rab);
}
return false;
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const fixedLength = new ctor(rab, 0, 4);
values = [];
detachAfter = 2;
assertEquals([],
ToNumbers(filterHelper(fixedLength, CollectValuesAndDetach)));
assertEquals([0, 2], values);
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2);
values = [];
detachAfter = 1;
assertEquals([],
ToNumbers(filterHelper(fixedLengthWithOffset, CollectValuesAndDetach)));
assertEquals([4], values);
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const lengthTracking = new ctor(rab, 0);
values = [];
detachAfter = 2;
assertEquals([],
ToNumbers(filterHelper(lengthTracking, CollectValuesAndDetach)));
assertEquals([0, 2], values);
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT);
values = [];
detachAfter = 1;
assertEquals([],
ToNumbers(filterHelper(lengthTrackingWithOffset, CollectValuesAndDetach)));
assertEquals([4], values);
}
})();
...@@ -668,7 +668,9 @@ function FindLastIndexDetachMidIteration(findLastIndexHelper) { ...@@ -668,7 +668,9 @@ function FindLastIndexDetachMidIteration(findLastIndexHelper) {
FindLastIndexDetachMidIteration(TypedArrayFindLastIndexHelper); FindLastIndexDetachMidIteration(TypedArrayFindLastIndexHelper);
FindLastIndexDetachMidIteration(ArrayFindLastIndexHelper); FindLastIndexDetachMidIteration(ArrayFindLastIndexHelper);
(function FilterShrinkMidIteration() { // The corresponding tests for Array.prototype.filter are in
// typedarray-resizablearraybuffer-array-methods.js.
(function FilterDetachMidIteration() {
// Orig. array: [0, 2, 4, 6] // Orig. array: [0, 2, 4, 6]
// [0, 2, 4, 6] << fixedLength // [0, 2, 4, 6] << fixedLength
// [4, 6] << fixedLengthWithOffset // [4, 6] << fixedLengthWithOffset
......
...@@ -3649,7 +3649,7 @@ function FindLastIndexGrowMidIteration(findLastIndexHelper) { ...@@ -3649,7 +3649,7 @@ function FindLastIndexGrowMidIteration(findLastIndexHelper) {
FindLastIndexGrowMidIteration(TypedArrayFindLastIndexHelper); FindLastIndexGrowMidIteration(TypedArrayFindLastIndexHelper);
FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
(function Filter() { function Filter(filterHelper, oobThrows) {
for (let ctor of ctors) { for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT); 8 * ctor.BYTES_PER_ELEMENT);
...@@ -3674,10 +3674,11 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -3674,10 +3674,11 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
return n != undefined && Number(n) % 2 == 0; return n != undefined && Number(n) % 2 == 0;
} }
assertEquals([0, 2], ToNumbers(fixedLength.filter(isEven))); assertEquals([0, 2], ToNumbers(filterHelper(fixedLength, isEven)));
assertEquals([2], ToNumbers(fixedLengthWithOffset.filter(isEven))); assertEquals([2], ToNumbers(filterHelper(fixedLengthWithOffset, isEven)));
assertEquals([0, 2], ToNumbers(lengthTracking.filter(isEven))); assertEquals([0, 2], ToNumbers(filterHelper(lengthTracking, isEven)));
assertEquals([2], ToNumbers(lengthTrackingWithOffset.filter(isEven))); assertEquals([2],
ToNumbers(filterHelper(lengthTrackingWithOffset, isEven)));
// Shrink so that fixed length TAs go out of bounds. // Shrink so that fixed length TAs go out of bounds.
rab.resize(3 * ctor.BYTES_PER_ELEMENT); rab.resize(3 * ctor.BYTES_PER_ELEMENT);
...@@ -3686,29 +3687,46 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -3686,29 +3687,46 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
// [0, 1, 2, ...] << lengthTracking // [0, 1, 2, ...] << lengthTracking
// [2, ...] << lengthTrackingWithOffset // [2, ...] << lengthTrackingWithOffset
assertThrows(() => { fixedLength.filter(isEven); }); if (oobThrows) {
assertThrows(() => { fixedLengthWithOffset.filter(isEven); }); assertThrows(() => { filterHelper(fixedLength, isEven); });
assertThrows(() => { filterHelper(fixedLengthWithOffset, isEven); });
} else {
assertEquals([], filterHelper(fixedLength, isEven));
assertEquals([], filterHelper(fixedLengthWithOffset, isEven));
}
assertEquals([0, 2], ToNumbers(lengthTracking.filter(isEven))); assertEquals([0, 2], ToNumbers(filterHelper(lengthTracking, isEven)));
assertEquals([2], ToNumbers(lengthTrackingWithOffset.filter(isEven))); assertEquals([2],
ToNumbers(filterHelper(lengthTrackingWithOffset, isEven)));
// Shrink so that the TAs with offset go out of bounds. // Shrink so that the TAs with offset go out of bounds.
rab.resize(1 * ctor.BYTES_PER_ELEMENT); rab.resize(1 * ctor.BYTES_PER_ELEMENT);
assertThrows(() => { fixedLength.filter(isEven); }); if (oobThrows) {
assertThrows(() => { fixedLengthWithOffset.filter(isEven); }); assertThrows(() => { filterHelper(fixedLength, isEven); });
assertThrows(() => { lengthTrackingWithOffset.filter(isEven); }); assertThrows(() => { filterHelper(fixedLengthWithOffset, isEven); });
assertThrows(() => { filterHelper(lengthTrackingWithOffset, isEven); });
} else {
assertEquals([], filterHelper(fixedLength, isEven));
assertEquals([], filterHelper(fixedLengthWithOffset, isEven));
assertEquals([], filterHelper(lengthTrackingWithOffset, isEven));
}
assertEquals([0], ToNumbers(lengthTracking.filter(isEven))); assertEquals([0], ToNumbers(filterHelper(lengthTracking, isEven)));
// Shrink to zero. // Shrink to zero.
rab.resize(0); rab.resize(0);
assertThrows(() => { fixedLength.filter(isEven); }); if (oobThrows) {
assertThrows(() => { fixedLengthWithOffset.filter(isEven); }); assertThrows(() => { filterHelper(fixedLength, isEven); });
assertThrows(() => { lengthTrackingWithOffset.filter(isEven); }); assertThrows(() => { filterHelper(fixedLengthWithOffset, isEven); });
assertThrows(() => { filterHelper(lengthTrackingWithOffset, isEven); });
assertEquals([], ToNumbers(lengthTracking.filter(isEven))); } else {
assertEquals([], filterHelper(fixedLength, isEven));
assertEquals([], filterHelper(fixedLengthWithOffset, isEven));
assertEquals([], filterHelper(lengthTrackingWithOffset, isEven));
}
assertEquals([], ToNumbers(filterHelper(lengthTracking, isEven)));
// Grow so that all TAs are back in-bounds. // Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT); rab.resize(6 * ctor.BYTES_PER_ELEMENT);
...@@ -3722,13 +3740,18 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -3722,13 +3740,18 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
// [0, 1, 2, 3, 4, 5, ...] << lengthTracking // [0, 1, 2, 3, 4, 5, ...] << lengthTracking
// [2, 3, 4, 5, ...] << lengthTrackingWithOffset // [2, 3, 4, 5, ...] << lengthTrackingWithOffset
assertEquals([0, 2], ToNumbers(fixedLength.filter(isEven))); assertEquals([0, 2], ToNumbers(filterHelper(fixedLength, isEven)));
assertEquals([2], ToNumbers(fixedLengthWithOffset.filter(isEven))); assertEquals([2], ToNumbers(filterHelper(fixedLengthWithOffset, isEven)));
assertEquals([0, 2, 4], ToNumbers(lengthTracking.filter(isEven))); assertEquals([0, 2, 4], ToNumbers(filterHelper(lengthTracking, isEven)));
assertEquals([2, 4], ToNumbers(lengthTrackingWithOffset.filter(isEven))); assertEquals([2, 4],
ToNumbers(filterHelper(lengthTrackingWithOffset, isEven)));
} }
})(); }
Filter(TypedArrayFilterHelper, true);
Filter(ArrayFilterHelper, false);
// The corresponding tests for Array.prototype.filter are in
// typedarray-resizablearraybuffer-array-methods.js.
(function FilterShrinkMidIteration() { (function FilterShrinkMidIteration() {
// Orig. array: [0, 2, 4, 6] // Orig. array: [0, 2, 4, 6]
// [0, 2, 4, 6] << fixedLength // [0, 2, 4, 6] << fixedLength
...@@ -3778,7 +3801,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -3778,7 +3801,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
values = []; values = [];
resizeAfter = 1; resizeAfter = 1;
resizeTo = 3 * ctor.BYTES_PER_ELEMENT; resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
assertEquals([], ToNumbers(fixedLengthWithOffset.filter(CollectValuesAndResize))); assertEquals([],
ToNumbers(fixedLengthWithOffset.filter(CollectValuesAndResize)));
assertEquals([4, undefined], values); assertEquals([4, undefined], values);
} }
...@@ -3798,12 +3822,13 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -3798,12 +3822,13 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
values = []; values = [];
resizeAfter = 1; resizeAfter = 1;
resizeTo = 3 * ctor.BYTES_PER_ELEMENT; resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
assertEquals([], ToNumbers(lengthTrackingWithOffset.filter(CollectValuesAndResize))); assertEquals([],
ToNumbers(lengthTrackingWithOffset.filter(CollectValuesAndResize)));
assertEquals([4, undefined], values); assertEquals([4, undefined], values);
} }
})(); })();
(function FilterGrowMidIteration() { function FilterGrowMidIteration(filterHelper) {
// Orig. array: [0, 2, 4, 6] // Orig. array: [0, 2, 4, 6]
// [0, 2, 4, 6] << fixedLength // [0, 2, 4, 6] << fixedLength
// [4, 6] << fixedLengthWithOffset // [4, 6] << fixedLengthWithOffset
...@@ -3842,7 +3867,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -3842,7 +3867,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
values = []; values = [];
resizeAfter = 2; resizeAfter = 2;
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
assertEquals([], ToNumbers(fixedLength.filter(CollectValuesAndResize))); assertEquals([],
ToNumbers(filterHelper(fixedLength, CollectValuesAndResize)));
assertEquals([0, 2, 4, 6], values); assertEquals([0, 2, 4, 6], values);
} }
...@@ -3852,7 +3878,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -3852,7 +3878,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
values = []; values = [];
resizeAfter = 1; resizeAfter = 1;
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
assertEquals([], ToNumbers(fixedLengthWithOffset.filter(CollectValuesAndResize))); assertEquals([],
ToNumbers(filterHelper(fixedLengthWithOffset, CollectValuesAndResize)));
assertEquals([4, 6], values); assertEquals([4, 6], values);
} }
...@@ -3862,7 +3889,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -3862,7 +3889,8 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
values = []; values = [];
resizeAfter = 2; resizeAfter = 2;
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
assertEquals([], ToNumbers(lengthTracking.filter(CollectValuesAndResize))); assertEquals([],
ToNumbers(filterHelper(lengthTracking, CollectValuesAndResize)));
assertEquals([0, 2, 4, 6], values); assertEquals([0, 2, 4, 6], values);
} }
...@@ -3872,10 +3900,13 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper); ...@@ -3872,10 +3900,13 @@ FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
values = []; values = [];
resizeAfter = 1; resizeAfter = 1;
resizeTo = 5 * ctor.BYTES_PER_ELEMENT; resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
assertEquals([], ToNumbers(lengthTrackingWithOffset.filter(CollectValuesAndResize))); assertEquals([], ToNumbers(filterHelper(
lengthTrackingWithOffset, CollectValuesAndResize)));
assertEquals([4, 6], values); assertEquals([4, 6], values);
} }
})(); }
FilterGrowMidIteration(TypedArrayFilterHelper);
FilterGrowMidIteration(ArrayFilterHelper);
function ForEachReduceReduceRight( function ForEachReduceReduceRight(
forEachHelper, reduceHelper, reduceRightHelper, oobThrows) { forEachHelper, reduceHelper, reduceRightHelper, oobThrows) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment