quickcheck-state-machine-0.1.0: Test monadic programs using state machine based models

Copyright(C) 2017 ATS Advanced Telematic Systems GmbH
LicenseBSD-style (see the file LICENSE)
MaintainerStevan Andjelkovic <stevan@advancedtelematic.com>
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Test.StateMachine

Contents

Description

The main module for state machine based testing, it contains combinators that help you build sequential and parallel properties.

Synopsis

Sequential property combinators

data Program act Source #

A (sequential) program is an abstract datatype representing a list of actions.

The idea is that the user shows how to generate, shrink, execute and modelcheck individual actions, and then the below combinators lift those things to whole programs.

Instances

Eq (Internal act) => Eq (Program act) Source # 

Methods

(==) :: Program act -> Program act -> Bool #

(/=) :: Program act -> Program act -> Bool #

Read (Internal act) => Read (Program act) Source # 
(Show (Untyped act), HFoldable act) => Show (Program act) Source # 

Methods

showsPrec :: Int -> Program act -> ShowS #

show :: Program act -> String #

showList :: [Program act] -> ShowS #

Monoid (Program act) Source # 

Methods

mempty :: Program act #

mappend :: Program act -> Program act -> Program act #

mconcat :: [Program act] -> Program act #

forAllProgram Source #

Arguments

:: Show (Untyped act) 
=> HFoldable act 
=> Generator model act 
-> Shrinker act 
-> Precondition model act 
-> Transition model act 
-> InitialModel model 
-> (Program act -> Property)

Predicate that should hold for all programs.

-> Property 

This function is like a forAllShrink for sequential programs.

runAndCheckProgram Source #

Arguments

:: Monad m 
=> HFunctor act 
=> Precondition model act 
-> Transition model act 
-> Postcondition model act 
-> InitialModel model 
-> Semantics act m 
-> (m Property -> Property)

Runner

-> Program act 
-> Property 

Run a sequential program and check if your model agrees with your semantics.

runAndCheckProgram' Source #

Arguments

:: Monad m 
=> HFunctor act 
=> Precondition model act 
-> Transition model act 
-> Postcondition model act 
-> InitialModel model 
-> Semantics act m 
-> IO setup

Setup a resource.

-> (setup -> m Property -> Property) 
-> (setup -> IO ())

Tear down the resource.

-> Program act 
-> Property 

Same as above, except with the possibility to setup some resource for the runner to use. The resource could be a database connection for example.

Parallel property combinators

data ParallelProgram act Source #

A parallel program is an abstract datatype that represents three sequences of actions; a sequential prefix and two parallel suffixes. Analogous to the sequential case, the user shows how to generate, shrink, execute and modelcheck individual actions, and then the below combinators lift those things to whole parallel programs.

Instances

forAllParallelProgram Source #

Arguments

:: Show (Untyped act) 
=> HFoldable act 
=> Generator model act 
-> Shrinker act 
-> Precondition model act 
-> Transition model act 
-> InitialModel model 
-> (ParallelProgram act -> Property)

Predicate that should hold for all parallel programs.

-> Property 

This function is like a forAllShrink for parallel programs.

data History act Source #

A history is a trace of invocations and responses from running a parallel program.

runParallelProgram Source #

Arguments

:: Show (Untyped act) 
=> HTraversable act 
=> Semantics act IO 
-> ParallelProgram act 
-> (History act -> Property)

Predicate that should hold for the execution history.

-> Property 

Run a parallel program and collect the history of the execution.

runParallelProgram' Source #

Arguments

:: Show (Untyped act) 
=> HTraversable act 
=> IO setup

Setup a resource.

-> (setup -> Semantics act IO) 
-> (setup -> IO ())

Tear down the resource.

-> ParallelProgram act 
-> (History act -> Property) 
-> Property 

Same as above, but with the possibility of setting up some resource.

checkParallelProgram Source #

Arguments

:: HFoldable act 
=> Transition model act 
-> Postcondition model act 
-> InitialModel model 
-> ParallelProgram act 
-> History act

History to be checked.

-> Property 

Check if a history from a parallel execution can be linearised.

Types