Safe Haskell | None |
---|---|
Language | Haskell2010 |
FreeC.Monad.Class.Testable
Description
This module contains a type class for monads that can be used in tests.
Synopsis
- class Monad m => MonadTestable m err | m -> err
- shouldReturn :: (Eq a, Show a, MonadTestable m err) => m a -> a -> Expectation
- shouldReturnWith :: (Show a, MonadTestable m err) => m a -> (a -> Expectation) -> Expectation
- shouldSucceed :: (Show a, MonadTestable m err) => m a -> Expectation
- shouldSucceedWith :: MonadTestable m err => m Expectation -> Expectation
- shouldFail :: (Show a, MonadTestable m err) => m a -> Expectation
- shouldFailPretty :: (Pretty a, MonadTestable m err) => m a -> Expectation
- shouldFailWith :: (Show a, MonadTestable m err) => m a -> (err -> Expectation) -> Expectation
- shouldReturnProperty :: (MonadTestable m err, Testable prop) => m prop -> Property
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 |
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 |
Defined in FreeC.Monad.Class.Testable | |
MonadTestable Identity () Source # | A computation in the |
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 |
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
|
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. |
Defined in FreeC.Monad.Class.Testable |
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.