hunit-dejafu-0.5.0.0: Deja Fu support for the HUnit test framework.

Copyright(c) 2017 Michael Walker
LicenseMIT
MaintainerMichael Walker <mike@barrucadu.co.uk>
Stabilitystable
PortabilityCPP, FlexibleInstances, ImpredicativeTypes, RankNTypes, ScopedTypeVariables, TypeSynonymInstances
Safe HaskellNone
LanguageHaskell2010

Test.HUnit.DejaFu

Contents

Description

This module allows using Deja Fu predicates with HUnit to test the behaviour of concurrent systems.

Synopsis

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

testAuto Source #

Arguments

:: (Eq a, Show a) 
=> (forall t. ConcST t a)

The computation to test

-> Test 

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.

Since: 0.2.0.0

testDejafu Source #

Arguments

:: 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.

Since: 0.2.0.0

testDejafus Source #

Arguments

:: 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.

Since: 0.2.0.0

testAutoWay Source #

Arguments

:: (Eq a, Show a) 
=> Way

How to execute the concurrent program.

-> MemType

The memory model to use for non-synchronised CRef operations.

-> (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.

Since: 0.5.0.0

testDejafuWay Source #

Arguments

:: Show a 
=> Way

How to execute the concurrent program.

-> MemType

The memory model to use for non-synchronised CRef operations.

-> (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.

Since: 0.5.0.0

testDejafusWay Source #

Arguments

:: Show a 
=> Way

How to execute the concurrent program.

-> MemType

The memory model to use for non-synchronised CRef operations.

-> (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.

Since: 0.5.0.0

IO

testAutoIO :: (Eq a, Show a) => ConcIO a -> Test Source #

Variant of testAuto for computations which do IO.

Since: 0.2.0.0

testDejafuIO :: Show a => ConcIO a -> String -> Predicate a -> Test Source #

Variant of testDejafu for computations which do IO.

Since: 0.2.0.0

testDejafusIO :: Show a => ConcIO a -> [(String, Predicate a)] -> Test Source #

Variant of testDejafus for computations which do IO.

Since: 0.2.0.0

testAutoWayIO :: (Eq a, Show a) => Way -> MemType -> ConcIO a -> Test Source #

Variant of testAutoWay for computations which do IO.

Since: 0.5.0.0

testDejafuWayIO :: Show a => Way -> MemType -> ConcIO a -> String -> Predicate a -> Test Source #

Variant of testDejafuWay for computations which do IO.

Since: 0.5.0.0

testDejafusWayIO :: Show a => Way -> MemType -> ConcIO a -> [(String, Predicate a)] -> Test Source #

Variant of dejafusWay for computations which do IO.

Since: 0.5.0.0

Re-exports

data Way :: * where #

How to explore the possible executions of a concurrent program:

  • Systematically explore all executions within the bounds; or
  • Explore a fixed number of random executions, with the given PRNG.

Since: 0.6.0.0

Constructors

Systematically :: Way 
Randomly :: Way 

Instances

Show Way 

Methods

showsPrec :: Int -> Way -> ShowS #

show :: Way -> String #

showList :: [Way] -> ShowS #

data MemType :: * #

The memory model to use for non-synchronised CRef operations.

Since: 0.4.0.0

Constructors

SequentialConsistency

The most intuitive model: a program behaves as a simple interleaving of the actions in different threads. When a CRef is written to, that write is immediately visible to all threads.

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 CRef 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 to different CRefs are not necessarily committed in the same order that they are created.

Orphan instances

Assertable (ConcIO ()) Source #

Since: 0.3.0.0

Methods

assert :: ConcIO () -> Assertion #

Testable (ConcIO ()) Source #

Since: 0.3.0.0

Methods

test :: ConcIO () -> Test #

Assertable (ConcST t ()) Source #

Since: 0.3.0.0

Methods

assert :: ConcST t () -> Assertion #

Testable (ConcST t ()) Source #

Since: 0.3.0.0

Methods

test :: ConcST t () -> Test #