Skip to content

Commit

Permalink
Add test for cycling over empty enumberable
Browse files Browse the repository at this point in the history
  • Loading branch information
sabiwara committed Mar 2, 2025
1 parent e12b377 commit 8c3df68
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/elixir/test/elixir/stream_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ defmodule StreamTest do
Stream.cycle(%{}) |> Enum.to_list()
end

assert_raise ArgumentError, "cannot cycle over an empty enumerable", fn ->
Stream.cycle(..)
end

assert Stream.cycle([1, 2, 3]) |> Stream.take(5) |> Enum.to_list() == [1, 2, 3, 1, 2]
assert Enum.take(stream, 5) == [1, 2, 3, 1, 2]
end
Expand Down

0 comments on commit 8c3df68

Please sign in to comment.