whatyouhide / stream_data

Data generation and property-based testing for Elixir. 🔮
https://hexdocs.pm/stream_data
864 stars 66 forks source link

StreamData.integer/1 does not handle ranges with steps correctly #158

Closed Qqwy closed 2 years ago

Qqwy commented 2 years ago

Given

generator = StreamData.integer(2..8//2)

When calling

generator |> Enum.take(1_000) |> MapSet.new

the expected output is

#MapSet<[2, 4, 6, 8]>

(i.e. the same as calling MapSet.new(2..8//2))

but instead we get

#MapSet<[2, 3, 4, 5, 6, 7, 8]>

It seems StreamData is not taking the step field (introduced in Elixir 1.12) into account.

Qqwy commented 2 years ago

I'd be willing to contribute a PR to fix this, by the way :slightly_smiling_face:

whatyouhide commented 2 years ago

@Qqwy yep, definitely not taking steps into account yet. Please do send a PR! 💟