freec-unit-tests

Safe HaskellNone
LanguageHaskell2010

FreeC.Monad.Class.Testable

Contents

Description

This module contains a type class for monads that can be used in tests.

Synopsis

Documentation

class Monad m => MonadTestable m err | m -> err Source #

Type class for monads which can be used in tests.

Minimal complete definition

shouldReturnWith', shouldFailWith'

Instances
MonadTestable Maybe () Source #

A computation in the Maybe monad fails if the result is Nothing and succeeds if the result is Just a value.

Instance details

Defined in FreeC.Monad.Class.Testable

Methods

shouldReturnWith' :: (a -> String) -> Maybe a -> (a -> IO b) -> IO b

shouldFailWith' :: (a -> String) -> Maybe a -> (() -> IO b) -> IO b

MonadTestable IO IOError Source #

An impure computation in the IO monad fails if an IO error is thrown.

Instance details

Defined in FreeC.Monad.Class.Testable

Methods

shouldReturnWith' :: (a -> String) -> IO a -> (a -> IO b) -> IO b

shouldFailWith' :: (a -> String) -> IO a -> (IOError -> IO b) -> IO b

MonadTestable Identity () Source #

A computation in the Identity monad can return a result but never fails.

Instance details

Defined in FreeC.Monad.Class.Testable

Methods

shouldReturnWith' :: (a -> String) -> Identity a -> (a -> IO b) -> IO b

shouldFailWith' :: (a -> String) -> Identity a -> (() -> IO b) -> IO b

Show err => MonadTestable (Either err) err Source #

A computation in the Either monad fails if the result is Left and succeeds if the result is Right.

Instance details

Defined in FreeC.Monad.Class.Testable

Methods

shouldReturnWith' :: (a -> String) -> Either err a -> (a -> IO b) -> IO b

shouldFailWith' :: (a -> String) -> Either err a -> (err -> IO b) -> IO b

MonadTestable m err => MonadTestable (ConverterT m) [Message] Source #

A converter is evaluated within the test environment created by initTestEnvironment and the resulting reporter is handled by the MonadTestable instance for ReporterT.

Instance details

Defined in FreeC.Monad.Class.Testable

Methods

shouldReturnWith' :: (a -> String) -> ConverterT m a -> (a -> IO b) -> IO b

shouldFailWith' :: (a -> String) -> ConverterT m a -> ([Message] -> IO b) -> IO b

MonadTestable m err => MonadTestable (ReporterT m) [Message] Source #

A reporter fails when a fatal message is reported.

Instance details

Defined in FreeC.Monad.Class.Testable

Methods

shouldReturnWith' :: (a -> String) -> ReporterT m a -> (a -> IO b) -> IO b

shouldFailWith' :: (a -> String) -> ReporterT m a -> ([Message] -> IO b) -> IO b

Expecting Values

shouldReturn :: (Eq a, Show a, MonadTestable m err) => m a -> a -> Expectation Source #

Sets the expectation that the given computation successfully returns the given value.

shouldReturnWith :: (Show a, MonadTestable m err) => m a -> (a -> Expectation) -> Expectation Source #

Sets the expectation returned by the given function for the value returned by the given computation.

Expecting Success

shouldSucceed :: (Show a, MonadTestable m err) => m a -> Expectation Source #

Sets the expectation that the given computation does not fail.

shouldSucceedWith :: MonadTestable m err => m Expectation -> Expectation Source #

Sets the expectation that the given computation successfully produces an expectation and that expectation holds.

Expecting Failures

shouldFail :: (Show a, MonadTestable m err) => m a -> Expectation Source #

Sets the expectation that the given computation fails without returning a value.

shouldFailPretty :: (Pretty a, MonadTestable m err) => m a -> Expectation Source #

Like shouldFail but if the given computation does not fail, the produced value is printed using its Pretty instance.

shouldFailWith :: (Show a, MonadTestable m err) => m a -> (err -> Expectation) -> Expectation Source #

Sets the expectation returned by the given function for the error that was produced by the given computation instead of a value.

QuickCheck

shouldReturnProperty :: (MonadTestable m err, Testable prop) => m prop -> Property Source #

Sets the expectation that the given computation returns a testable QuickCheck property and returns a property that is satisfied if and only if the property returned by the computation is satisfied.