packages feed

extra 1.4.4 → 1.4.5

raw patch · 6 files changed

+21/−14 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for Extra +1.4.5+    #17, change fileEq on files that do not exist to be an error 1.4.4     #14, add mconcatMap and mconcatMapM     #16, add fileEq
Generate.hs view
@@ -75,8 +75,8 @@ tweakTest x     | Just x <- stripSuffix " == undefined" x =         if not $ "\\" `isPrefixOf` x then-            "erroneous $ " ++ trim x+            (if "fileEq" `isInfixOf` x then "erroneousIO $ " else "erroneous $ ") ++ trim x         else             let (a,b) = breakOn "->" $ trim x-            in a ++ "-> erroneous $ " ++ drop 2 b+            in a ++ "-> erroneous $ " ++ trim (drop 2 b)     | otherwise = x
extra.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.10 build-type:         Simple name:               extra-version:            1.4.4+version:            1.4.5 license:            BSD3 license-file:       LICENSE category:           Development
src/System/IO/Extra.hs view
@@ -234,15 +234,15 @@           withb = allocaBytesAligned bufsz 4096           bufsz = 64*1024 --- | Returs 'True' when both files exist and have the same content.+-- | Returns 'True' if both files have the same content.+--   Raises an error if either file is missing. ----- > notM $ fileEq "does_not_exist" "does_not_exist"+-- > fileEq "does_not_exist1" "does_not_exist2" == undefined+-- > fileEq "does_not_exist" "does_not_exist" == undefined+-- > withTempFile $ \f1 -> fileEq "does_not_exist" f1 == undefined -- > withTempFile $ \f1 -> withTempFile $ \f2 -> fileEq f1 f2 -- > withTempFile $ \f1 -> withTempFile $ \f2 -> writeFile f1 "a" >> writeFile f2 "a" >> fileEq f1 f2 -- > withTempFile $ \f1 -> withTempFile $ \f2 -> writeFile f1 "a" >> writeFile f2 "b" >> notM (fileEq f1 f2) fileEq :: FilePath -> FilePath -> IO Bool-fileEq p1 p2 =-    doesFileExist p1-    &&^ doesFileExist p2-    &&^ withH p1 (\h1 -> withH p2 $ \h2 -> sameContent h1 h2)+fileEq p1 p2 = withH p1 $ \h1 -> withH p2 $ \h2 -> sameContent h1 h2     where withH p = withBinaryFile p ReadMode
test/TestGen.hs view
@@ -50,9 +50,9 @@     testGen "findM (Just . isUpper) \"test\"             == Just Nothing" $ findM (Just . isUpper) "test"             == Just Nothing     testGen "findM (Just . const True) [\"x\",undefined] == Just (Just \"x\")" $ findM (Just . const True) ["x",undefined] == Just (Just "x")     testGen "\\x -> fromLeft (Left  x) == x" $ \x -> fromLeft (Left  x) == x-    testGen "\\x -> fromLeft (Right x) == undefined" $ \x -> erroneous $  fromLeft (Right x)+    testGen "\\x -> fromLeft (Right x) == undefined" $ \x -> erroneous $ fromLeft (Right x)     testGen "\\x -> fromRight (Right x) == x" $ \x -> fromRight (Right x) == x-    testGen "\\x -> fromRight (Left  x) == undefined" $ \x -> erroneous $  fromRight (Left  x)+    testGen "\\x -> fromRight (Left  x) == undefined" $ \x -> erroneous $ fromRight (Left  x)     testGen "\\x -> fromEither (Left x ) == x" $ \x -> fromEither (Left x ) == x     testGen "\\x -> fromEither (Right x) == x" $ \x -> fromEither (Right x) == x     testGen "\\xs -> repeatedly (splitAt 3) xs  == chunksOf 3 xs" $ \xs -> repeatedly (splitAt 3) xs  == chunksOf 3 xs@@ -214,7 +214,9 @@     testGen "withTempDir doesDirectoryExist == return True" $ withTempDir doesDirectoryExist == return True     testGen "(doesDirectoryExist =<< withTempDir return) == return False" $ (doesDirectoryExist =<< withTempDir return) == return False     testGen "withTempDir listFiles == return []" $ withTempDir listFiles == return []-    testGen "notM $ fileEq \"does_not_exist\" \"does_not_exist\"" $ notM $ fileEq "does_not_exist" "does_not_exist"+    testGen "fileEq \"does_not_exist1\" \"does_not_exist2\" == undefined" $ erroneousIO $ fileEq "does_not_exist1" "does_not_exist2"+    testGen "fileEq \"does_not_exist\" \"does_not_exist\" == undefined" $ erroneousIO $ fileEq "does_not_exist" "does_not_exist"+    testGen "withTempFile $ \\f1 -> fileEq \"does_not_exist\" f1 == undefined" $ erroneousIO $ withTempFile $ \f1 -> fileEq "does_not_exist" f1     testGen "withTempFile $ \\f1 -> withTempFile $ \\f2 -> fileEq f1 f2" $ withTempFile $ \f1 -> withTempFile $ \f2 -> fileEq f1 f2     testGen "withTempFile $ \\f1 -> withTempFile $ \\f2 -> writeFile f1 \"a\" >> writeFile f2 \"a\" >> fileEq f1 f2" $ withTempFile $ \f1 -> withTempFile $ \f2 -> writeFile f1 "a" >> writeFile f2 "a" >> fileEq f1 f2     testGen "withTempFile $ \\f1 -> withTempFile $ \\f2 -> writeFile f1 \"a\" >> writeFile f2 \"b\" >> notM (fileEq f1 f2)" $ withTempFile $ \f1 -> withTempFile $ \f2 -> writeFile f1 "a" >> writeFile f2 "b" >> notM (fileEq f1 f2)
test/TestUtil.hs view
@@ -1,6 +1,6 @@-{-# LANGUAGE ScopedTypeVariables, CPP #-}+{-# LANGUAGE ScopedTypeVariables, CPP, FlexibleInstances #-} -module TestUtil(runTests, testGen, testRaw, erroneous, (====), module X) where+module TestUtil(runTests, testGen, testRaw, erroneous, erroneousIO, (====), module X) where  import Test.QuickCheck import Test.QuickCheck.Test@@ -48,6 +48,9 @@  erroneous :: a -> Bool erroneous x = unsafePerformIO $ fmap isLeft $ try_ $ evaluate x++erroneousIO :: IO a -> Bool+erroneousIO x = unsafePerformIO $ fmap isLeft $ try_ $ evaluate =<< x  (====) :: (Show a, Eq a) => a -> a -> Bool a ==== b = if a == b then True else error $ "Not equal!\n" ++ show a ++ "\n" ++ show b