Skip to content

Commit 5294a73

Browse files
author
José Valim
committed
Also consider when acc_count is more than count
1 parent c7bf764 commit 5294a73

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/elixir/lib/stream/reducers.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ defmodule Stream.Reducers do
2525
end
2626

2727
after_fun = fn {acc_buffer, acc_count} ->
28-
if leftover == :discard or acc_count == 0 or (step > count and count == acc_count) do
28+
if leftover == :discard or acc_count == 0 or (step > count and acc_count >= count) do
2929
{:cont, []}
3030
else
3131
{:cont, :lists.reverse(acc_buffer, Enum.take(leftover, count - acc_count)), []}

lib/elixir/test/elixir/enum_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ defmodule EnumTest do
7575
assert Enum.chunk_every([1, 2, 3, 4, 5, 6], 2, 3, []) == [[1, 2], [4, 5]]
7676
assert Enum.chunk_every([1, 2, 3, 4, 5, 6, 7], 2, 3, []) == [[1, 2], [4, 5], [7]]
7777
assert Enum.chunk_every([1, 2, 3, 4, 5, 6, 7], 2, 3, [8]) == [[1, 2], [4, 5], [7, 8]]
78+
assert Enum.chunk_every([1, 2, 3, 4, 5, 6, 7], 2, 4, []) == [[1, 2], [5, 6]]
7879
end
7980

8081
test "chunk_by/2" do

0 commit comments

Comments
 (0)