[commit: packages/containers] master: quickcheck size for intmap (a56916e)

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


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

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

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

commit a56916e36b6fcc828c741d7620617e782145de87
Author: Mike Ledger <mike at quasimal.com>
Date:   Wed Mar 29 17:08:57 2017 +1100

    quickcheck size for intmap


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

a56916e36b6fcc828c741d7620617e782145de87
 tests/intmap-properties.hs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/intmap-properties.hs b/tests/intmap-properties.hs
index db95338..1c37cc9 100644
--- a/tests/intmap-properties.hs
+++ b/tests/intmap-properties.hs
@@ -142,6 +142,7 @@ main = defaultMain
              , testProperty "alter"                prop_alter
              , testProperty "index"                prop_index
              , testProperty "null"                 prop_null
+             , testProperty "size"                 prop_size
              , testProperty "member"               prop_member
              , testProperty "notmember"            prop_notmember
              , testProperty "lookup"               prop_lookup
@@ -906,6 +907,11 @@ prop_index xs = length xs > 0 ==>
 prop_null :: IMap -> Bool
 prop_null m = null m == (size m == 0)
 
+prop_size :: UMap -> Property
+prop_size im = sz === foldl' (\i _ -> i + 1) (0 :: Int) im .&&.
+               sz === List.length (toList im)
+  where sz = size im
+
 prop_member :: [Int] -> Int -> Bool
 prop_member xs n =
   let m  = fromList (zip xs xs)



More information about the ghc-commits mailing list