tasty-dejafu-0.3.0.1: Deja Fu support for the Tasty test framework.

Safe HaskellNone
LanguageHaskell2010

Test.Tasty.DejaFu

Contents

Description

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

Synopsis

Unit testing

This is supported by the IsTest instances for ConcST and ConcIO. These instances try all executions, reporting as failures the cases which return a Just string.

instance Typeable t => IsTest (ConcST t (Maybe String)) instance IsTest (ConcIO (Maybe String)) instance IsOption Bounds instance IsOption MemType

Property testing

testAuto Source

Arguments

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

The computation to test

-> TestTree 

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.

testDejafu Source

Arguments

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

The computation to test

-> TestName

The name of the test.

-> Predicate a

The predicate to check

-> TestTree 

Check that a predicate holds.

testDejafus Source

Arguments

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

The computation to test

-> [(TestName, Predicate a)]

The list of predicates (with names) to check

-> TestTree 

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.

testAuto' Source

Arguments

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

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

-> (forall t. ConcST t a)

The computation to test

-> TestTree 

Variant of testAuto which tests a computation under a given memory model.

testDejafu' Source

Arguments

:: Show a 
=> MemType

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

-> Bounds

The schedule bounds.

-> (forall t. ConcST t a)

The computation to test

-> TestName

The name of the test.

-> Predicate a

The predicate to check

-> TestTree 

Variant of testDejafu which takes a memory model and pre-emption bound.

testDejafus' Source

Arguments

:: Show a 
=> MemType

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

-> Bounds

The schedule bounds.

-> (forall t. ConcST t a)

The computation to test

-> [(TestName, Predicate a)]

The list of predicates (with names) to check

-> TestTree 

Variant of testDejafus which takes a memory model and pre-emption bound.

IO

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

Variant of testAuto for computations which do IO.

testDejafuIO :: Show a => ConcIO a -> TestName -> Predicate a -> TestTree Source

Variant of testDejafu for computations which do IO.

testDejafusIO :: Show a => ConcIO a -> [(TestName, Predicate a)] -> TestTree Source

Variant of testDejafus for computations which do IO.

testAutoIO' :: (Eq a, Show a) => MemType -> ConcIO a -> TestTree Source

Variant of testAuto' for computations which do IO.

testDejafuIO' :: Show a => MemType -> Bounds -> ConcIO a -> TestName -> Predicate a -> TestTree Source

Variant of testDejafu' for computations which do IO.

testDejafusIO' :: Show a => MemType -> Bounds -> ConcIO a -> [(TestName, Predicate a)] -> TestTree Source

Variant of dejafus' for computations which do IO.

Re-exports

data MemType :: *

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

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.