instance Example (a -> TestT IO ()) where
type Arg (a -> TestT IO ()) = Gen a
evaluateExample example =
evaluateExample (\gen ->
a <- forAll gen
test (example a)
This puts the Gen into the hspec hooks.
beforeGen :: Gen a -> SpecWith (Gen a) -> Spec
beforeGen gen = beforeAll (pure gen)
beforeWithGen :: (a -> Gen b) -> SpecWith (Gen b) -> SpecWith (Gen a)
beforeWithGen mkGen =
beforeAllWith $ \genA -> pure (genA >>= mkGen)
But it also forbids you from providing "normal" values in to TestT. That's probably fine. After all you can always do pure :: a -> Gen a.
This puts the
Gen
into thehspec
hooks.But it also forbids you from providing "normal" values in to
TestT
. That's probably fine. After all you can always dopure :: a -> Gen a
.