0 | module Evince.Hedgehog
 1 |
 2 | import Evince.Core
 3 | import Evince.Expectations
 4 | import Evince.Spec
 5 | import Hedgehog
 6 |
 7 | %default covering
 8 |
 9 | ||| Run a property silently as a `TestResultT IO` chain. A failure carries
10 | ||| hedgehog's report - the shrunk counterexample, diff and recheck seed -
11 | ||| under the given test label.
12 | export
13 | runProperty : String -> Property -> TestResultT IO ()
14 | runProperty label p = do
15 |   seed <- liftIO initSeed
16 |   rep  <- liftIO $ checkReport p.config Nothing seed p.test (\_ => pure ())
17 |   case rep.status of
18 |     OK       => pure ()
19 |     Failed _ => mustFail (renderResult DisableColor (Just (fromString label)) rep)
20 |
21 | ||| Embed a hedgehog Property as an evince test case.
22 | export
23 | prop : HasIO m => String -> Property -> Spec m a ()
24 | prop label p = it label (runProperty label p)
25 |
26 | ||| Embed a PropertyT action (wraps in `property`).
27 | export
28 | itProp : HasIO m => String -> PropertyT () -> Spec m a ()
29 | itProp label = prop label . property
30 |
31 | ||| Embed a single-run property (wraps in `property1`).
32 | export
33 | itProp1 : HasIO m => String -> PropertyT () -> Spec m a ()
34 | itProp1 label = prop label . property1
35 |