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

Test.HMock.Internal.Rule

Description

Internal module to define Rule, so that its constructor can be visible to other implementation code.

Synopsis

Documentation

data Rule (cls :: (Type -> Type) -> Constraint) (name :: Symbol) (m :: Type -> Type) (r :: Type) where Source #

A rule for matching a method and responding to it when it matches.

The method may be matched by providing either an Action to match exactly, or a Matcher. Exact matching is only available when all method arguments

A Rule may have zero or more responses, which are attached using |-> and |=>. If there are no responses for a Rule, then there must be a default response for that action, and it is used. If more than one response is added, the rule will perform the responses in order, repeating the last response if there are additional matches.

Example:

expect $
  GetLine_ anything
    |-> "hello"
    |=> (GetLine prompt) -> "The prompt was " ++ prompt
    |-> "quit"

Constructors

(:=>) :: Matcher cls name m r -> [Action cls name m r -> MockT m r] -> Rule cls name m r 

Instances

Instances details
Expectable cls name m r (Rule cls name m r) Source # 
Instance details

Defined in Test.HMock.Rule

Methods

toRule :: Rule cls name m r -> Rule cls name m r Source #