module Test.DejaFu.Conc
(
Program
, Basic
, ConcT
, ConcIO
, WithSetup
, WithSetupAndTeardown
, withSetup
, withTeardown
, withSetupAndTeardown
, Invariant
, registerInvariant
, inspectIORef
, inspectMVar
, inspectTVar
, Snapshot
, MemType(..)
, runConcurrent
, recordSnapshot
, runSnapshot
, module Test.DejaFu.Schedule
, Condition(..)
, Trace
, Decision(..)
, ThreadId(..)
, ThreadAction(..)
, Lookahead(..)
, MVarId
, IORefId
, MaskingState(..)
, showTrace
, showCondition
) where
import Control.Exception (MaskingState(..))
import Control.Monad (void)
import Test.DejaFu.Conc.Internal.Common
import Test.DejaFu.Conc.Internal.Program
import Test.DejaFu.Conc.Internal.STM (ModelTVar)
import Test.DejaFu.Schedule
import Test.DejaFu.Types
import Test.DejaFu.Utils
type ConcT = Program Basic
type ConcIO = ConcT IO
withSetup
:: Program Basic n x
-> (x -> Program Basic n a)
-> Program (WithSetup x) n a
withSetup :: forall (n :: * -> *) x a.
Program Basic n x
-> (x -> Program Basic n a) -> Program (WithSetup x) n a
withSetup Program Basic n x
setup x -> Program Basic n a
p = WithSetup
{ wsSetup :: Program Basic n x
wsSetup = Program Basic n x
setup
, wsProgram :: x -> Program Basic n a
wsProgram = x -> Program Basic n a
p
}
withTeardown
:: (x -> Either Condition y -> Program Basic n a)
-> Program (WithSetup x) n y
-> Program (WithSetupAndTeardown x y) n a
withTeardown :: forall x y (n :: * -> *) a.
(x -> Either Condition y -> Program Basic n a)
-> Program (WithSetup x) n y
-> Program (WithSetupAndTeardown x y) n a
withTeardown x -> Either Condition y -> Program Basic n a
teardown Program (WithSetup x) n y
ws = WithSetupAndTeardown
{ wstSetup :: ModelConc n x
wstSetup = forall (n :: * -> *) x a.
Program (WithSetup x) n a -> ModelConc n x
wsSetup Program (WithSetup x) n y
ws
, wstProgram :: x -> ModelConc n y
wstProgram = forall (n :: * -> *) x a.
Program (WithSetup x) n a -> x -> ModelConc n a
wsProgram Program (WithSetup x) n y
ws
, wstTeardown :: x -> Either Condition y -> Program Basic n a
wstTeardown = x -> Either Condition y -> Program Basic n a
teardown
}
withSetupAndTeardown
:: Program Basic n x
-> (x -> Either Condition y -> Program Basic n a)
-> (x -> Program Basic n y)
-> Program (WithSetupAndTeardown x y) n a
withSetupAndTeardown :: forall (n :: * -> *) x y a.
Program Basic n x
-> (x -> Either Condition y -> Program Basic n a)
-> (x -> Program Basic n y)
-> Program (WithSetupAndTeardown x y) n a
withSetupAndTeardown Program Basic n x
setup x -> Either Condition y -> Program Basic n a
teardown =
forall x y (n :: * -> *) a.
(x -> Either Condition y -> Program Basic n a)
-> Program (WithSetup x) n y
-> Program (WithSetupAndTeardown x y) n a
withTeardown x -> Either Condition y -> Program Basic n a
teardown forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (n :: * -> *) x a.
Program Basic n x
-> (x -> Program Basic n a) -> Program (WithSetup x) n a
withSetup Program Basic n x
setup
registerInvariant :: Invariant n a -> Program Basic n ()
registerInvariant :: forall (n :: * -> *) a. Invariant n a -> Program Basic n ()
registerInvariant Invariant n a
inv = forall a (n :: * -> *).
((a -> Action n) -> Action n) -> Program Basic n a
ModelConc (\() -> Action n
c -> forall (n :: * -> *). Invariant n () -> Action n -> Action n
ANewInvariant (forall (f :: * -> *) a. Functor f => f a -> f ()
void Invariant n a
inv) (() -> Action n
c ()))
inspectIORef :: ModelIORef n a -> Invariant n a
inspectIORef :: forall (n :: * -> *) a. ModelIORef n a -> Invariant n a
inspectIORef = forall (n :: * -> *) a.
((a -> IAction n) -> IAction n) -> Invariant n a
Invariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (n :: * -> *) a.
ModelIORef n a -> (a -> IAction n) -> IAction n
IInspectIORef
inspectMVar :: ModelMVar n a -> Invariant n (Maybe a)
inspectMVar :: forall (n :: * -> *) a. ModelMVar n a -> Invariant n (Maybe a)
inspectMVar = forall (n :: * -> *) a.
((a -> IAction n) -> IAction n) -> Invariant n a
Invariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (n :: * -> *) a.
ModelMVar n a -> (Maybe a -> IAction n) -> IAction n
IInspectMVar
inspectTVar :: ModelTVar n a -> Invariant n a
inspectTVar :: forall (n :: * -> *) a. ModelTVar n a -> Invariant n a
inspectTVar = forall (n :: * -> *) a.
((a -> IAction n) -> IAction n) -> Invariant n a
Invariant forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (n :: * -> *) a.
ModelTVar n a -> (a -> IAction n) -> IAction n
IInspectTVar