diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2014-09-13 16:14:03 +0200 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2014-09-13 16:14:12 +0200 |
commit | 719a2bafcb79d7c838527bf890b1bb13a006d8a9 (patch) | |
tree | 01956d40bd4a37a8858c355a628e2e02fc082615 /lib/elixir/test/elixir/stream_test.exs | |
parent | c26db149739a2adc2da15418f8793d88f749efb8 (diff) | |
download | elixir-719a2bafcb79d7c838527bf890b1bb13a006d8a9.tar.gz |
Ensure chunk/4 is haltable
Diffstat (limited to 'lib/elixir/test/elixir/stream_test.exs')
-rw-r--r-- | lib/elixir/test/elixir/stream_test.exs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/elixir/test/elixir/stream_test.exs b/lib/elixir/test/elixir/stream_test.exs index af0f734c5..edc85ea78 100644 --- a/lib/elixir/test/elixir/stream_test.exs +++ b/lib/elixir/test/elixir/stream_test.exs @@ -67,6 +67,19 @@ defmodule StreamTest do assert Enum.zip(list, list) == Enum.zip(stream, stream) end + test "chunk/4 is haltable" do + assert 1..10 |> Stream.take(6) |> Stream.chunk(4, 4, [7, 8]) |> Enum.to_list == + [[1, 2, 3, 4], [5, 6, 7, 8]] + assert 1..10 |> Stream.take(6) |> Stream.chunk(4, 4, [7, 8]) |> Stream.take(3) |> Enum.to_list == + [[1, 2, 3, 4], [5, 6, 7, 8]] + assert 1..10 |> Stream.take(6) |> Stream.chunk(4, 4, [7, 8]) |> Stream.take(2) |> Enum.to_list == + [[1, 2, 3, 4], [5, 6, 7, 8]] + assert 1..10 |> Stream.take(6) |> Stream.chunk(4, 4, [7, 8]) |> Stream.take(1) |> Enum.to_list == + [[1, 2, 3, 4]] + assert 1..6 |> Stream.take(6) |> Stream.chunk(4, 4, [7, 8]) |> Enum.to_list == + [[1, 2, 3, 4], [5, 6, 7, 8]] + end + test "chunk_by/2" do stream = Stream.chunk_by([1, 2, 2, 3, 4, 4, 6, 7, 7], &(rem(&1, 2) == 1)) |