Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ranges with step in tests #202

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions test/stdlib/enum_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ defmodule StreamData.EnumTest do
) do
length = length(list)

# TODO: When we depend on 1.12+, rewrite as:
# negative_range = (range.first - length)..(range.last - length)//1
negative_range = %Range{
first: range.first - length,
last: range.last - length,
step: 1
}
negative_range = (range.first - length)..(range.last - length)//1

assert Enum.slide(list, negative_range, insertion_idx) ==
Enum.slide(list, range, insertion_idx)
Expand Down Expand Up @@ -92,9 +86,7 @@ defmodule StreamData.EnumTest do
first <- integer(),
last <- integer(),
step <- positive_integer() do
# TODO: When we depend on 1.12+, rewrite as:
# first..last//step
range = %Range{first: first, last: last, step: step}
range = first..last//step

enum_consistency_spec(count, fn enumerable ->
Enum.slice(enumerable, range)
Expand Down Expand Up @@ -131,9 +123,7 @@ defmodule StreamData.EnumTest do
end

defp enum_consistency_spec(count, fun) do
# TODO: When we depend on 1.12+, rewrite as:
# 1..count//1
range = %Range{first: 1, last: count, step: 1}
range = 1..count//1
list = Enum.to_list(range)
stream = Stream.map(range, & &1)

Expand Down
Loading