Ticket #5242: 0004-QuickCheck-property-for-differenceKeysSet.patch

File 0004-QuickCheck-property-for-differenceKeysSet.patch, 1.8 KB (added by liyang, 3 years ago)
  • tests/intmap-properties.hs

    From db0c0eca569ecc34eb5453ef8deed8db2d04e5b8 Mon Sep 17 00:00:00 2001
    From: Liyang HU <git@liyang.hu>
    Date: Tue, 7 Jun 2011 16:35:18 +0900
    Subject: [PATCH 4/4] QuickCheck property for differenceKeysSet
    
    ---
     tests/intmap-properties.hs |   13 +++++++++++++
     1 files changed, 13 insertions(+), 0 deletions(-)
    
    diff --git a/tests/intmap-properties.hs b/tests/intmap-properties.hs
    index c2080a1..bb992ae 100644
    a b main = do 
    4747--    q $ label   "prop_DiffValid"        prop_DiffValid 
    4848    q $ label   "prop_Diff"             prop_Diff 
    4949    q $ label   "prop_Diff2"            prop_Diff2 
     50    q $ label   "prop_DiffKeysSet"      prop_DiffKeysSet 
    5051--    q $ label   "prop_IntValid"         prop_IntValid 
    5152    q $ label   "prop_Int"              prop_Int 
    5253    q $ label   "prop_Ordered"          prop_Ordered 
    prop_UnionWith xs ys 
    249250  = sum (elems (unionWith (+) (fromListWith (+) xs) (fromListWith (+) ys)))  
    250251    == (sum (Prelude.map snd xs) + sum (Prelude.map snd ys)) 
    251252 
     253{-------------------------------------------------------------------- 
     254  Difference 
     255--------------------------------------------------------------------} 
     256 
    252257{- 
    253258prop_DiffValid 
    254259  = forValidUnitTree $ \t1 -> 
    prop_Diff2 xs ys 
    266271  =  List.sort (keys ((\\) (fromListWith (+) xs) (fromListWith (+) ys)))  
    267272    == List.sort ((List.\\) (List.nub (Prelude.map fst xs))  (List.nub (Prelude.map fst ys))) 
    268273 
     274prop_DiffKeysSet :: Map Int -> Map () -> Bool 
     275prop_DiffKeysSet t1 t2 
     276  = difference t1 t2 == differenceKeysSet t1 (keysSet t2) 
     277 
     278{-------------------------------------------------------------------- 
     279  Intersection 
     280--------------------------------------------------------------------} 
     281 
    269282{- 
    270283prop_IntValid 
    271284  = forValidUnitTree $ \t1 ->