module BuildBox.Build.Testable
( Testable(..)
, check
, checkFalse
, outCheckOk
, outCheckFalseOk)
where
import BuildBox.Build.Base
import BuildBox.Build.BuildError
import BuildBox.Pretty
import Control.Monad.Catch
class Testable prop where
test :: prop -> Build Bool
check :: (Show prop, Testable prop) => prop -> Build ()
check prop
= do result <- test prop
if result
then return ()
else throwM $ ErrorCheckFailed True prop
checkFalse :: (Show prop, Testable prop) => prop -> Build ()
checkFalse prop
= do result <- test prop
if result
then throwM $ ErrorCheckFailed False prop
else return ()
outCheckOk
:: (Show prop, Testable prop)
=> String -> prop -> Build ()
outCheckOk str prop
= do outLn (string str)
check prop
outCheckFalseOk
:: (Show prop, Testable prop)
=> String -> prop -> Build ()
outCheckFalseOk str prop
= do outLn (string str)
checkFalse prop