Skip to content

Doesn't shrink or print generated values if using for loop in property #427

@cmeeren

Description

@cmeeren

I am running the following test in Expecto:

testCase "Blah" <| fun () ->
  Property.check <| property {
    let! xs =
      Gen.int32 (Range.exponentialBounded ())
      |> Gen.list (Range.linear 1 10)

    for i in xs do
      Expect.isLessThan i 1000 ""
  }

When this fails, it does not shrink or print the generated values:

[11:13:21 ERR] SlidingWindowRateLimiter.Blah failed in 00:00:00.0410000.
. Expected a (1556) to be less than b (1000).
   at [email protected](Int32 i) in C:\path\to\tests.fs:line 62
   at [email protected](Unit x)
   at [email protected](Unit x)
   at [email protected](Seed seed, Int32 size)
 <Expecto>[email protected](Seed seed, Int32 size)

Replacing the loop with xs |> List.iter (fun i -> Expect.isLessThan i 1000 "") works:

[11:15:12 ERR] SlidingWindowRateLimiter.Blah errored in 00:00:00.0810000 <Expecto>
System.Exception: *** Failed! Falsifiable (after 34 tests and 6 shrinks):
[1000]
Expecto.AssertException: . Expected a (1000) to be less than b (1000).
   at [email protected](String msg)
   at [email protected](FSharpList`1 xs) in C:\path\to\tests.fs:line 61
   at [email protected](a a)
This failure can be reproduced by running:
> Property.recheck "33_2529029042667730436_6746702585223722841_0101110111111101111111101111111110" <property>
   at Hedgehog.ReportModule.tryRaise(Report report)
   at Hedgehog.Property.check(Property`1 p)
   at [email protected](Unit unitVar0) in C:\path\to\tests.fs:line 56
   at [email protected](Unit unitVar)
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 510
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions