Skip to content

Commit

Permalink
fixup! Add Iterator#chunks to allow splitting iterator values into Ar…
Browse files Browse the repository at this point in the history
…rays
  • Loading branch information
lundibundi committed Jul 5, 2019
1 parent 9a0273d commit eeb66c4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,27 @@ metatests.testSync('Iterator.chunk with number', test => {
test.strictSame(actual, [[1, 2, 3], [1, 4, 5], [1, 6, 7]]);
});

metatests.testSync('Iterator.chunk with empty iterator', test => {
const actual = iter([])
.chunk(3)
.toArray();
test.strictSame(actual, []);
});

metatests.testSync('Iterator.chunk with single chunk', test => {
const actual = iter([1, 2, 3, 1, 4, 5, 1, 6, 7])
.chunk(() => false)
.toArray();
test.strictSame(actual, [[1, 2, 3, 1, 4, 5, 1, 6, 7]]);
});

metatests.testSync('Iterator.chunk with empty chunks', test => {
const actual = iter([1, 1, 3, 3, 3, 5, 5])
.chunk(x => x === 3)
.toArray();
test.strictSame(actual, [[1, 1], [3], [3], [3, 5, 5]]);
});

metatests.testSync('iterEntries must iterate over object entries', test => {
const source = { a: 13, b: 42, c: 'hello' };
test.strictSame(iterEntries(source).toArray(), Object.entries(source));
Expand Down

0 comments on commit eeb66c4

Please sign in to comment.