Copyright | (c) 2017 Michael Walker |
---|---|
License | MIT |
Maintainer | Michael Walker <mike@barrucadu.co.uk> |
Stability | stable |
Portability | CPP, FlexibleInstances, ImpredicativeTypes, RankNTypes, ScopedTypeVariables, TypeSynonymInstances |
Safe Haskell | None |
Language | Haskell2010 |
This module allows using Deja Fu predicates with HUnit to test the behaviour of concurrent systems.
- testAuto :: (Eq a, Show a) => (forall t. ConcST t a) -> Test
- testDejafu :: Show a => (forall t. ConcST t a) -> String -> Predicate a -> Test
- testDejafus :: Show a => (forall t. ConcST t a) -> [(String, Predicate a)] -> Test
- testAutoWay :: (Eq a, Show a, RandomGen g) => Way g -> MemType -> (forall t. ConcST t a) -> Test
- testDejafuWay :: (Show a, RandomGen g) => Way g -> MemType -> (forall t. ConcST t a) -> String -> Predicate a -> Test
- testDejafusWay :: (Show a, RandomGen g) => Way g -> MemType -> (forall t. ConcST t a) -> [(String, Predicate a)] -> Test
- testAutoIO :: (Eq a, Show a) => ConcIO a -> Test
- testDejafuIO :: Show a => ConcIO a -> String -> Predicate a -> Test
- testDejafusIO :: Show a => ConcIO a -> [(String, Predicate a)] -> Test
- testAutoWayIO :: (Eq a, Show a, RandomGen g) => Way g -> MemType -> ConcIO a -> Test
- testDejafuWayIO :: (Show a, RandomGen g) => Way g -> MemType -> ConcIO a -> String -> Predicate a -> Test
- testDejafusWayIO :: (Show a, RandomGen g) => Way g -> MemType -> ConcIO a -> [(String, Predicate a)] -> Test
- data Way g :: * -> *
- = Systematically Bounds
- | Randomly g Int
- data Bounds :: * = Bounds {}
- data MemType :: *
Unit testing
This is supported by the Assertable
and Testable
instances for ConcST
and ConcIO
. These instances try all
executions, reporting as failures the cases which throw an
HUnitFailure
exception.
instance Testable (ConcST t ())
instance Assertable (ConcST t ())
instance Testable (ConcIO ())
instance Assertable (ConcIO ())
These instances use defaultWay
and defaultMemType
.
Property testing
Automatically test a computation. In particular, look for deadlocks, uncaught exceptions, and multiple return values.
This uses the Conc
monad for testing, which is an instance of
MonadConc
. If you need to test something which also uses
MonadIO
, use testAutoIO
.
:: Show a | |
=> (forall t. ConcST t a) | The computation to test |
-> String | The name of the test. |
-> Predicate a | The predicate to check |
-> Test |
Check that a predicate holds.
:: Show a | |
=> (forall t. ConcST t a) | The computation to test |
-> [(String, Predicate a)] | The list of predicates (with names) to check |
-> Test |
Variant of testDejafu
which takes a collection of predicates to
test. This will share work between the predicates, rather than
running the concurrent computation many times for each predicate.
:: (Eq a, Show a, RandomGen g) | |
=> Way g | How to execute the concurrent program. |
-> MemType | The memory model to use for non-synchronised |
-> (forall t. ConcST t a) | The computation to test |
-> Test |
Variant of testAuto
which tests a computation under a given
execution way and memory model.
:: (Show a, RandomGen g) | |
=> Way g | How to execute the concurrent program. |
-> MemType | The memory model to use for non-synchronised |
-> (forall t. ConcST t a) | The computation to test |
-> String | The name of the test. |
-> Predicate a | The predicate to check |
-> Test |
Variant of testDejafu
which takes a way to execute the program
and a memory model.
:: (Show a, RandomGen g) | |
=> Way g | How to execute the concurrent program. |
-> MemType | The memory model to use for non-synchronised |
-> (forall t. ConcST t a) | The computation to test |
-> [(String, Predicate a)] | The list of predicates (with names) to check |
-> Test |
Variant of testDejafus
which takes a way to execute the program
and a memory model.
IO
testDejafuIO :: Show a => ConcIO a -> String -> Predicate a -> Test Source #
Variant of testDejafu
for computations which do IO
.
testDejafusIO :: Show a => ConcIO a -> [(String, Predicate a)] -> Test Source #
Variant of testDejafus
for computations which do IO
.
testAutoWayIO :: (Eq a, Show a, RandomGen g) => Way g -> MemType -> ConcIO a -> Test Source #
Variant of testAutoWay
for computations which do IO
.
testDejafuWayIO :: (Show a, RandomGen g) => Way g -> MemType -> ConcIO a -> String -> Predicate a -> Test Source #
Variant of testDejafuWay
for computations which do IO
.
testDejafusWayIO :: (Show a, RandomGen g) => Way g -> MemType -> ConcIO a -> [(String, Predicate a)] -> Test Source #
Variant of dejafusWay
for computations which do IO
.
Re-exports
How to explore the possible executions of a concurrent program.
Systematically Bounds | Systematically explore all executions within the bounds. |
Randomly g Int | Explore a fixed number of random executions, with the given PRNG. |
The memory model to use for non-synchronised CRef
operations.
SequentialConsistency | The most intuitive model: a program behaves as a simple
interleaving of the actions in different threads. When a |
TotalStoreOrder | Each thread has a write buffer. A thread sees its writes immediately, but other threads will only see writes when they are committed, which may happen later. Writes are committed in the same order that they are created. |
PartialStoreOrder | Each |