mirror of
https://github.com/barrucadu/dejafu.git
synced 2024-11-05 06:45:08 +03:00
Change order of arguments to test functions
1. Discard function (if present) 2. Way (if present) 3. Memory type (if present) 4. Name of test 5. Predicate 6. Action For multi-predicate functions, 4 and 5 are replaced with a list.
This commit is contained in:
parent
3a534f70fa
commit
020e3967f7
@ -16,12 +16,9 @@ tests = toTestList
|
||||
\x -> if x == Right 3 then Just DiscardResultAndTrace else Nothing
|
||||
]
|
||||
where
|
||||
check name xs f = testDejafuDiscard f defaultWay defaultMemType nondet name (gives' xs)
|
||||
|
||||
nondet :: MonadConc m => m Int
|
||||
nondet = do
|
||||
mvar <- newEmptyMVar
|
||||
_ <- fork $ putMVar mvar 1
|
||||
_ <- fork $ putMVar mvar 2
|
||||
_ <- fork $ putMVar mvar 3
|
||||
readMVar mvar
|
||||
check name xs f = testDejafuDiscard f defaultWay defaultMemType name (gives' xs) $ do
|
||||
mvar <- newEmptyMVar
|
||||
_ <- fork $ putMVar mvar 1
|
||||
_ <- fork $ putMVar mvar 2
|
||||
_ <- fork $ putMVar mvar 3
|
||||
readMVar mvar
|
||||
|
@ -48,9 +48,9 @@ tests =
|
||||
|
||||
litmusTest :: (Eq a, Show a) => String -> ConcIO a -> [a] -> [a] -> [a] -> Test
|
||||
litmusTest name act sq tso pso = testGroup name . hUnitTestToTests $ test
|
||||
[ testDejafuWay defaultWay SequentialConsistency act "SQ" (gives' sq)
|
||||
, testDejafuWay defaultWay TotalStoreOrder act "TSO" (gives' tso)
|
||||
, testDejafuWay defaultWay PartialStoreOrder act "PSO" (gives' pso)
|
||||
[ testDejafuWay defaultWay SequentialConsistency "SQ" (gives' sq) act
|
||||
, testDejafuWay defaultWay TotalStoreOrder "TSO" (gives' tso) act
|
||||
, testDejafuWay defaultWay PartialStoreOrder "PSO" (gives' pso) act
|
||||
]
|
||||
|
||||
-- | Run a litmus test against the three different memory models, and
|
||||
|
@ -34,7 +34,7 @@ instance IsTest TH.Test where
|
||||
instance IsTest T where
|
||||
toTestList (T n c p) = toTestList (BT n c p defaultBounds)
|
||||
toTestList (BT n c p b) = toTestList . testGroup n $
|
||||
let mk way name = testDejafuWay way defaultMemType c name p
|
||||
let mk way name = testDejafuWay way defaultMemType name p c
|
||||
g = mkStdGen 0
|
||||
in [ mk (systematically b) "systematically"
|
||||
, mk (uniformly g 100) "uniformly"
|
||||
@ -53,7 +53,7 @@ testGroup :: IsTest t => String -> t -> TF.Test
|
||||
testGroup name = TF.testGroup name . toTestList
|
||||
|
||||
djfu :: Show a => String -> Predicate a -> ConcIO a -> TF.Test
|
||||
djfu name p c = hunitTest $ testDejafu c name p
|
||||
djfu name p c = hunitTest $ testDejafu name p c
|
||||
|
||||
djfuT :: Show a => String -> Predicate a -> ConcIO a -> [TF.Test]
|
||||
djfuT name p c = toTestList $ T name c p
|
||||
|
@ -12,8 +12,8 @@ import Test.HUnit.DejaFu
|
||||
|
||||
tests :: [Test]
|
||||
tests = hUnitTestToTests $ test
|
||||
[ testDejafuWay way defaultMemType (philosophers 3) "deadlocks" deadlocksSometimes
|
||||
, testDejafuWay way defaultMemType (philosophers 3) "loops" abortsSometimes
|
||||
[ testDejafuWay way defaultMemType "deadlocks" deadlocksSometimes (philosophers 3)
|
||||
, testDejafuWay way defaultMemType "loops" abortsSometimes (philosophers 3)
|
||||
]
|
||||
|
||||
-- | Shorter execution length bound
|
||||
|
@ -34,7 +34,7 @@ import Examples.SearchParty.Impredicative
|
||||
|
||||
tests :: [Test]
|
||||
tests = hUnitTestToTests $ test
|
||||
[ testDejafu concFilter "concurrent filter" (failing checkResultLists)
|
||||
[ testDejafu "concurrent filter" (failing checkResultLists) concFilter
|
||||
]
|
||||
|
||||
-- | Filter a list concurrently.
|
||||
|
@ -20,6 +20,8 @@ This project is versioned according to the [Package Versioning Policy](https://p
|
||||
|
||||
It is no longer possible to test things in `ST`.
|
||||
|
||||
- All testing functions now take the action to test as the last parameter.
|
||||
|
||||
- The `autocheckIO`, `dejafuIO`, `dejafusIO`, `autocheckWayIO`, `dejafuWayIO`, `dejafusWayIO`,
|
||||
`dejafuDiscardIO`, `runTestM`, and `runTestWayM` functions are now gone.
|
||||
|
||||
|
@ -337,8 +337,7 @@ autocheckWay :: (MonadConc n, MonadIO n, MonadRef r n, Eq a, Show a)
|
||||
-> ConcT r n a
|
||||
-- ^ The computation to test
|
||||
-> n Bool
|
||||
autocheckWay way memtype conc =
|
||||
dejafusWay way memtype conc autocheckCases
|
||||
autocheckWay way memtype = dejafusWay way memtype autocheckCases
|
||||
|
||||
-- | Predicates for the various autocheck functions.
|
||||
autocheckCases :: Eq a => [(String, Predicate a)]
|
||||
@ -353,10 +352,12 @@ autocheckCases =
|
||||
--
|
||||
-- @since 1.0.0.0
|
||||
dejafu :: (MonadConc n, MonadIO n, MonadRef r n, Show b)
|
||||
=> ConcT r n a
|
||||
=> String
|
||||
-- ^ The name of the test
|
||||
-> ProPredicate a b
|
||||
-- ^ The predicate to check
|
||||
-> ConcT r n a
|
||||
-- ^ The computation to test
|
||||
-> (String, ProPredicate a b)
|
||||
-- ^ The predicate (with a name) to check
|
||||
-> n Bool
|
||||
dejafu = dejafuWay defaultWay defaultMemType
|
||||
|
||||
@ -369,10 +370,12 @@ dejafuWay :: (MonadConc n, MonadIO n, MonadRef r n, Show b)
|
||||
-- ^ How to run the concurrent program.
|
||||
-> MemType
|
||||
-- ^ The memory model to use for non-synchronised @CRef@ operations.
|
||||
-> String
|
||||
-- ^ The name of the test
|
||||
-> ProPredicate a b
|
||||
-- ^ The predicate to check
|
||||
-> ConcT r n a
|
||||
-- ^ The computation to test
|
||||
-> (String, ProPredicate a b)
|
||||
-- ^ The predicate (with a name) to check
|
||||
-> n Bool
|
||||
dejafuWay = dejafuDiscard (const Nothing)
|
||||
|
||||
@ -386,12 +389,14 @@ dejafuDiscard :: (MonadConc n, MonadIO n, MonadRef r n, Show b)
|
||||
-- ^ How to run the concurrent program.
|
||||
-> MemType
|
||||
-- ^ The memory model to use for non-synchronised @CRef@ operations.
|
||||
-> String
|
||||
-- ^ The name of the test
|
||||
-> ProPredicate a b
|
||||
-- ^ The predicate to check
|
||||
-> ConcT r n a
|
||||
-- ^ The computation to test
|
||||
-> (String, ProPredicate a b)
|
||||
-- ^ The predicate (with a name) to check
|
||||
-> n Bool
|
||||
dejafuDiscard discard way memtype conc (name, test) = do
|
||||
dejafuDiscard discard way memtype name test conc = do
|
||||
let discarder = strengthenDiscard discard (pdiscard test)
|
||||
traces <- runSCTDiscard discarder way memtype conc
|
||||
liftIO $ doTest name (peval test traces)
|
||||
@ -401,10 +406,10 @@ dejafuDiscard discard way memtype conc (name, test) = do
|
||||
--
|
||||
-- @since 1.0.0.0
|
||||
dejafus :: (MonadConc n, MonadIO n, MonadRef r n, Show b)
|
||||
=> ConcT r n a
|
||||
-- ^ The computation to test
|
||||
-> [(String, ProPredicate a b)]
|
||||
=> [(String, ProPredicate a b)]
|
||||
-- ^ The list of predicates (with names) to check
|
||||
-> ConcT r n a
|
||||
-- ^ The computation to test
|
||||
-> n Bool
|
||||
dejafus = dejafusWay defaultWay defaultMemType
|
||||
|
||||
@ -417,12 +422,12 @@ dejafusWay :: (MonadConc n, MonadIO n, MonadRef r n, Show b)
|
||||
-- ^ How to run the concurrent program.
|
||||
-> MemType
|
||||
-- ^ The memory model to use for non-synchronised @CRef@ operations.
|
||||
-> ConcT r n a
|
||||
-- ^ The computation to test
|
||||
-> [(String, ProPredicate a b)]
|
||||
-- ^ The list of predicates (with names) to check
|
||||
-> ConcT r n a
|
||||
-- ^ The computation to test
|
||||
-> n Bool
|
||||
dejafusWay way memtype conc tests = do
|
||||
dejafusWay way memtype tests conc = do
|
||||
traces <- runSCTDiscard discarder way memtype conc
|
||||
results <- mapM (\(name, test) -> liftIO . doTest name $ check test traces) tests
|
||||
pure (and results)
|
||||
|
@ -19,6 +19,7 @@ This project is versioned according to the [Package Versioning Policy](https://p
|
||||
- The `ConcST` functions have been removed and replaced by the `ConcIO` functions.
|
||||
- The `Testable` and `Assertable` instances for `ConcST t ()` are gone.
|
||||
- All test functions are generalised to take a `ProPredicate`.
|
||||
- All test functions now take the action to test as the last parameter.
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
|
@ -122,8 +122,7 @@ testAutoWay :: (Eq a, Show a)
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> Test
|
||||
testAutoWay way memtype conc =
|
||||
testDejafusWay way memtype conc autocheckCases
|
||||
testAutoWay way memtype = testDejafusWay way memtype autocheckCases
|
||||
|
||||
-- | Predicates for the various autocheck functions.
|
||||
autocheckCases :: Eq a => [(String, Predicate a)]
|
||||
@ -137,12 +136,12 @@ autocheckCases =
|
||||
--
|
||||
-- @since 1.0.0.0
|
||||
testDejafu :: Show b
|
||||
=> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> String
|
||||
-- ^ The name of the test.
|
||||
=> String
|
||||
-- ^ The name of the test
|
||||
-> ProPredicate a b
|
||||
-- ^ The predicate to check
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> Test
|
||||
testDejafu = testDejafuWay defaultWay defaultMemType
|
||||
|
||||
@ -155,12 +154,12 @@ testDejafuWay :: Show b
|
||||
-- ^ How to execute the concurrent program.
|
||||
-> MemType
|
||||
-- ^ The memory model to use for non-synchronised @CRef@ operations.
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> String
|
||||
-- ^ The name of the test.
|
||||
-> ProPredicate a b
|
||||
-- ^ The predicate to check
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> Test
|
||||
testDejafuWay = testDejafuDiscard (const Nothing)
|
||||
|
||||
@ -174,15 +173,15 @@ testDejafuDiscard :: Show b
|
||||
-- ^ How to execute the concurrent program.
|
||||
-> MemType
|
||||
-- ^ The memory model to use for non-synchronised @CRef@ operations.
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> String
|
||||
-- ^ The name of the test.
|
||||
-> ProPredicate a b
|
||||
-- ^ The predicate to check
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> Test
|
||||
testDejafuDiscard discard way memtype conc name test =
|
||||
testconc discard way memtype conc [(name, test)]
|
||||
testDejafuDiscard discard way memtype name test =
|
||||
testconc discard way memtype [(name, test)]
|
||||
|
||||
-- | Variant of 'testDejafu' which takes a collection of predicates to
|
||||
-- test. This will share work between the predicates, rather than
|
||||
@ -190,10 +189,10 @@ testDejafuDiscard discard way memtype conc name test =
|
||||
--
|
||||
-- @since 1.0.0.0
|
||||
testDejafus :: Show b
|
||||
=> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> [(String, ProPredicate a b)]
|
||||
=> [(String, ProPredicate a b)]
|
||||
-- ^ The list of predicates (with names) to check
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> Test
|
||||
testDejafus = testDejafusWay defaultWay defaultMemType
|
||||
|
||||
@ -206,10 +205,10 @@ testDejafusWay :: Show b
|
||||
-- ^ How to execute the concurrent program.
|
||||
-> MemType
|
||||
-- ^ The memory model to use for non-synchronised @CRef@ operations.
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> [(String, ProPredicate a b)]
|
||||
-- ^ The list of predicates (with names) to check
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> Test
|
||||
testDejafusWay = testconc (const Nothing)
|
||||
|
||||
@ -256,10 +255,10 @@ testconc :: Show b
|
||||
=> (Either Failure a -> Maybe Discard)
|
||||
-> Way
|
||||
-> MemType
|
||||
-> Conc.ConcIO a
|
||||
-> [(String, ProPredicate a b)]
|
||||
-> Conc.ConcIO a
|
||||
-> Test
|
||||
testconc discard way memtype concio tests = case map toTest tests of
|
||||
testconc discard way memtype tests concio = case map toTest tests of
|
||||
[t] -> t
|
||||
ts -> TestList ts
|
||||
|
||||
|
@ -19,6 +19,7 @@ This project is versioned according to the [Package Versioning Policy](https://p
|
||||
- The `ConcST` functions have been removed and replaced by the `ConcIO` functions.
|
||||
- The `IsTest` instance for `ConcST t (Maybe String)` is gone.
|
||||
- All test functions are generalised to take a `ProPredicate`.
|
||||
- All test functions now take the action to test as the last parameter.
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
|
@ -155,7 +155,7 @@ testAutoWay :: (Eq a, Show a)
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> TestTree
|
||||
testAutoWay way memtype conc = testDejafusWay way memtype conc autocheckCases
|
||||
testAutoWay way memtype = testDejafusWay way memtype autocheckCases
|
||||
|
||||
-- | Predicates for the various autocheck functions.
|
||||
autocheckCases :: Eq a => [(TestName, Predicate a)]
|
||||
@ -169,12 +169,12 @@ autocheckCases =
|
||||
--
|
||||
-- @since 1.0.0.0
|
||||
testDejafu :: Show b
|
||||
=> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> TestName
|
||||
=> TestName
|
||||
-- ^ The name of the test.
|
||||
-> ProPredicate a b
|
||||
-- ^ The predicate to check
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> TestTree
|
||||
testDejafu = testDejafuWay defaultWay defaultMemType
|
||||
|
||||
@ -187,12 +187,12 @@ testDejafuWay :: Show b
|
||||
-- ^ How to execute the concurrent program.
|
||||
-> MemType
|
||||
-- ^ The memory model to use for non-synchronised @CRef@ operations.
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> TestName
|
||||
-- ^ The name of the test.
|
||||
-> ProPredicate a b
|
||||
-- ^ The predicate to check
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> TestTree
|
||||
testDejafuWay = testDejafuDiscard (const Nothing)
|
||||
|
||||
@ -206,15 +206,15 @@ testDejafuDiscard :: Show b
|
||||
-- ^ How to execute the concurrent program.
|
||||
-> MemType
|
||||
-- ^ The memory model to use for non-synchronised @CRef@ operations.
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> String
|
||||
-- ^ The name of the test.
|
||||
-> ProPredicate a b
|
||||
-- ^ The predicate to check
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> TestTree
|
||||
testDejafuDiscard discard way memtype conc name test =
|
||||
testconc discard way memtype conc [(name, test)]
|
||||
testDejafuDiscard discard way memtype name test =
|
||||
testconc discard way memtype [(name, test)]
|
||||
|
||||
-- | Variant of 'testDejafu' which takes a collection of predicates to
|
||||
-- test. This will share work between the predicates, rather than
|
||||
@ -222,10 +222,10 @@ testDejafuDiscard discard way memtype conc name test =
|
||||
--
|
||||
-- @since 1.0.0.0
|
||||
testDejafus :: Show b
|
||||
=> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> [(TestName, ProPredicate a b)]
|
||||
=> [(TestName, ProPredicate a b)]
|
||||
-- ^ The list of predicates (with names) to check
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> TestTree
|
||||
testDejafus = testDejafusWay defaultWay defaultMemType
|
||||
|
||||
@ -238,10 +238,10 @@ testDejafusWay :: Show b
|
||||
-- ^ How to execute the concurrent program.
|
||||
-> MemType
|
||||
-- ^ The memory model to use for non-synchronised @CRef@ operations.
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> [(TestName, ProPredicate a b)]
|
||||
-- ^ The list of predicates (with names) to check
|
||||
-> Conc.ConcIO a
|
||||
-- ^ The computation to test
|
||||
-> TestTree
|
||||
testDejafusWay = testconc (const Nothing)
|
||||
|
||||
@ -319,10 +319,10 @@ testconc :: Show b
|
||||
=> (Either Failure a -> Maybe Discard)
|
||||
-> Way
|
||||
-> MemType
|
||||
-> Conc.ConcIO a
|
||||
-> [(TestName, ProPredicate a b)]
|
||||
-> Conc.ConcIO a
|
||||
-> TestTree
|
||||
testconc discard way memtype concio tests = case map toTest tests of
|
||||
testconc discard way memtype tests concio = case map toTest tests of
|
||||
[t] -> t
|
||||
ts -> testGroup "Deja Fu Tests" ts
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user