dejafu 1.6.0.0 → 1.7.0.0
raw patch · 7 files changed
+39/−66 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Test.DejaFu.Internal: [Uniform] :: RandomGen g => g -> Int -> Way
- Test.DejaFu.Internal: [Weighted] :: RandomGen g => g -> Int -> Int -> Way
- Test.DejaFu.Settings: swarmy :: RandomGen g => g -> Int -> Int -> Way
+ Test.DejaFu.Internal: [Randomly] :: RandomGen g => (g -> (Int, g)) -> g -> Int -> Way
- Test.DejaFu.SCT: sctWeightedRandom :: (MonadConc n, RandomGen g) => MemType -> g -> Int -> Int -> ConcT n a -> n [(Either Failure a, Trace)]
+ Test.DejaFu.SCT: sctWeightedRandom :: (MonadConc n, RandomGen g) => MemType -> g -> Int -> ConcT n a -> n [(Either Failure a, Trace)]
- Test.DejaFu.SCT: sctWeightedRandomDiscard :: (MonadConc n, RandomGen g) => (Either Failure a -> Maybe Discard) -> MemType -> g -> Int -> Int -> ConcT n a -> n [(Either Failure a, Trace)]
+ Test.DejaFu.SCT: sctWeightedRandomDiscard :: (MonadConc n, RandomGen g) => (Either Failure a -> Maybe Discard) -> MemType -> g -> Int -> ConcT n a -> n [(Either Failure a, Trace)]
- Test.DejaFu.SCT.Internal.Weighted: initialRandSchedState :: Maybe (Map ThreadId Int) -> g -> RandSchedState g
+ Test.DejaFu.SCT.Internal.Weighted: initialRandSchedState :: g -> RandSchedState g
Files
- CHANGELOG.rst +20/−0
- Test/DejaFu.hs +1/−2
- Test/DejaFu/Internal.hs +3/−5
- Test/DejaFu/SCT.hs +8/−26
- Test/DejaFu/SCT/Internal/Weighted.hs +2/−3
- Test/DejaFu/Settings.hs +3/−28
- dejafu.cabal +2/−2
CHANGELOG.rst view
@@ -6,6 +6,26 @@ .. _PVP: https://pvp.haskell.org/ +1.7.0.0 (2018-06-03)+--------------------++* Git: :tag:`dejafu-1.7.0.0`+* Hackage: :hackage:`dejafu-1.7.0.0`++Changed+~~~~~~~++* (:issue:`237`) ``Test.DejaFu.SCT.sctWeightedRandom`` and+ ``sctWeightedRandomDiscard`` no longer take the number of executions+ to use the same weights for as a parameter.++Removed+~~~~~~~++* (:issue:`237`) The deprecated function+ ``Test.DejaFu.Settings.swarmy``.++ 1.6.0.0 (2018-05-11) --------------------
Test/DejaFu.hs view
@@ -88,8 +88,7 @@ If you need to test things with /nondeterministc/ @IO@, see the 'autocheckWay', 'dejafuWay', and 'dejafusWay' functions: the-'randomly', 'uniformly', and 'swarmy' testing modes can cope with-nondeterminism.+'randomly' and 'uniformly' testing modes can cope with nondeterminism. -} module Test.DejaFu ( -- * Unit testing
Test/DejaFu/Internal.hs view
@@ -52,13 +52,11 @@ -- @since 0.7.0.0 data Way where Systematic :: Bounds -> Way- Weighted :: RandomGen g => g -> Int -> Int -> Way- Uniform :: RandomGen g => g -> Int -> Way+ Randomly :: RandomGen g => (g -> (Int, g)) -> g -> Int -> Way instance Show Way where- show (Systematic bs) = "Systematic (" ++ show bs ++ ")"- show (Weighted _ n t) = "Weighted <gen> " ++ show (n, t)- show (Uniform _ n) = "Uniform <gen> " ++ show n+ show (Systematic bs) = "Systematic (" ++ show bs ++ ")"+ show (Randomly _ _ n) = "Randomly <f> <gen> " ++ show n ------------------------------------------------------------------------------- -- * Identifiers
Test/DejaFu/SCT.hs view
@@ -44,7 +44,7 @@ import Data.Maybe (fromMaybe) import Data.Set (Set) import qualified Data.Set as S-import System.Random (RandomGen, randomR)+import System.Random (RandomGen) import Test.DejaFu.Conc import Test.DejaFu.Internal@@ -211,7 +211,7 @@ else (force (incorporateBacktrackSteps bpoints newDPOR), Just (res, trace)) in sct settings initial check step conc - Uniform g0 lim0 ->+ Randomly gen g0 lim0 -> let initial _ = (g0, max 0 lim0) check (_, 0) = Nothing@@ -219,25 +219,11 @@ step run _ (g, n) = do (res, s, trace) <- run- (randSched $ \g' -> (1, g'))- (initialRandSchedState Nothing g)+ (randSched gen)+ (initialRandSchedState g) pure ((schedGen s, n-1), Just (res, trace)) in sct settings initial check step conc - Weighted g0 lim0 use0 ->- let initial _ = (g0, max 0 lim0, max 1 use0, M.empty)-- check (_, 0, _, _) = Nothing- check s = Just s-- step run s (g, n, 0, _) = step run s (g, n, max 1 use0, M.empty)- step run _ (g, n, use, ws) = do- (res, s, trace) <- run- (randSched $ randomR (1, 50))- (initialRandSchedState (Just ws) g)- pure ((schedGen s, n-1, use-1, schedWeights s), Just (res, trace))- in sct settings initial check step conc- -- | A variant of 'resultsSet' which takes a 'Settings' record. -- -- @since 1.2.0.0@@ -466,7 +452,7 @@ -- -- This is not guaranteed to find all distinct results. ----- @since 1.0.0.0+-- @since 1.7.0.0 sctWeightedRandom :: (MonadConc n, RandomGen g) => MemType -- ^ The memory model to use for non-synchronised @CRef@ operations.@@ -474,8 +460,6 @@ -- ^ The random number generator. -> Int -- ^ The number of executions to perform.- -> Int- -- ^ The number of executions to use the same set of weights for. -> ConcT n a -- ^ The computation to run many times. -> n [(Either Failure a, Trace)]@@ -487,7 +471,7 @@ -- -- This is not guaranteed to find all distinct results. ----- @since 1.0.0.0+-- @since 1.7.0.0 sctWeightedRandomDiscard :: (MonadConc n, RandomGen g) => (Either Failure a -> Maybe Discard) -- ^ Selectively discard results.@@ -497,13 +481,11 @@ -- ^ The random number generator. -> Int -- ^ The number of executions to perform.- -> Int- -- ^ The number of executions to use the same set of weights for. -> ConcT n a -- ^ The computation to run many times. -> n [(Either Failure a, Trace)]-sctWeightedRandomDiscard discard memtype g lim use = runSCTWithSettings $- set ldiscard (Just discard) (fromWayAndMemType (swarmy g lim use) memtype)+sctWeightedRandomDiscard discard memtype g lim = runSCTWithSettings $+ set ldiscard (Just discard) (fromWayAndMemType (randomly g lim) memtype) {-# DEPRECATED sctWeightedRandomDiscard "Use runSCTWithSettings instead" #-} -------------------------------------------------------------------------------
Test/DejaFu/SCT/Internal/Weighted.hs view
@@ -18,7 +18,6 @@ import Data.List.NonEmpty (toList) import Data.Map.Strict (Map) import qualified Data.Map.Strict as M-import Data.Maybe (fromMaybe) import GHC.Generics (Generic) import System.Random (RandomGen, randomR) @@ -37,8 +36,8 @@ } deriving (Eq, Show, Generic, NFData) -- | Initial weighted random scheduler state.-initialRandSchedState :: Maybe (Map ThreadId Int) -> g -> RandSchedState g-initialRandSchedState = RandSchedState . fromMaybe M.empty+initialRandSchedState :: g -> RandSchedState g+initialRandSchedState = RandSchedState M.empty -- | Weighted random scheduler: assigns to each new thread a weight, -- and makes a weighted random choice out of the runnable threads at
Test/DejaFu/Settings.hs view
@@ -207,14 +207,11 @@ -- * Lens helpers , get , set-- -- * Deprecated- , swarmy ) where import Control.Applicative (Const(..)) import Data.Functor.Identity (Identity(..))-import System.Random (RandomGen)+import System.Random (RandomGen, randomR) import Test.DejaFu.Internal (Settings(..), Way(..)) import Test.DejaFu.Types@@ -288,7 +285,7 @@ -> Int -- ^ The number of executions to try. -> Way-randomly g lim = Weighted g lim 1+randomly = Randomly $ randomR (1, 50) -- | Randomly execute a program, exploring a fixed number of -- executions.@@ -305,29 +302,7 @@ -> Int -- ^ The number of executions to try. -> Way-uniformly = Uniform---- | Randomly execute a program, exploring a fixed number of--- executions.------ Threads are scheduled by a weighted random selection, where weights--- are assigned randomly on thread creation.------ This is not guaranteed to find all distinct results (unlike--- 'systematically').------ @since 0.7.0.0-swarmy :: RandomGen g- => g- -- ^ The random generator to drive the scheduling.- -> Int- -- ^ The number of executions to try.- -> Int- -- ^ The number of executions to use the thread weights for.- -> Way--- when this is removed, simplify the Weighted logic to not do re-use-swarmy = Weighted-{-# DEPRECATED swarmy "Use randomly instead. If you have a case where swarmy works better, please comment on issue #237." #-}+uniformly = Randomly $ \g -> (1, g) ------------------------------------------------------------------------------- -- Schedule bounds
dejafu.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: dejafu-version: 1.6.0.0+version: 1.7.0.0 synopsis: A library for unit-testing concurrent programs. description:@@ -33,7 +33,7 @@ source-repository this type: git location: https://github.com/barrucadu/dejafu.git- tag: dejafu-1.6.0.0+ tag: dejafu-1.7.0.0 library exposed-modules: Test.DejaFu