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

Test.Method.Protocol

Description

 
Synopsis

Documentation

protocol :: ProtocolM f a -> IO (ProtocolEnv f) Source #

Build ProtocolEnv from Protocol DSL.

data ProtocolM f a Source #

Instances

Instances details
Monad (ProtocolM f) Source # 
Instance details

Defined in Test.Method.Protocol

Methods

(>>=) :: ProtocolM f a -> (a -> ProtocolM f b) -> ProtocolM f b #

(>>) :: ProtocolM f a -> ProtocolM f b -> ProtocolM f b #

return :: a -> ProtocolM f a #

Functor (ProtocolM f) Source # 
Instance details

Defined in Test.Method.Protocol

Methods

fmap :: (a -> b) -> ProtocolM f a -> ProtocolM f b #

(<$) :: a -> ProtocolM f b -> ProtocolM f a #

Applicative (ProtocolM f) Source # 
Instance details

Defined in Test.Method.Protocol

Methods

pure :: a -> ProtocolM f a #

(<*>) :: ProtocolM f (a -> b) -> ProtocolM f a -> ProtocolM f b #

liftA2 :: (a -> b -> c) -> ProtocolM f a -> ProtocolM f b -> ProtocolM f c #

(*>) :: ProtocolM f a -> ProtocolM f b -> ProtocolM f b #

(<*) :: ProtocolM f a -> ProtocolM f b -> ProtocolM f a #

data ProtocolEnv f Source #

ProtocolEnv f provides mock methods, where f is a GADT functor that represents the set of dependent methods.

data Call f m Source #

Instances

Instances details
Behave (Call f m) Source # 
Instance details

Defined in Test.Method.Protocol

Associated Types

type Condition (Call f m) Source #

type MethodOf (Call f m) Source #

Methods

thenMethod :: Condition (Call f m) -> MethodOf (Call f m) -> Call f m Source #

type Condition (Call f m) Source # 
Instance details

Defined in Test.Method.Protocol

type Condition (Call f m) = CallArgs f m
type MethodOf (Call f m) Source # 
Instance details

Defined in Test.Method.Protocol

type MethodOf (Call f m) = m

data CallArgs f m Source #

data CallId Source #

Instances

Instances details
Eq CallId Source # 
Instance details

Defined in Test.Method.Protocol

Methods

(==) :: CallId -> CallId -> Bool #

(/=) :: CallId -> CallId -> Bool #

Ord CallId Source # 
Instance details

Defined in Test.Method.Protocol

Show CallId Source # 
Instance details

Defined in Test.Method.Protocol

type IsMethodName f m = (Typeable (f m), Ord (f m), Show (f m)) Source #

lookupMock Source #

Arguments

:: forall f m. (IsMethodName f m, Show (AsTuple (Args m)), TupleLike (Args m), Method m, MonadIO (Base m)) 
=> f m

name of method

-> ProtocolEnv f 
-> m 

Get the mock method by method name. Return a unstubed method (which throws exception for every call) if the behavior of the method is unspecified by ProtocolEnv

lookupMockWithShow Source #

Arguments

:: forall f m. (IsMethodName f m, Method m, MonadIO (Base m)) 
=> (Args m -> String)

show function for the argument of method

-> f m

name of method

-> ProtocolEnv f 
-> m 

Get the mock method by method name. Return a unstubed method (which throws exception for every call) if the behavior of the method is unspecified by ProtocolEnv. Use this function only if you want to customize show implementation for the argument of the method.

decl :: IsMethodName f m => Call f m -> ProtocolM f CallId Source #

Declare a method call specification. It returns the call id of the method call.

whenArgs :: ArgsMatcher (Args m) => f m -> EachMatcher (Args m) -> CallArgs f m Source #

Specify the argument condition of a method call

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

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

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

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

Specify behavior that return a constant value for a call

dependsOn :: Call f m -> [CallId] -> Call f m Source #

Specify on which method calls the call depends.

verify :: ProtocolEnv f -> IO () Source #

Verify that all method calls specified by Protocol DSL are fired.