diff --git a/dejafu/CHANGELOG.markdown b/dejafu/CHANGELOG.markdown index 6dc392a..06a7d2c 100644 --- a/dejafu/CHANGELOG.markdown +++ b/dejafu/CHANGELOG.markdown @@ -10,6 +10,10 @@ This project is versioned according to the [Package Versioning Policy](https://p unreleased ---------- +### Test.DejaFu + +- The new Test.DejaFu.Defaults and Test.DejaFu.Refinement modules are re-exported. + ### Test.DejaFu.Defaults - The `default*` values are now defined in the new Test.DejaFu.Defaults module. There is no breaking diff --git a/dejafu/Test/DejaFu.hs b/dejafu/Test/DejaFu.hs index e6a9857..e4f6b44 100644 --- a/dejafu/Test/DejaFu.hs +++ b/dejafu/Test/DejaFu.hs @@ -240,20 +240,47 @@ module Test.DejaFu , somewhereTrue , gives , gives' + + -- * Refinement property testing + + -- | Consider this statement about @MVar@s: \"using @readMVar@ is + -- better than @takeMVar@ followed by @putMVar@ because the former + -- is atomic but the latter is not.\" + -- + -- Deja Fu can test properties like that: + -- + -- @ + -- sig e = Sig + -- { initialise = maybe newEmptyMVar newMVar + -- , observe = \\v _ -> tryReadMVar v + -- , interfere = \\v s -> tryTakeMVar v >> maybe (pure ()) (void . tryPutMVar v) s + -- , expression = e + -- } + -- + -- > check $ sig (void . readMVar) \`equivalentTo\` sig (\\v -> takeMVar v >>= putMVar v) + -- *** Failure: (seed Just ()) + -- left: [(Nothing,Just ())] + -- right: [(Nothing,Just ()),(Just Deadlock,Just ())] + -- @ + -- + -- The two expressions are not equivalent, and we get given the + -- counterexample! + , module Test.DejaFu.Refinement ) where -import Control.Arrow (first) -import Control.DeepSeq (NFData(..)) -import Control.Monad (unless, when) -import Control.Monad.Ref (MonadRef) -import Control.Monad.ST (runST) -import Data.Function (on) -import Data.List (intercalate, intersperse, minimumBy) -import Data.Ord (comparing) +import Control.Arrow (first) +import Control.DeepSeq (NFData(..)) +import Control.Monad (unless, when) +import Control.Monad.Ref (MonadRef) +import Control.Monad.ST (runST) +import Data.Function (on) +import Data.List (intercalate, intersperse, minimumBy) +import Data.Ord (comparing) import Test.DejaFu.Common import Test.DejaFu.Conc import Test.DejaFu.Defaults +import Test.DejaFu.Refinement import Test.DejaFu.SCT diff --git a/hunit-dejafu/Test/HUnit/DejaFu.hs b/hunit-dejafu/Test/HUnit/DejaFu.hs index 8a735a9..161569e 100755 --- a/hunit-dejafu/Test/HUnit/DejaFu.hs +++ b/hunit-dejafu/Test/HUnit/DejaFu.hs @@ -77,7 +77,7 @@ import Control.Monad.Catch (try) import Control.Monad.ST (runST) import qualified Data.Foldable as F import Data.List (intercalate, intersperse) -import Test.DejaFu +import Test.DejaFu hiding (Testable(..)) import qualified Test.DejaFu.Conc as Conc import qualified Test.DejaFu.Refinement as R import qualified Test.DejaFu.SCT as SCT diff --git a/tasty-dejafu/Test/Tasty/DejaFu.hs b/tasty-dejafu/Test/Tasty/DejaFu.hs index dd6b2eb..a064078 100755 --- a/tasty-dejafu/Test/Tasty/DejaFu.hs +++ b/tasty-dejafu/Test/Tasty/DejaFu.hs @@ -78,7 +78,7 @@ import Data.Proxy (Proxy(..)) import Data.Tagged (Tagged(..)) import Data.Typeable (Typeable) import System.Random (StdGen, mkStdGen) -import Test.DejaFu +import Test.DejaFu hiding (Testable(..)) import qualified Test.DejaFu.Conc as Conc import qualified Test.DejaFu.Refinement as R import qualified Test.DejaFu.SCT as SCT