hspec / hspec-hedgehog

A library to integrate hedgehog tests into your hspec test suite.
https://hackage.haskell.org/package/hspec-hedgehog
Other
28 stars 6 forks source link

"GaveUp" when using tests with guards #15

Open iko-deleted opened 4 years ago

iko-deleted commented 4 years ago

any(?) tests using guards/discard will fail with GaveUp even when they should succeed

this test fails when used with hspec-hedgehog, but succeeds when run with the hedgehog check method

import Control.Monad (guard)
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
import Test.Hspec
import Test.Hspec.Hedgehog
import Prelude

list :: MonadGen m => m a -> m [a]
list = Gen.list (Range.constant 0 3)

prop :: PropertyT IO ()
prop = do
  l <- forAll (list Gen.bool)
  let (h : _) = l
  guard (l /= [])
  head l === h

main :: IO ()
main = do
  check $ property prop
  hspec $ it "???" $ hedgehog prop
sol commented 1 year ago

This is a duplicate of https://github.com/parsonsmatt/hspec-hedgehog/issues/9.