]> code.delx.au - offlineimap/commitdiff
Fixed prop_unaryApplyChanges for arbitrary types)
authorJohn Goerzen <jgoerzen@complete.org>
Wed, 28 May 2008 11:27:10 +0000 (06:27 -0500)
committerJohn Goerzen <jgoerzen@complete.org>
Wed, 28 May 2008 11:27:10 +0000 (06:27 -0500)
testsrc/runtests.hs

index 2d57ac123896a4d7b6f5c2472053c47f5cd8b3f8..c96df3a8ae807b68c274fb685141e3ec7eba6c1d 100644 (file)
@@ -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)