Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data (a :: k) :~: (b :: k) :: forall k. k -> k -> Type where
- data WithResult action where
- (:->) :: action result -> result -> WithResult action
- class IsAction (action :: Type -> Type) where
- eqAction :: action a -> action b -> Maybe (a :~: b)
- showAction :: action a -> Text
- mockAction :: ContainsType [WithResult action] actions => IsAction action => Text -> action result -> InContextOf actions result
- type InContextOf s = MultiStateT s IO
- type Executes action actions = ContainsType [WithResult action] actions
- runMock :: InContextOf '[] a -> IO ()
- withActions :: IsAction action => [WithResult action] -> InContextOf ([WithResult action] ': otherActions) a -> InContextOf otherActions (a, [WithResult action])
- makeMock :: Name -> DecsQ
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
Instances
TestEquality ((:~:) a :: k -> Type) | Since: base-4.7.0.0 |
Defined in Data.Type.Equality | |
NFData2 ((:~:) :: Type -> Type -> Type) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
NFData1 ((:~:) a) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
a ~ b => Bounded (a :~: b) | Since: base-4.7.0.0 |
a ~ b => Enum (a :~: b) | Since: base-4.7.0.0 |
Defined in Data.Type.Equality | |
Eq (a :~: b) | Since: base-4.7.0.0 |
Ord (a :~: b) | Since: base-4.7.0.0 |
Defined in Data.Type.Equality | |
a ~ b => Read (a :~: b) | Since: base-4.7.0.0 |
Show (a :~: b) | Since: base-4.7.0.0 |
NFData (a :~: b) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
HasDict (a ~ b) (a :~: b) | |
Defined in Data.Constraint |
data WithResult action where Source #
Operator to specify that an action returns some result
(:->) :: 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
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.