purescript-deprecated/purescript-strongcheck

Using suchThat makes test to never halt

Closed this issue ยท 6 comments

suchThat (chooseInt (-99.0) 99.0) (/= 0)

It seems that once the predicate returns false, it won't generate anything anymore and the tests stop. Using (const true) there makes the tests run normally.

Here's a failing test: https://github.com/anttih/purescript-strongcheck/blob/such-that-bug/test/Test/Main.purs#L95

This only happens when trying to generate one value out of the generator. If I change that to

suchThat'   <- collectAll mempty $ suchThat (chooseInt 0.0 4.0) (/= 2)

it works as expected.

I see another problem here too, why does chooseInt accept Numbers? ๐Ÿ˜‰

๐Ÿ‘ i'm also having this issue.

Haskell QuickCheck's suchThat resizes the the Gen when the predicate isn't affirmed.

https://hackage.haskell.org/package/QuickCheck-2.8.1/docs/src/Test-QuickCheck-Gen.html#suchThat

I see another problem here too, why does chooseInt accept Numbers? ๐Ÿ˜‰

Because someone submitted the Int cleanup to quickcheck but not strongcheck. Not pointing any fingers, mind you. ๐Ÿ˜‰