hunit-dejafu 1.2.1.0 → 2.0.0.0
raw patch · 3 files changed
+96/−83 lines, 3 filesdep ~dejafuPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: dejafu
API changes (from Hackage documentation)
- Test.HUnit.DejaFu: testDejafuDiscard :: Show b => (Either Condition a -> Maybe Discard) -> Way -> MemType -> String -> ProPredicate a b -> ConcIO a -> Test
- Test.HUnit.DejaFu: testDejafusDiscard :: Show b => (Either Condition a -> Maybe Discard) -> Way -> MemType -> [(String, ProPredicate a b)] -> ConcIO a -> Test
+ Test.HUnit.DejaFu: data Basic
+ Test.HUnit.DejaFu: data Invariant (n :: Type -> Type) a
+ Test.HUnit.DejaFu: data Program pty (n :: Type -> Type) a
+ Test.HUnit.DejaFu: data WithSetup x
+ Test.HUnit.DejaFu: data WithSetupAndTeardown x y
+ Test.HUnit.DejaFu: inspectIORef :: () => ModelIORef n a -> Invariant n a
+ Test.HUnit.DejaFu: inspectMVar :: () => ModelMVar n a -> Invariant n (Maybe a)
+ Test.HUnit.DejaFu: inspectTVar :: () => ModelTVar n a -> Invariant n a
+ Test.HUnit.DejaFu: registerInvariant :: () => Invariant n a -> Program Basic n ()
+ Test.HUnit.DejaFu: type ConcIO = ConcT IO
+ Test.HUnit.DejaFu: type ConcT = Program Basic
+ Test.HUnit.DejaFu: withSetup :: () => Program Basic n x -> (x -> Program Basic n a) -> Program (WithSetup x) n a
+ Test.HUnit.DejaFu: withSetupAndTeardown :: () => Program Basic n x -> (x -> Either Condition y -> Program Basic n a) -> (x -> Program Basic n y) -> Program (WithSetupAndTeardown x y) n a
+ Test.HUnit.DejaFu: withTeardown :: () => (x -> Either Condition y -> Program Basic n a) -> Program (WithSetup x) n y -> Program (WithSetupAndTeardown x y) n a
- Test.HUnit.DejaFu: testAuto :: (Eq a, Show a) => ConcIO a -> Test
+ Test.HUnit.DejaFu: testAuto :: (Eq a, Show a) => Program pty IO a -> Test
- Test.HUnit.DejaFu: testAutoWay :: (Eq a, Show a) => Way -> MemType -> ConcIO a -> Test
+ Test.HUnit.DejaFu: testAutoWay :: (Eq a, Show a) => Way -> MemType -> Program pty IO a -> Test
- Test.HUnit.DejaFu: testAutoWithSettings :: (Eq a, Show a) => Settings IO a -> ConcIO a -> Test
+ Test.HUnit.DejaFu: testAutoWithSettings :: (Eq a, Show a) => Settings IO a -> Program pty IO a -> Test
- Test.HUnit.DejaFu: testDejafu :: Show b => String -> ProPredicate a b -> ConcIO a -> Test
+ Test.HUnit.DejaFu: testDejafu :: Show b => String -> ProPredicate a b -> Program pty IO a -> Test
- Test.HUnit.DejaFu: testDejafuWay :: Show b => Way -> MemType -> String -> ProPredicate a b -> ConcIO a -> Test
+ Test.HUnit.DejaFu: testDejafuWay :: Show b => Way -> MemType -> String -> ProPredicate a b -> Program pty IO a -> Test
- Test.HUnit.DejaFu: testDejafuWithSettings :: Show b => Settings IO a -> String -> ProPredicate a b -> ConcIO a -> Test
+ Test.HUnit.DejaFu: testDejafuWithSettings :: Show b => Settings IO a -> String -> ProPredicate a b -> Program p IO a -> Test
- Test.HUnit.DejaFu: testDejafus :: Show b => [(String, ProPredicate a b)] -> ConcIO a -> Test
+ Test.HUnit.DejaFu: testDejafus :: Show b => [(String, ProPredicate a b)] -> Program pty IO a -> Test
- Test.HUnit.DejaFu: testDejafusWay :: Show b => Way -> MemType -> [(String, ProPredicate a b)] -> ConcIO a -> Test
+ Test.HUnit.DejaFu: testDejafusWay :: Show b => Way -> MemType -> [(String, ProPredicate a b)] -> Program pty IO a -> Test
- Test.HUnit.DejaFu: testDejafusWithSettings :: Show b => Settings IO a -> [(String, ProPredicate a b)] -> ConcIO a -> Test
+ Test.HUnit.DejaFu: testDejafusWithSettings :: Show b => Settings IO a -> [(String, ProPredicate a b)] -> Program pty IO a -> Test
Files
- CHANGELOG.rst +54/−0
- Test/HUnit/DejaFu.hs +39/−80
- hunit-dejafu.cabal +3/−3
CHANGELOG.rst view
@@ -7,6 +7,60 @@ .. _PVP: https://pvp.haskell.org/ +2.0.0.0 (2019-02-12)+--------------------++* Git: :tag:`hunit-dejafu-2.0.0.0`+* Hackage: :hackage:`hunit-dejafu-2.0.0.0`++Added+~~~~~++* Re-exports for the ``Program`` types and their constructors:+ * ``Test.HUnit.DejaFu.Program``+ * ``Test.HUnit.DejaFu.Basic``+ * ``Test.HUnit.DejaFu.ConcT``+ * ``Test.HUnit.DejaFu.ConcIO``+ * ``Test.HUnit.DejaFu.WithSetup``+ * ``Test.HUnit.DejaFu.WithSetupAndTeardown``+ * ``Test.HUnit.DejaFu.withSetup``+ * ``Test.HUnit.DejaFu.withTeardown``+ * ``Test.HUnit.DejaFu.withSetupAndTeardown``++* Re-exports for the ``Invariant`` type and its functions:+ * ``Test.HUnit.DejaFu.Invariant``+ * ``Test.HUnit.DejaFu.registerInvariant``+ * ``Test.HUnit.DejaFu.inspectIORef``+ * ``Test.HUnit.DejaFu.inspectMVar``+ * ``Test.HUnit.DejaFu.inspectTVar``++Changes+~~~~~~~++* Functions which took a ``ConcIO`` now take a ``Program pty IO``:+ * ``Test.HUnit.DejaFu.testAuto``+ * ``Test.HUnit.DejaFu.testAutoWay``+ * ``Test.HUnit.DejaFu.testAutoWithSettings``+ * ``Test.HUnit.DejaFu.testDejafu``+ * ``Test.HUnit.DejaFu.testDejafuWay``+ * ``Test.HUnit.DejaFu.testDejafuWithSettings``+ * ``Test.HUnit.DejaFu.testDejafus``+ * ``Test.HUnit.DejaFu.testDejafusWay``+ * ``Test.HUnit.DejaFu.testDejafusWithSettings``++Removed+~~~~~~~++* The deprecated functions:+ * ``Test.HUnit.DejaFu.testDejafuDiscard``+ * ``Test.HUnit.DejaFu.testDejafusDiscard``++Miscellaneous+~~~~~~~~~~~~~++* The lower bound on :hackage:`dejafu` is >=2.0.++ 1.2.1.0 (2019-01-20) --------------------
Test/HUnit/DejaFu.hs view
@@ -1,16 +1,14 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-}-{-# LANGUAGE TypeSynonymInstances #-} -- | -- Module : Test.HUnit.DejaFu--- Copyright : (c) 2015--2018 Michael Walker+-- Copyright : (c) 2015--2019 Michael Walker -- License : MIT -- Maintainer : Michael Walker <mike@barrucadu.co.uk> -- Stability : stable--- Portability : FlexibleContexts, FlexibleInstances, LambdaCase, TypeSynonymInstances+-- Portability : FlexibleContexts, FlexibleInstances, LambdaCase -- -- This module allows using Deja Fu predicates with HUnit to test the -- behaviour of concurrent systems.@@ -43,7 +41,24 @@ , Condition , Predicate , ProPredicate(..)+ -- *** Settings , module Test.DejaFu.Settings+ -- *** Expressing concurrent programs+ , Program+ , Basic+ , ConcT+ , ConcIO+ , WithSetup+ , WithSetupAndTeardown+ , withSetup+ , withTeardown+ , withSetupAndTeardown+ -- *** Invariants+ , Invariant+ , registerInvariant+ , inspectIORef+ , inspectMVar+ , inspectTVar -- * Refinement property testing , testProperty@@ -58,10 +73,6 @@ , R.refines, (R.=>=) , R.strictlyRefines, (R.->-) , R.equivalentTo, (R.===)-- -- * Deprecated- , testDejafuDiscard- , testDejafusDiscard ) where import Control.Monad.Catch (try)@@ -77,17 +88,6 @@ assertFailure, assertString) import Test.HUnit.Lang (HUnitFailure(..)) -showCondition :: Condition -> String-#if MIN_VERSION_dejafu(1,12,0)-showCondition = Conc.showCondition-#else--- | An alias for 'Failure'.------ @since 1.2.1.0-type Condition = Failure-showCondition = Conc.showFail-#endif- -------------------------------------------------------------------------------- -- HUnit-style unit testing @@ -113,9 +113,9 @@ -- | Automatically test a computation. In particular, look for -- deadlocks, uncaught exceptions, and multiple return values. ----- @since 1.0.0.0+-- @since 2.0.0.0 testAuto :: (Eq a, Show a)- => Conc.ConcIO a+ => Program pty IO a -- ^ The computation to test. -> Test testAuto = testAutoWithSettings defaultSettings@@ -123,24 +123,24 @@ -- | Variant of 'testAuto' which tests a computation under a given -- execution way and memory model. ----- @since 1.0.0.0+-- @since 2.0.0.0 testAutoWay :: (Eq a, Show a) => Way -- ^ How to execute the concurrent program. -> MemType -- ^ The memory model to use for non-synchronised @IORef@ operations.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> Test testAutoWay way = testAutoWithSettings . fromWayAndMemType way -- | Variant of 'testAuto' which takes a settings record. ----- @since 1.1.0.0+-- @since 2.0.0.0 testAutoWithSettings :: (Eq a, Show a) => Settings IO a -- ^ The SCT settings.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> Test testAutoWithSettings settings = testDejafusWithSettings settings@@ -151,13 +151,13 @@ -- | Check that a predicate holds. ----- @since 1.0.0.0+-- @since 2.0.0.0 testDejafu :: Show b => String -- ^ The name of the test. -> ProPredicate a b -- ^ The predicate to check.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> Test testDejafu = testDejafuWithSettings defaultSettings@@ -165,7 +165,7 @@ -- | Variant of 'testDejafu' which takes a way to execute the program -- and a memory model. ----- @since 1.0.0.0+-- @since 2.0.0.0 testDejafuWay :: Show b => Way -- ^ How to execute the concurrent program.@@ -175,14 +175,14 @@ -- ^ The name of the test. -> ProPredicate a b -- ^ The predicate to check.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> Test testDejafuWay way = testDejafuWithSettings . fromWayAndMemType way -- | Variant of 'testDejafu' which takes a settings record. ----- @since 1.1.0.0+-- @since 2.0.0.0 testDejafuWithSettings :: Show b => Settings IO a -- ^ The SCT settings.@@ -190,41 +190,20 @@ -- ^ The name of the test. -> ProPredicate a b -- ^ The predicate to check.- -> Conc.ConcIO a+ -> Program p IO a -- ^ The computation to test. -> Test testDejafuWithSettings settings name p = testDejafusWithSettings settings [(name, p)] --- | Variant of 'testDejafuWay' which can selectively discard results.------ @since 1.0.0.0-testDejafuDiscard :: Show b- => (Either Condition a -> Maybe Discard)- -- ^ Selectively discard results.- -> Way- -- ^ How to execute the concurrent program.- -> MemType- -- ^ The memory model to use for non-synchronised @IORef@ operations.- -> String- -- ^ The name of the test.- -> ProPredicate a b- -- ^ The predicate to check.- -> Conc.ConcIO a- -- ^ The computation to test.- -> Test-testDejafuDiscard discard way =- testDejafuWithSettings . set ldiscard (Just discard) . fromWayAndMemType way-{-# DEPRECATED testDejafuDiscard "Use testDejafuWithSettings instead" #-}- -- | 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 1.0.0.0+-- @since 2.0.0.0 testDejafus :: Show b => [(String, ProPredicate a b)] -- ^ The list of predicates (with names) to check.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> Test testDejafus = testDejafusWithSettings defaultSettings@@ -232,7 +211,7 @@ -- | Variant of 'testDejafus' which takes a way to execute the program -- and a memory model. ----- @since 1.0.0.0+-- @since 2.0.0.0 testDejafusWay :: Show b => Way -- ^ How to execute the concurrent program.@@ -240,45 +219,25 @@ -- ^ The memory model to use for non-synchronised @IORef@ operations. -> [(String, ProPredicate a b)] -- ^ The list of predicates (with names) to check.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> Test testDejafusWay way = testDejafusWithSettings . fromWayAndMemType way -- | Variant of 'testDejafus' which takes a settings record. ----- @since 1.1.0.0+-- @since 2.0.0.0 testDejafusWithSettings :: Show b => Settings IO a -- ^ The SCT settings. -> [(String, ProPredicate a b)] -- ^ The list of predicates (with names) to check.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> Test testDejafusWithSettings = testconc --- | Variant of 'testDejafusWay' which can selectively discard--- results, beyond what each predicate already discards.------ @since 1.0.1.0-testDejafusDiscard :: Show b- => (Either Condition a -> Maybe Discard)- -- ^ Selectively discard results.- -> Way- -- ^ How to execute the concurrent program.- -> MemType- -- ^ The memory model to use for non-synchronised @IORef@ operations.- -> [(String, ProPredicate a b)]- -- ^ The list of predicates (with names) to check.- -> Conc.ConcIO a- -- ^ The computation to test.- -> Test-testDejafusDiscard discard way =- testDejafusWithSettings . set ldiscard (Just discard) . fromWayAndMemType way-{-# DEPRECATED testDejafusDiscard "Use testDejafusWithSettings instead" #-} - ------------------------------------------------------------------------------- -- Refinement property testing @@ -320,7 +279,7 @@ testconc :: Show b => Settings IO a -> [(String, ProPredicate a b)]- -> Conc.ConcIO a+ -> Program pty IO a -> Test testconc settings tests concio = case map toTest tests of [t] -> t@@ -362,7 +321,7 @@ failures = intersperse "" . map (indent . showres) . take 5 $ _failures res - showres (r, t) = either showCondition show r ++ " " ++ Conc.showTrace t+ showres (r, t) = either Conc.showCondition show r ++ " " ++ Conc.showTrace t rest = if moreThan (_failures res) 5 then "\n\t..." else ""
hunit-dejafu.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: hunit-dejafu-version: 1.2.1.0+version: 2.0.0.0 synopsis: Deja Fu support for the HUnit test framework. description:@@ -30,7 +30,7 @@ source-repository this type: git location: https://github.com/barrucadu/dejafu.git- tag: hunit-dejafu-1.2.1.0+ tag: hunit-dejafu-2.0.0.0 library exposed-modules: Test.HUnit.DejaFu@@ -38,7 +38,7 @@ -- other-extensions: build-depends: base >=4.9 && <5 , exceptions >=0.7 && <0.11- , dejafu >=1.5 && <1.13+ , dejafu >=2.0 && <2.1 , HUnit >=1.3.1 && <1.7 -- hs-source-dirs: default-language: Haskell2010