packages feed

quickcheck-classes 0.4.1 → 0.4.2

raw patch · 3 files changed

+39/−31 lines, 3 filesdep ~transformers

Dependency ranges changed: transformers

Files

quickcheck-classes.cabal view
@@ -1,5 +1,5 @@ name: quickcheck-classes-version: 0.4.1+version: 0.4.2 synopsis: QuickCheck common typeclasses description:   This library provides quickcheck properties to@@ -7,10 +7,7 @@   supposed to. There are other libraries that do similar   things, such as `genvalidity-hspec` and `checkers`. This   library differs from other solutions by not introducing-  any new typeclasses that the user needs to learn. The source-  code for this library should be easy to understand if you-  are already familiar with quickcheck. Open an issue-  if you feel that this is not the case.+  any new typeclasses that the user needs to learn. homepage: https://github.com/andrewthad/quickcheck-classes#readme license: BSD3 license-file: LICENSE@@ -30,7 +27,7 @@       base >= 4.5 && < 5     , bifunctors      , QuickCheck >= 2.9-    , transformers >= 0.4 && < 0.6+    , transformers >= 0.3 && < 0.6     , primitive >= 0.6.1 && < 0.7     , aeson     , containers
src/Test/QuickCheck/Classes.hs view
@@ -58,12 +58,14 @@ #endif #if MIN_VERSION_QuickCheck(2,10,0)     -- ** Higher-Kinded Types+#if MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,4,0)   , altLaws    , alternativeLaws    , applicativeLaws   , foldableLaws   , functorLaws   , monadLaws+#endif #if MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,5,0)   , bifunctorLaws  #endif@@ -114,7 +116,9 @@ import Control.Exception (ErrorCall,try,evaluate) import Control.Monad (ap) import Control.Monad.Trans.Class (lift)+#if MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,4,0) import Data.Functor.Classes+#endif import Test.QuickCheck.Arbitrary (Arbitrary1(..)) import Test.QuickCheck.Monadic (monadicIO) import qualified Data.Foldable as F@@ -752,6 +756,8 @@     else return True  #if MIN_VERSION_QuickCheck(2,10,0)++#if MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,4,0) -- | Tests the following functor properties: -- -- [/Identity/]@@ -835,29 +841,6 @@   , ("Ap", monadAp p)   ] --- | Tests the following 'Bifunctor' properties:------ [/Identity/]---   @'bimap' 'id' 'id' ≡ 'id'@--- [/First Identity/]---   @'first' 'id' ≡ 'id'@--- [/Second Identity/] ---   @'second' 'id' ≡ 'id'@--- [/Bifunctor Composition/]---   @'bimap' f g ≡ 'first' f . 'second' g@ ------ /Note/: This property test is only available when this package is built with--- @base-4.9+@ or @transformers-0.5+@.-#if MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,5,0)-bifunctorLaws :: (Bifunctor f, Eq2 f, Show2 f, Arbitrary2 f) => proxy f -> Laws-bifunctorLaws p = Laws "Bifunctor"-  [ ("Identity", bifunctorIdentity p)-  , ("First Identity", bifunctorFirstIdentity p)-  , ("Second Identity", bifunctorSecondIdentity p)-  , ("Bifunctor Composition", bifunctorComposition p)-  ]-#endif- -- | Tests the following 'Foldable' properties: -- -- [/fold/]@@ -1210,8 +1193,30 @@ monadAp _ = property $ \(Apply (f' :: f Equation)) (Apply (x :: f Integer)) ->    let f = fmap runEquation f'    in eq1 (ap f x) (f <*> x)+#endif  #if MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,5,0)+-- | Tests the following 'Bifunctor' properties:+--+-- [/Identity/]+--   @'bimap' 'id' 'id' ≡ 'id'@+-- [/First Identity/]+--   @'first' 'id' ≡ 'id'@+-- [/Second Identity/] +--   @'second' 'id' ≡ 'id'@+-- [/Bifunctor Composition/]+--   @'bimap' f g ≡ 'first' f . 'second' g@ +--+-- /Note/: This property test is only available when this package is built with+-- @base-4.9+@ or @transformers-0.5+@.+bifunctorLaws :: (Bifunctor f, Eq2 f, Show2 f, Arbitrary2 f) => proxy f -> Laws+bifunctorLaws p = Laws "Bifunctor"+  [ ("Identity", bifunctorIdentity p)+  , ("First Identity", bifunctorFirstIdentity p)+  , ("Second Identity", bifunctorSecondIdentity p)+  , ("Bifunctor Composition", bifunctorComposition p)+  ]+ bifunctorIdentity :: forall proxy f. (Bifunctor f, Eq2 f, Show2 f, Arbitrary2 f) => proxy f -> Property bifunctorIdentity _ = property $ \(Apply2 (x :: f Integer Integer)) -> eq2 (bimap id id x) x 
test/Spec.hs view
@@ -9,7 +9,9 @@ import Data.Aeson (ToJSON,FromJSON) import Data.Bits import Data.Foldable+#if MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,4,0) import Data.Functor.Classes+#endif import Data.Int import Data.Monoid (Sum,Monoid,mappend,mconcat,mempty) import Data.Primitive@@ -36,9 +38,11 @@   , ("Int64",allLaws (Proxy :: Proxy Int64))   , ("Word",allLaws (Proxy :: Proxy Word)) #if MIN_VERSION_QuickCheck(2,10,0)+#if MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,4,0)   , ("Maybe",allHigherLaws (Proxy1 :: Proxy1 Maybe))   , ("List",allHigherLaws (Proxy1 :: Proxy1 [])) #endif+#endif #if MIN_VERSION_base(4,7,0)   , ("Vector",[isListLaws (Proxy :: Proxy (Vector Word))]) #endif@@ -76,6 +80,7 @@ foldlMapM f = foldlM (\b a -> liftM (mappend b) (f a)) mempty  #if MIN_VERSION_QuickCheck(2,10,0)+#if MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,4,0) allHigherLaws :: (Foldable f, Monad f, Applicative f, Eq1 f, Arbitrary1 f, Show1 f) => proxy f -> [Laws] allHigherLaws p =    [ functorLaws p@@ -84,15 +89,16 @@   , foldableLaws p   ] #endif+#endif  -- This type fails the laws for the strict functions -- in Foldable. It is used just to confirm that -- those property tests actually work. newtype Rouge a = Rouge [a]-#if MIN_VERSION_QuickCheck(2,10,0)+#if MIN_VERSION_QuickCheck(2,10,0) && (MIN_VERSION_base(4,9,0) || MIN_VERSION_transformers(0,4,0))   deriving (Eq,Show,Arbitrary,Arbitrary1,Eq1,Show1) #else-  deriving (Eq,Show,Arbitrary,Eq1,Show1)+  deriving (Eq,Show,Arbitrary) #endif  -- Note: when using base < 4.6, the Rouge type does