packages feed

hunit-dejafu 0.5.0.0 → 0.6.0.0

raw patch · 3 files changed

+103/−19 lines, 3 filesdep ~dejafuPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: dejafu

API changes (from Hackage documentation)

- Test.HUnit.DejaFu: [Randomly] :: Way
- Test.HUnit.DejaFu: [Systematically] :: Way
+ Test.HUnit.DejaFu: (->-) :: Ord o => Sig s1 o x -> Sig s2 o x -> RefinementProperty o x
+ Test.HUnit.DejaFu: (===) :: Ord o => Sig s1 o x -> Sig s2 o x -> RefinementProperty o x
+ Test.HUnit.DejaFu: (=>=) :: Ord o => Sig s1 o x -> Sig s2 o x -> RefinementProperty o x
+ Test.HUnit.DejaFu: Sig :: (x -> ConcIO s) -> (s -> x -> ConcIO o) -> (s -> x -> ConcIO ()) -> (s -> ConcIO ()) -> Sig s o x
+ Test.HUnit.DejaFu: [expression] :: Sig s o x -> s -> ConcIO ()
+ Test.HUnit.DejaFu: [initialise] :: Sig s o x -> x -> ConcIO s
+ Test.HUnit.DejaFu: [interfere] :: Sig s o x -> s -> x -> ConcIO ()
+ Test.HUnit.DejaFu: [observe] :: Sig s o x -> s -> x -> ConcIO o
+ Test.HUnit.DejaFu: class Listable a
+ Test.HUnit.DejaFu: class Testable a where type O a :: * type X a :: * where {
+ Test.HUnit.DejaFu: data RefinementProperty o x :: * -> * -> *
+ Test.HUnit.DejaFu: data Sig s o x :: * -> * -> * -> *
+ Test.HUnit.DejaFu: defaultBounds :: Bounds
+ Test.HUnit.DejaFu: defaultMemType :: MemType
+ Test.HUnit.DejaFu: defaultWay :: Way
+ Test.HUnit.DejaFu: equivalentTo :: Ord o => Sig s1 o x -> Sig s2 o x -> RefinementProperty o x
+ Test.HUnit.DejaFu: expectFailure :: RefinementProperty o x -> RefinementProperty o x
+ Test.HUnit.DejaFu: list :: Listable a => [a]
+ Test.HUnit.DejaFu: randomly :: RandomGen g => g -> Int -> Way
+ Test.HUnit.DejaFu: refines :: Ord o => Sig s1 o x -> Sig s2 o x -> RefinementProperty o x
+ Test.HUnit.DejaFu: strictlyRefines :: Ord o => Sig s1 o x -> Sig s2 o x -> RefinementProperty o x
+ Test.HUnit.DejaFu: swarmy :: RandomGen g => g -> Int -> Int -> Way
+ Test.HUnit.DejaFu: systematically :: Bounds -> Way
+ Test.HUnit.DejaFu: testProperty :: (Testable p, Listable (X p), Eq (X p), Show (X p), Show (O p)) => String -> p -> Test
+ Test.HUnit.DejaFu: tiers :: Listable a => [[a]]
+ Test.HUnit.DejaFu: type family X a :: *;
+ Test.HUnit.DejaFu: uniformly :: RandomGen g => g -> Int -> Way
+ Test.HUnit.DejaFu: }

Files

CHANGELOG.markdown view
@@ -7,6 +7,33 @@ *de facto* standard Haskell versioning scheme.  +0.6.0.0 [2017-06-07] (git tag: [hunit-dejafu-0.6.0.0][])+-------++https://hackage.haskell.org/package/hunit-dejafu-0.6.0.0++### Test.HUnit.DejaFu++- The refinement property testing functionality of dejafu is exposed in the new `testProperty`+  function, and re-exported values.+- Due to changes in dejafu, the `Way` type is now abstract and exposes smart constructor functions:+    - `systematically`, corresponding to the old `Systematically`.+    - `randomly`, corresponding to the old `Randomly`.+    - `uniformly`, a new uniform random (as opposed to weighted random) scheduler.+    - `swarmy`, corresponding to the old `Randomly` and specifying how many executions to use the+      same weights for.+- The `defaultWay`, `defaultMemType`, and `defaultBounds` values are all now re-exported.++### Miscellaneous++- Only dejafu 0.7 is supported.++[hunit-dejafu-0.6.0.0]: https://github.com/barrucadu/dejafu/releases/tag/hunit-dejafu-0.6.0.0+++---------------------------------------------------------------------------------------------------++ 0.5.0.0 [2017-04-08] (git tag: [hunit-dejafu-0.5.0.0][]) ------- 
Test/HUnit/DejaFu.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -16,7 +17,7 @@ -- License     : MIT -- Maintainer  : Michael Walker <mike@barrucadu.co.uk> -- Stability   : stable--- Portability : CPP, FlexibleInstances, ImpredicativeTypes, RankNTypes, ScopedTypeVariables, TypeSynonymInstances+-- Portability : CPP, FlexibleContexts, FlexibleInstances, ImpredicativeTypes, RankNTypes, ScopedTypeVariables, TypeSynonymInstances -- -- This module allows using Deja Fu predicates with HUnit to test the -- behaviour of concurrent systems.@@ -35,7 +36,7 @@   --   -- These instances use 'defaultWay' and 'defaultMemType'. -  -- * Property testing+  -- * Unit testing     testAuto   , testDejafu   , testDejafus@@ -53,25 +54,47 @@   , testDejafuWayIO   , testDejafusWayIO -  -- * Re-exports-  , Way(..)+  -- ** Re-exports+  , Way+  , defaultWay+  , systematically+  , randomly+  , uniformly+  , swarmy   , Bounds(..)+  , defaultBounds   , MemType(..)+  , defaultMemType++  -- * Refinement property testing+  , testProperty++  -- ** Re-exports+  , R.Sig(..)+  , R.RefinementProperty+  , R.Testable(..)+  , R.Listable(..)+  , R.expectFailure+  , R.refines, (R.=>=)+  , R.strictlyRefines, (R.->-)+  , R.equivalentTo, (R.===)   ) where -import           Control.Monad.Catch (try)-import           Control.Monad.ST    (runST)-import           Data.List           (intercalate, intersperse)-import           Test.DejaFu-import qualified Test.DejaFu.Conc    as Conc-import qualified Test.DejaFu.SCT     as SCT-import           Test.HUnit          (Assertable(..), Test(..), Testable(..),-                                      assertString)-import           Test.HUnit.Lang     (HUnitFailure(..))+import           Control.Monad.Catch    (try)+import           Control.Monad.ST       (runST)+import qualified Data.Foldable          as F+import           Data.List              (intercalate, intersperse)+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+import           Test.HUnit             (Assertable(..), Test(..), Testable(..),+                                         assertFailure, assertString)+import           Test.HUnit.Lang        (HUnitFailure(..))  -- Can't put the necessary forall in the @Assertable Conc.ConcST t@ -- instance :(-import           Unsafe.Coerce       (unsafeCoerce)+import           Unsafe.Coerce          (unsafeCoerce)  runSCTst :: Way -> MemType -> (forall t. Conc.ConcST t a) -> [(Either Failure a, Conc.Trace)] runSCTst way memtype conc = runST (SCT.runSCT way memtype conc)@@ -80,7 +103,7 @@ runSCTio = SCT.runSCT  ----------------------------------------------------------------------------------- Unit testing+-- HUnit-style unit testing  -- | @since 0.3.0.0 instance Testable (Conc.ConcST t ()) where@@ -114,8 +137,9 @@   Right (Left HUnitFailure {}) -> False   _ -> True + ----------------------------------------------------------------------------------- Property testing+-- DejaFu-style unit testing  -- | Automatically test a computation. In particular, look for -- deadlocks, uncaught exceptions, and multiple return values.@@ -256,6 +280,23 @@   => Way -> MemType -> Conc.ConcIO a -> [(String, Predicate a)] -> Test testDejafusWayIO = testio ++-------------------------------------------------------------------------------+-- Refinement property testing++-- | Check a refinement property with a variety of seed values and+-- variable assignments.+--+-- @since 0.6.0.0+testProperty :: (R.Testable p, R.Listable (R.X p), Eq (R.X p), Show (R.X p), Show (R.O p))+  => String+  -- ^ The name of the test.+  -> p+  -- ^ The property to check.+  -> Test+testProperty = testprop++ -------------------------------------------------------------------------------- -- HUnit integration @@ -287,6 +328,22 @@       -- test computed them).       traces <- runSCTio way memtype concio       assertString . showErr $ p traces++-- | Produce a HUnit 'Test' from a Deja Fu refinement property test.+testprop :: (R.Testable p, R.Listable (R.X p), Eq (R.X p), Show (R.X p), Show (R.O p))+  => String -> p -> Test+testprop name p = TestLabel name . TestCase $ do+  ce <- R.check' p+  case ce of+    Just c -> assertFailure . init $ unlines+      [ "*** Failure: " +++        (if null (R.failingArgs c) then "" else unwords (R.failingArgs c) ++ " ") +++        "(seed " ++ show (R.failingSeed c) ++ ")"+      , "    left:  " ++ show (F.toList $ R.leftResults  c)+      , "    right: " ++ show (F.toList $ R.rightResults c)+      ]+    Nothing -> pure ()+  -------------------------------------------------------------------------------- -- Utilities
hunit-dejafu.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                hunit-dejafu-version:             0.5.0.0+version:             0.6.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-0.5.0.0+  tag:      hunit-dejafu-0.6.0.0  library   exposed-modules:     Test.HUnit.DejaFu@@ -38,7 +38,7 @@   -- other-extensions:       build-depends:       base       >=4.8 && <5                      , exceptions >=0.7 && <0.9-                     , dejafu     >=0.6 && <0.7+                     , dejafu     >=0.7 && <0.8                      , HUnit      >=1.2 && <1.7   -- hs-source-dirs:         default-language:    Haskell2010