HTF-0.13.1.0: The Haskell Test Framework

Safe HaskellSafe
LanguageHaskell2010

Test.Framework.AssertM

Description

This module defines the AssertM monad, which allows you either to run assertions as ordinary unit tests or to evaluate them as pure functions.

Synopsis

Documentation

class Monad m => AssertM m where #

A typeclass for generic assertions.

Minimal complete definition

genericAssertFailure__, genericSubAssert

data AssertBool a #

Type for evaluating a generic assertion as a pure function.

Constructors

AssertOk a

Assertion passes successfully and yields the given value.

AssertFailed [AssertStackElem]

Assertion fails with the given stack trace. In the stack trace, the outermost stackframe comes first.

Instances

Monad AssertBool # 

Methods

(>>=) :: AssertBool a -> (a -> AssertBool b) -> AssertBool b #

(>>) :: AssertBool a -> AssertBool b -> AssertBool b #

return :: a -> AssertBool a #

fail :: String -> AssertBool a #

Functor AssertBool # 

Methods

fmap :: (a -> b) -> AssertBool a -> AssertBool b #

(<$) :: a -> AssertBool b -> AssertBool a #

Applicative AssertBool # 

Methods

pure :: a -> AssertBool a #

(<*>) :: AssertBool (a -> b) -> AssertBool a -> AssertBool b #

(*>) :: AssertBool a -> AssertBool b -> AssertBool b #

(<*) :: AssertBool a -> AssertBool b -> AssertBool a #

AssertM AssertBool # 
Eq a => Eq (AssertBool a) # 

Methods

(==) :: AssertBool a -> AssertBool a -> Bool #

(/=) :: AssertBool a -> AssertBool a -> Bool #

Ord a => Ord (AssertBool a) # 
Read a => Read (AssertBool a) # 
Show a => Show (AssertBool a) # 

boolValue :: AssertBool a -> Bool #

Evaluates a generic assertion to a Bool value.

eitherValue :: AssertBool a -> Either String a #

Evaluates a generic assertion to an Either value. The result is Right x if the assertion passes and yields value x, otherwise the result is Left err, where err is an error message.

formatStack :: [AssertStackElem] -> String #

Formats a stack trace.