module BuildBox.Build.Testable
( Testable(..)
, check
, checkFalse
, outCheckOk
, outCheckFalseOk)
where
import BuildBox.Build.Base
import BuildBox.Build.BuildError
import Control.Monad.Error
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 throwError $ ErrorCheckFailed True prop
checkFalse :: (Show prop, Testable prop) => prop -> Build ()
checkFalse prop
= do result <- test prop
if result
then throwError $ ErrorCheckFailed False prop
else return ()
outCheckOk
:: (Show prop, Testable prop)
=> String -> prop -> Build ()
outCheckOk str prop
= do outLn str
check prop
outCheckFalseOk
:: (Show prop, Testable prop)
=> String -> prop -> Build ()
outCheckFalseOk str prop
= do outLn str
checkFalse prop