[commit: packages/containers] master: quickcheck size using foldl for intset (300af25)

git at git.haskell.org git at git.haskell.org
Mon Apr 17 21:49:11 UTC 2017


Repository : ssh://git@git.haskell.org/containers

On branch  : master
Link       : http://git.haskell.org/packages/containers.git/commitdiff/300af2500379b4f4a15b595e79eec248ffd9b3b4

>---------------------------------------------------------------

commit 300af2500379b4f4a15b595e79eec248ffd9b3b4
Author: Mike Ledger <mike at quasimal.com>
Date:   Wed Mar 29 17:09:07 2017 +1100

    quickcheck size using foldl for intset


>---------------------------------------------------------------

300af2500379b4f4a15b595e79eec248ffd9b3b4
 tests/intset-properties.hs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/intset-properties.hs b/tests/intset-properties.hs
index 1671967..0cf2504 100644
--- a/tests/intset-properties.hs
+++ b/tests/intset-properties.hs
@@ -261,8 +261,10 @@ prop_isSubsetOf a b = isSubsetOf a b == Set.isSubsetOf (toSet a) (toSet b)
 prop_isSubsetOf2 :: IntSet -> IntSet -> Bool
 prop_isSubsetOf2 a b = isSubsetOf a (union a b)
 
-prop_size :: IntSet -> Bool
-prop_size s = size s == List.length (toList s)
+prop_size :: IntSet -> Property
+prop_size s = sz === foldl' (\i _ -> i + 1) (0 :: Int) s .&&.
+              sz === List.length (toList s)
+  where sz = size s
 
 prop_findMax :: IntSet -> Property
 prop_findMax s = not (null s) ==> findMax s == maximum (toList s)



More information about the ghc-commits mailing list