Skip to content

Commit cde12f7

Browse files
author
José Valim
committed
Also consider when acc_count is more than count
Signed-off-by: José Valim <[email protected]>
1 parent eb7e098 commit cde12f7

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
@@ -22,7 +22,7 @@ defmodule Stream.Reducers do
2222
{:cont, new_state}
2323
end
2424
end, fn {acc_buffer, acc_count} ->
25-
if leftover == :discard or acc_count == 0 or (step > count and count == acc_count) do
25+
if leftover == :discard or acc_count == 0 or (step > count and acc_count >= count) do
2626
{:cont, []}
2727
else
2828
{: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
@@ -74,6 +74,7 @@ defmodule EnumTest do
7474
assert Enum.chunk_every([1, 2, 3, 4, 5, 6], 2, 3, []) == [[1, 2], [4, 5]]
7575
assert Enum.chunk_every([1, 2, 3, 4, 5, 6, 7], 2, 3, []) == [[1, 2], [4, 5], [7]]
7676
assert Enum.chunk_every([1, 2, 3, 4, 5, 6, 7], 2, 3, [8]) == [[1, 2], [4, 5], [7, 8]]
77+
assert Enum.chunk_every([1, 2, 3, 4, 5, 6, 7], 2, 4, []) == [[1, 2], [5, 6]]
7778
end
7879

7980
test "chunk_by/2" do

0 commit comments

Comments
 (0)