checkers 0.5.6 → 0.5.7
raw patch · 5 files changed
+68/−21 lines, 5 filesdep −semigroupsdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: semigroups
Dependency ranges changed: base
API changes (from Hackage documentation)
- Test.QuickCheck.Instances.Array: instance (GHC.Arr.Ix a, GHC.Real.Integral a, Test.QuickCheck.Arbitrary.Arbitrary b) => Test.QuickCheck.Arbitrary.Arbitrary (GHC.Arr.Array a b)
- Test.QuickCheck.Instances.Array: instance (GHC.Arr.Ix a, Test.QuickCheck.Arbitrary.CoArbitrary b) => Test.QuickCheck.Arbitrary.CoArbitrary (GHC.Arr.Array a b)
+ Test.QuickCheck.Classes: bifoldable :: forall p a b c m. (Bifoldable p, Monoid m, Show (p a b), Show (p m m), Arbitrary (p a b), Arbitrary (p m m), Arbitrary m, CoArbitrary a, CoArbitrary b, EqProp m, EqProp c, CoArbitrary c, Arbitrary c, Show c) => p a (b, c, m) -> TestBatch
+ Test.QuickCheck.Classes: bifoldableBifunctor :: forall p a b m. (Bifoldable p, Bifunctor p, Monoid m, Show (p a b), Arbitrary (p a b), Arbitrary m, CoArbitrary a, CoArbitrary b, EqProp m) => p a (b, m) -> TestBatch
+ Test.QuickCheck.Instances.Array: instance (GHC.Ix.Ix a, GHC.Real.Integral a, Test.QuickCheck.Arbitrary.Arbitrary b) => Test.QuickCheck.Arbitrary.Arbitrary (GHC.Arr.Array a b)
+ Test.QuickCheck.Instances.Array: instance (GHC.Ix.Ix a, Test.QuickCheck.Arbitrary.CoArbitrary b) => Test.QuickCheck.Arbitrary.CoArbitrary (GHC.Arr.Array a b)
Files
- CHANGELOG.md +9/−0
- README.md +2/−0
- checkers.cabal +8/−11
- src/Test/QuickCheck/Checkers.hs +9/−9
- src/Test/QuickCheck/Classes.hs +40/−1
+ CHANGELOG.md view
@@ -0,0 +1,9 @@+## [0.5.7]++* [Add `bifoldable` and `bifoldableBifunctor` tests](https://github.com/haskell-checkers/checkers/pull/62)++* [Restore `verboseBatch` functionality](https://github.com/haskell-checkers/checkers/pull/59)++* [Drop support for GHC < 8.2](https://github.com/haskell-checkers/checkers/pull/63)++[0.5.7]: https://github.com/haskell-checkers/checkers/compare/v0.5.6...v0.5.7
+ README.md view
@@ -0,0 +1,2 @@+**checkers** is a library for reusable QuickCheck properties, particularly for standard type classes (class laws and [class morphisms](http://conal.net/papers/type-class-morphisms)).+Checkers also has lots of support for randomly generating data values (thanks to Thomas Davie).
checkers.cabal view
@@ -1,5 +1,5 @@ Name: checkers-Version: 0.5.6+Version: 0.5.7 Cabal-Version: >= 1.10 Synopsis: Check properties on standard classes and data structures. Category: Testing@@ -17,19 +17,18 @@ License-File: COPYING Stability: experimental build-type: Simple-tested-with: GHC==8.8.1, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3-homepage: https://github.com/conal/checkers+tested-with: GHC==9.2.1, GHC==9.0.2, GHC==8.10.7, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2+homepage: https://github.com/haskell-checkers/checkers+extra-source-files: README.md CHANGELOG.md+ source-repository head type: git- location: git://github.com/conal/checkers.git+ location: git://github.com/haskell-checkers/checkers.git Library hs-Source-Dirs: src Extensions:- Build-Depends: base >= 4.8 && < 5, random, QuickCheck>=2.3, array >= 0.1, semigroupoids >= 5 && < 6- if !impl(ghc >= 8.0)- build-depends:- semigroups >= 0.18.2 && < 0.19+ Build-Depends: base >= 4.10 && < 5, random, QuickCheck>=2.3, array >= 0.1, semigroupoids >= 5 && < 6 Exposed-Modules: Test.QuickCheck.Utils@@ -48,7 +47,5 @@ Test.QuickCheck.Later Other-modules: Control.Monad.Extensions- ghc-options: -Wall- if impl(ghc >= 8.0)- ghc-options: -Wredundant-constraints+ ghc-options: -Wall -Wredundant-constraints Default-Language: Haskell2010
src/Test/QuickCheck/Checkers.hs view
@@ -98,17 +98,21 @@ -- TODO: consider a tree structure so that flattening is unnecessary. +type QuickCheckRunner = Args -> Property -> IO ()+ -- | Run a batch of tests. See 'quickBatch' and 'verboseBatch'.-checkBatch :: Args -> TestBatch -> IO ()-checkBatch args (name,tests) =+checkBatch' :: QuickCheckRunner -> Args -> TestBatch -> IO ()+checkBatch' runner args (name,tests) = do putStrLn $ "\n" ++ name ++ ":" mapM_ pr tests where pr (s,p) = do putStr (padTo (width + 4) (" "++s ++ ":"))- Ex.catch (quickCheckWith args p)+ Ex.catch (runner args p) (print :: Ex.SomeException -> IO ()) width = foldl' max 0 (map (length.fst) tests) +checkBatch :: Args -> TestBatch -> IO ()+checkBatch = checkBatch' quickCheckWith padTo :: Int -> String -> String padTo n = take n . (++ repeat ' ')@@ -119,14 +123,10 @@ -- | Check a batch verbosely. verboseBatch :: TestBatch -> IO ()-verboseBatch = checkBatch verbose'+verboseBatch = checkBatch' verboseCheckWith quick' -quick', verbose' :: Args+quick' :: Args quick' = stdArgs { maxSuccess = 500 }-verbose' = quick'- -- quick' { configEvery = \ n args -> show n ++ ":\n" ++ unlines args }---- TODO: Restore verbose functionality. How in QC2? {-
src/Test/QuickCheck/Classes.hs view
@@ -23,11 +23,13 @@ , applicative, applicativeMorphism, semanticApplicative , bind, bindMorphism, semanticBind, bindApply , monad, monadMorphism, semanticMonad, monadFunctor- , monadApplicative, arrow, arrowChoice, foldable, foldableFunctor, traversable+ , monadApplicative, arrow, arrowChoice, foldable, foldableFunctor, bifoldable, bifoldableBifunctor, traversable , monadPlus, monadOr, alt, alternative ) where +import Data.Bifoldable (Bifoldable (..))+import Data.Bifunctor hiding (first, second) import Data.Foldable (Foldable(..)) import Data.Functor.Apply (Apply ((<.>))) import Data.Functor.Alt (Alt ((<!>)))@@ -826,3 +828,40 @@ where foldMapP :: (a -> m) -> t a -> Property foldMapP f t = foldMap f t =-= fold (fmap f t)++bifoldable :: forall p a b c m.+ ( Bifoldable p, Monoid m+ , Show (p a b), Show (p m m)+ , Arbitrary (p a b), Arbitrary (p m m), Arbitrary m+ , CoArbitrary a, CoArbitrary b+ , EqProp m, EqProp c, CoArbitrary c, Arbitrary c, Show c) =>+ p a (b, c, m) -> TestBatch+bifoldable = const ( "Bifoldable"+ , [ ("identity", property identityP)+ , ("bifoldMap f g ≡ bifoldr (mappend . f) (mappend . g) mempty", property bifoldMapBifoldrP)+ , ("bifoldr f g z t ≡ appEndo (bifoldMap (Endo . f) (Endo . g) t) z", property bifoldrBifoldMapP)+ ]+ )+ where+ identityP :: Property+ identityP = bifold =-= (bifoldMap id id :: p m m -> m)++ bifoldMapBifoldrP :: (a -> m) -> (b -> m) -> Property+ bifoldMapBifoldrP f g = bifoldMap f g =-= (bifoldr (mappend . f) (mappend . g) mempty :: p a b -> m)++ bifoldrBifoldMapP :: (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> Property+ bifoldrBifoldMapP f g z t = bifoldr f g z t =-= appEndo (bifoldMap (Endo . f) (Endo . g) t) z++bifoldableBifunctor :: forall p a b m.+ ( Bifoldable p, Bifunctor p, Monoid m+ , Show (p a b)+ , Arbitrary (p a b), Arbitrary m, CoArbitrary a, CoArbitrary b+ , EqProp m) =>+ p a (b, m) -> TestBatch+bifoldableBifunctor = const ( "Bifoldable Bifunctor"+ , [ ("bifoldMap f g ≡ bifold . bimap f g", property bifoldBimapP) ]+ )+ where+ bifoldBimapP :: (a -> m) -> (b -> m) -> Property+ bifoldBimapP f g = bifoldMap f g =-= (bifold . bimap f g :: p a b -> m)+