Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
The internal core language of expectations in HMock.
Synopsis
- data ExpectSet step where
- ExpectStep :: step -> ExpectSet step
- ExpectNothing :: ExpectSet step
- ExpectSequence :: ExpectSet step -> ExpectSet step -> ExpectSet step
- ExpectInterleave :: ExpectSet step -> ExpectSet step -> ExpectSet step
- ExpectEither :: ExpectSet step -> ExpectSet step -> ExpectSet step
- ExpectMulti :: Multiplicity -> ExpectSet step -> ExpectSet step
- ExpectConsecutive :: Multiplicity -> ExpectSet step -> ExpectSet step
- satisfied :: ExpectSet step -> Bool
- liveSteps :: ExpectSet step -> [(step, ExpectSet step)]
- simplify :: ExpectSet step -> ExpectSet step
- getSteps :: ExpectSet step -> [step]
- data CollectedSet step where
- CollectedStep :: step -> CollectedSet step
- CollectedNothing :: CollectedSet step
- CollectedSequence :: [CollectedSet step] -> CollectedSet step
- CollectedInterleave :: [CollectedSet step] -> CollectedSet step
- CollectedChoice :: [CollectedSet step] -> CollectedSet step
- CollectedMulti :: Multiplicity -> CollectedSet step -> CollectedSet step
- CollectedConsecutive :: Multiplicity -> CollectedSet step -> CollectedSet step
- collect :: ExpectSet step -> CollectedSet step
- formatExpectSet :: Show step => ExpectSet step -> String
- excess :: ExpectSet step -> ExpectSet step
Documentation
data ExpectSet step where Source #
A set of expected steps and their responses. This is the "core" language of expectations for HMock. It's based roughly on Svenningsson, Svensson, Smallbone, Arts, Norell, and Hughes' Expressive Semantics of Mocking. However, there are a few small adjustments. We have two repetition operators which respectively represent general repetition with interleaving, and consecutive repetition. We also attach arbitrary multiplicities to repetition.
ExpectStep :: step -> ExpectSet step | |
ExpectNothing :: ExpectSet step | |
ExpectSequence :: ExpectSet step -> ExpectSet step -> ExpectSet step | |
ExpectInterleave :: ExpectSet step -> ExpectSet step -> ExpectSet step | |
ExpectEither :: ExpectSet step -> ExpectSet step -> ExpectSet step | |
ExpectMulti :: Multiplicity -> ExpectSet step -> ExpectSet step | |
ExpectConsecutive :: Multiplicity -> ExpectSet step -> ExpectSet step |
satisfied :: ExpectSet step -> Bool Source #
Checks whether an ExpectSet is in an "accepting" state. In other words, is it okay for the test to end here? If False, then there are still expectations that must be satisfied before the test can succeed.
liveSteps :: ExpectSet step -> [(step, ExpectSet step)] Source #
Computes the live steps of the ExpectSet. In other words: which individual steps can be matched right now, and what are the remaining expectations in each case?
simplify :: ExpectSet step -> ExpectSet step Source #
Performs a complete simplification of the ExpectSet. This could be slow, but we intend to do it only for error messages, so it need not be very fast.
getSteps :: ExpectSet step -> [step] Source #
Get a list of all steps mentioned by an ExpectSet
. This is used to
determine which classes need to be initialized before adding an expectation.
data CollectedSet step where Source #
A higher-level intermediate form of an ExpectSet suitable for communication with the user. Chains of binary operators are collected into sequences to be displayed in lists rather than arbitrary nesting.
CollectedStep :: step -> CollectedSet step | |
CollectedNothing :: CollectedSet step | |
CollectedSequence :: [CollectedSet step] -> CollectedSet step | |
CollectedInterleave :: [CollectedSet step] -> CollectedSet step | |
CollectedChoice :: [CollectedSet step] -> CollectedSet step | |
CollectedMulti :: Multiplicity -> CollectedSet step -> CollectedSet step | |
CollectedConsecutive :: Multiplicity -> CollectedSet step -> CollectedSet step |
collect :: ExpectSet step -> CollectedSet step Source #
Collects an ExpectSet into the intermediate form for display. It's assumed that the expression was simplified before this operation.