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

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

Open
cmeeren opened this issue Dec 14, 2022 · 0 comments
Open

Comments

@cmeeren
Copy link
Contributor

cmeeren commented Dec 14, 2022

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant