From: John Goerzen Date: Wed, 28 May 2008 11:27:10 +0000 (-0500) Subject: Fixed prop_unaryApplyChanges for arbitrary types) X-Git-Url: https://code.delx.au/offlineimap/commitdiff_plain/aa4f4fa5398a008d73f7206a5fc3d9a96b98f9ca Fixed prop_unaryApplyChanges for arbitrary types) --- diff --git a/testsrc/runtests.hs b/testsrc/runtests.hs index 2d57ac1..c96df3a 100644 --- a/testsrc/runtests.hs +++ b/testsrc/runtests.hs @@ -96,12 +96,12 @@ prop_unaryApplyChanges collection randcommands = toCommand (True, x, v) = CopyItem x v toCommand (False, x, _) = DeleteItem x - addedKeys = catMaybes . map (\x -> case x of CopyItem y _ -> Just y; _ -> Nothing) $ commands + addedItems = catMaybes . map (\x -> case x of CopyItem y v -> Just (y, v); _ -> Nothing) $ commands deletedKeys = catMaybes . map (\x -> case x of DeleteItem y -> Just y; _ -> Nothing) $ commands - collection' = Map.difference collection (foldl (\m k -> Map.insert k 3.14 m) emptymap deletedKeys) + collection' = foldl (flip Map.delete) collection deletedKeys expectedCollection = - Map.union collection' (foldl (\m k -> Map.insert k 3.14 m) emptymap deletedKeys) + Map.union collection' (Map.fromList addedItems) in (sort . Map.keys $ expectedCollection) @=? (sort . Map.keys $ unaryApplyChanges collection commands)