StreamData: data generation and property testing for Elixir

Thanks for StreamData and PropertyTest - going to prove very useful for me. I’ve taken it out for a spin but I can’t seem to influence the number of generations. My test looks like this:

  import PropertyTest
  property "checks that a date fits within the start and end dates for that year" do
    check all  day   <- StreamData.int(1..28),
               month <- StreamData.int(1..12),
               year  <- StreamData.int(1..3000),
               max_runs: 1_000
    do
      {:ok, date} = Date.new(year, month, day)
      starts = struct(Date, Cldr.Calendar.ISOWeek.first_day_of_year(date))
      ends = struct(Date, Cldr.Calendar.ISOWeek.last_day_of_year(date))
      assert Date.compare(starts, date) in [:lt, :eq] and Date.compare(ends, date) in [:gt, :eq]
    end
  end

I thought either the clauses would act like they do for a comprehension (seems they don’t, which makes sense) or would have been influenced by :max_runs. But no matter what I put for :max_runs the result of running this test is always 1 property, 125 tests, 0 failures. Any guidance would be much appreciated.

1 Like