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