mockazo-0.1.1: Mock records of functions easily

Safe HaskellNone
LanguageHaskell2010

Data.Component.Mock

Synopsis

Documentation

data (a :: k) :~: (b :: k) :: forall k. k -> k -> Type where infix 4 #

Propositional equality. If a :~: b is inhabited by some terminating value, then the type a is the same as the type b. To use this equality in practice, pattern-match on the a :~: b to get out the Refl constructor; in the body of the pattern-match, the compiler knows that a ~ b.

Since: base-4.7.0.0

Constructors

Refl :: forall k (a :: k) (b :: k). a :~: a 
Instances
TestEquality ((:~:) a :: k -> Type)

Since: base-4.7.0.0

Instance details

Defined in Data.Type.Equality

Methods

testEquality :: (a :~: a0) -> (a :~: b) -> Maybe (a0 :~: b) #

NFData2 ((:~:) :: Type -> Type -> Type)

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

liftRnf2 :: (a -> ()) -> (b -> ()) -> (a :~: b) -> () #

NFData1 ((:~:) a)

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

liftRnf :: (a0 -> ()) -> (a :~: a0) -> () #

a ~ b => Bounded (a :~: b)

Since: base-4.7.0.0

Instance details

Defined in Data.Type.Equality

Methods

minBound :: a :~: b #

maxBound :: a :~: b #

a ~ b => Enum (a :~: b)

Since: base-4.7.0.0

Instance details

Defined in Data.Type.Equality

Methods

succ :: (a :~: b) -> a :~: b #

pred :: (a :~: b) -> a :~: b #

toEnum :: Int -> a :~: b #

fromEnum :: (a :~: b) -> Int #

enumFrom :: (a :~: b) -> [a :~: b] #

enumFromThen :: (a :~: b) -> (a :~: b) -> [a :~: b] #

enumFromTo :: (a :~: b) -> (a :~: b) -> [a :~: b] #

enumFromThenTo :: (a :~: b) -> (a :~: b) -> (a :~: b) -> [a :~: b] #

Eq (a :~: b)

Since: base-4.7.0.0

Instance details

Defined in Data.Type.Equality

Methods

(==) :: (a :~: b) -> (a :~: b) -> Bool #

(/=) :: (a :~: b) -> (a :~: b) -> Bool #

Ord (a :~: b)

Since: base-4.7.0.0

Instance details

Defined in Data.Type.Equality

Methods

compare :: (a :~: b) -> (a :~: b) -> Ordering #

(<) :: (a :~: b) -> (a :~: b) -> Bool #

(<=) :: (a :~: b) -> (a :~: b) -> Bool #

(>) :: (a :~: b) -> (a :~: b) -> Bool #

(>=) :: (a :~: b) -> (a :~: b) -> Bool #

max :: (a :~: b) -> (a :~: b) -> a :~: b #

min :: (a :~: b) -> (a :~: b) -> a :~: b #

a ~ b => Read (a :~: b)

Since: base-4.7.0.0

Instance details

Defined in Data.Type.Equality

Methods

readsPrec :: Int -> ReadS (a :~: b) #

readList :: ReadS [a :~: b] #

readPrec :: ReadPrec (a :~: b) #

readListPrec :: ReadPrec [a :~: b] #

Show (a :~: b)

Since: base-4.7.0.0

Instance details

Defined in Data.Type.Equality

Methods

showsPrec :: Int -> (a :~: b) -> ShowS #

show :: (a :~: b) -> String #

showList :: [a :~: b] -> ShowS #

NFData (a :~: b)

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

rnf :: (a :~: b) -> () #

HasDict (a ~ b) (a :~: b) 
Instance details

Defined in Data.Constraint

Methods

evidence :: (a :~: b) -> Dict (a ~ b) #

data WithResult action where Source #

Operator to specify that an action returns some result

Constructors

(:->) :: action result -> result -> WithResult action 

class IsAction (action :: Type -> Type) where Source #

Class that all actions must implement in order to work with the rest of the library.

You only need to implement eqAction

Minimal complete definition

eqAction

Methods

eqAction :: action a -> action b -> Maybe (a :~: b) Source #

showAction :: action a -> Text Source #

showAction :: ForallF Show action => action a -> Text Source #

mockAction :: ContainsType [WithResult action] actions => IsAction action => Text -> action result -> InContextOf actions result Source #

Utility function to be used in the creation of the mock components, so the methods store action values instead of executing anything else

type InContextOf s = MultiStateT s IO Source #

Context that gets injected to the components to store the values that are being executed.

These actions will be compared during the tests with the ones that you expect, failing in case of a mismatch.

type Executes action actions = ContainsType [WithResult action] actions Source #

Constraint to specify that some actions contain the type of actions to be executed.

runMock :: InContextOf '[] a -> IO () Source #

Runs the mock context and all the checks with it

withActions :: IsAction action => [WithResult action] -> InContextOf ([WithResult action] ': otherActions) a -> InContextOf otherActions (a, [WithResult action]) Source #

Specify the expected actions for a given component to expect to be executed

makeMock :: Name -> DecsQ Source #

Generates all the required things to work with a mock: * A data type representing the component methods (Actions) * The proper instantiation of IsAction for this data type * A mock function to be used instead of new.

The only requirement is that all the methods of the component must return something wrapped in a context.