HMock-0.1.0.0: A flexible mock framework for testing effectful code.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.HMock.Internal.Mockable

Synopsis

Documentation

data MatchResult where Source #

The result of matching a Matcher a with an Action b. Because the types should already guarantee that the methods match, all that's left is to match arguments.

Constructors

NoMatch :: Int -> MatchResult

No match. The int is the number of arguments that don't match.

Match :: MatchResult

Match. Stores a witness to the equality of return types.

class Typeable cls => MockableBase (cls :: (Type -> Type) -> Constraint) where Source #

A base class for Monad subclasses whose methods can be mocked. You usually want to generate this instance using makeMockable, makeMockableBase, deriveMockable, or deriveMockableBase. It's just boilerplate.

Associated Types

data Action cls :: Symbol -> (Type -> Type) -> Type -> Type Source #

An action that is performed. This data type will have one constructor for each method.

data Matcher cls :: Symbol -> (Type -> Type) -> Type -> Type Source #

A specification for matching actions. The actual arguments should be replaced with predicates.

Methods

showAction :: Action cls name m a -> String Source #

Gets a text description of an Action, for use in error messages.

showMatcher :: Maybe (Action cls name m a) -> Matcher cls name m b -> String Source #

Gets a text description of a Matcher, for use in error messages.

matchAction :: Matcher cls name m a -> Action cls name m a -> MatchResult Source #

Attempts to match an Action with a Matcher.

class MockableBase cls => Mockable (cls :: (Type -> Type) -> Constraint) where Source #

A class for Monad subclasses whose methods can be mocked. This class augments MockableBase with a setup method that is run before HMock touches the Monad subclass for the first time. The default implementation does nothing, but you can derive your own instances that add setup behavior.

Minimal complete definition

Nothing

Methods

setupMockable :: (MonadIO m, Typeable m) => proxy cls -> MockT m () Source #