packages feed

smallcheck 1.0.2 → 1.0.3

raw patch · 6 files changed

+34/−9 lines, 6 files

Files

CHANGES.md view
@@ -1,6 +1,11 @@ Changes ======= +Version 1.0.3+-------------++Fix a bug where no test cases were generated for some functional types (#19).+ Version 1.0.2 ------------- 
Test/SmallCheck.hs view
@@ -14,6 +14,7 @@ -- to the README at -- <https://github.com/feuerbach/smallcheck/blob/master/README.md> --------------------------------------------------------------------+{-# LANGUAGE Safe #-} module Test.SmallCheck (   -- * Constructing tests 
Test/SmallCheck/Property.hs view
@@ -9,6 +9,9 @@ -- -- Properties and tools to construct them. --------------------------------------------------------------------+{-# LANGUAGE Trustworthy #-}+  -- Trustworthy is needed because of the hand-written Typeable instance.+  -- Kind-polymorphic Typeable will solve this. {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, TypeFamilies,              ScopedTypeVariables #-} module Test.SmallCheck.Property (
Test/SmallCheck/Series.hs view
@@ -139,7 +139,8 @@   --   -- If @d > 0@, these functions inspect each of their arguments up to the depth   -- @d-1@ (as defined by the 'coseries' functions for the corresponding-  -- types) and return values produced by @s@.+  -- types) and return values produced by @s@. The depth to which the+  -- values are enumerated does not depend on the depth of inspection.    alts0, alts1, alts2, alts3, alts4, newtypeAlts, @@ -254,12 +255,17 @@ constM :: Monad m => m b -> m (a -> b) constM = liftM const +-- | Fix the depth of a series at the current level. The resulting series+-- will no longer depend on the \"ambient\" depth.+fixDepth :: Series m a -> Series m (Series m a)+fixDepth s = getDepth >>= \d -> return $ localDepth (const d) s+ -- | If the current depth is 0, evaluate the first argument. Otherwise, -- evaluate the second argument with decremented depth. decDepthChecked :: Series m a -> Series m a -> Series m a decDepthChecked b r = do   d <- getDepth-  if d == 0+  if d <= 0     then b     else decDepth r @@ -307,27 +313,31 @@ alts0 s = s  alts1 :: CoSerial m a => Series m b -> Series m (a->b)-alts1 rs =+alts1 rs = do+  rs <- fixDepth rs   decDepthChecked (constM rs) (coseries rs)  alts2   :: (CoSerial m a, CoSerial m b)   => Series m c -> Series m (a->b->c)-alts2 rs =+alts2 rs = do+  rs <- fixDepth rs   decDepthChecked     (constM $ constM rs)     (coseries $ coseries rs)  alts3 ::  (CoSerial m a, CoSerial m b, CoSerial m c) =>             Series m d -> Series m (a->b->c->d)-alts3 rs =+alts3 rs = do+  rs <- fixDepth rs   decDepthChecked     (constM $ constM $ constM rs)     (coseries $ coseries $ coseries rs)  alts4 ::  (CoSerial m a, CoSerial m b, CoSerial m c, CoSerial m d) =>             Series m e -> Series m (a->b->c->d->e)-alts4 rs =+alts4 rs = do+  rs <- fixDepth rs   decDepthChecked     (constM $ constM $ constM $ constM rs)     (coseries $ coseries $ coseries $ coseries rs)@@ -436,8 +446,13 @@ instance (Integral a, Serial m a) => Serial m (N a) where   series = generate $ \d -> map (N . fromIntegral) [0..d] -instance (Integral a, Serial m a) => CoSerial m (N a) where+instance (Integral a, Monad m) => CoSerial m (N a) where   coseries rs =+    -- This is a recursive function, because @alts1 rs@ typically calls+    -- back to 'coseries' (but with lower depth).+    --+    -- The recursion stops when depth == 0. Then alts1 produces a constant+    -- function, and doesn't call back to 'coseries'.     alts0 rs >>- \z ->     alts1 rs >>- \f ->     return $ \(N i) ->
Test/SmallCheck/SeriesMonad.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Trustworthy #-} -- GeneralizedNewtypeDeriving {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Test.SmallCheck.SeriesMonad where 
smallcheck.cabal view
@@ -1,5 +1,5 @@ Name:          smallcheck-Version:       1.0.2+Version:       1.0.3 Cabal-Version: >= 1.6 License:       BSD3 License-File:  LICENSE@@ -27,7 +27,7 @@ Source-repository this   type:     git   location: git://github.com/feuerbach/smallcheck.git-  tag:      v1.0.2+  tag:      v1.0.3  Library