Skip to content

Commit

Permalink
Use ranges with step in tests (#202)
Browse files Browse the repository at this point in the history
StreamData depends on Elixir 1.12+ now, so we can clean these up.
  • Loading branch information
davydog187 authored Oct 18, 2024
1 parent 028e21f commit ccaf79b
Showing 1 changed file with 3 additions and 13 deletions.
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

0 comments on commit ccaf79b

Please sign in to comment.