method-0.4.0.0: rebindable methods for improving testability
LicenseBSD-3
Maintainerautotaker@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Test.Method.Mock

Description

DSL to generate mock methods.

Synopsis

Documentation

type Mock method = MockM method () Source #

data MockM method a Source #

Instances

Instances details
Monad (MockM method) Source # 
Instance details

Defined in Test.Method.Mock

Methods

(>>=) :: MockM method a -> (a -> MockM method b) -> MockM method b #

(>>) :: MockM method a -> MockM method b -> MockM method b #

return :: a -> MockM method a #

Functor (MockM method) Source # 
Instance details

Defined in Test.Method.Mock

Methods

fmap :: (a -> b) -> MockM method a -> MockM method b #

(<$) :: a -> MockM method b -> MockM method a #

Applicative (MockM method) Source # 
Instance details

Defined in Test.Method.Mock

Methods

pure :: a -> MockM method a #

(<*>) :: MockM method (a -> b) -> MockM method a -> MockM method b #

liftA2 :: (a -> b -> c) -> MockM method a -> MockM method b -> MockM method c #

(*>) :: MockM method a -> MockM method b -> MockM method b #

(<*) :: MockM method a -> MockM method b -> MockM method a #

a ~ () => Behave (MockM method a) Source # 
Instance details

Defined in Test.Method.Mock

Associated Types

type Condition (MockM method a) Source #

type MethodOf (MockM method a) Source #

Methods

thenMethod :: Condition (MockM method a) -> MethodOf (MockM method a) -> MockM method a Source #

type Condition (MockM method a) Source # 
Instance details

Defined in Test.Method.Mock

type Condition (MockM method a) = Matcher (Args method)
type MethodOf (MockM method a) Source # 
Instance details

Defined in Test.Method.Mock

type MethodOf (MockM method a) = method

mockup :: Method method => Mock method -> method Source #

generate a method from Mock DSL. Mock DSL consists of rules. On a call of generated method, the first rule matched the arguments is applied.

thenReturn :: (Behave x, Method (MethodOf x)) => Condition x -> Ret (MethodOf x) -> x Source #

Specify behavior that return a constant value for a call

thenAction :: (Behave x, Method (MethodOf x)) => Condition x -> Base (MethodOf x) (Ret (MethodOf x)) -> x Source #

Specify behavior that executes an action for a call

thenMethod :: Behave x => Condition x -> MethodOf x -> x Source #

Specify behavior from a pair of a condition and a method.

throwNoStubWithShow :: Method method => (Args method -> String) -> (Args method -> Bool) -> Mock method Source #

throwNoStubWithShow fshow matcher means the method raises runtime exception if the arguments matches matcher. The argument tuple is converted to String by using fshow function.

throwNoStub :: (Method method, Show (AsTuple (Args method)), TupleLike (Args method)) => Matcher (Args method) -> Mock method Source #

throwNoStub matcher means the method raises a runtime exception if the arguments matches matcher. The argument tuple is converted to String by using show function.