HMock-0.1.0.0: A flexible mock framework for testing effectful code.
Safe HaskellNone
LanguageHaskell2010

Test.HMock.Internal.ExpectSet

Synopsis

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.

Constructors

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 

Instances

Instances details
Eq step => Eq (ExpectSet step) Source # 
Instance details

Defined in Test.HMock.Internal.ExpectSet

Methods

(==) :: ExpectSet step -> ExpectSet step -> Bool #

(/=) :: ExpectSet step -> ExpectSet step -> Bool #

Show step => Show (ExpectSet step) Source # 
Instance details

Defined in Test.HMock.Internal.ExpectSet

Methods

showsPrec :: Int -> ExpectSet step -> ShowS #

show :: ExpectSet step -> String #

showList :: [ExpectSet step] -> ShowS #

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.

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.

formatExpectSet :: Show step => ExpectSet step -> String Source #

Converts a set of expectations into a string that summarizes them, with the given prefix (used to indent).

excess :: ExpectSet step -> ExpectSet step Source #

Reduces a set of expectations to the minimum steps that would be required to satisfy the entire set. This weeds out unnecessary information before reporting that there were unmet expectations at the end of the test.