From ce86302f083eda655a47347373551071b2d87c5a Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Mon, 18 Dec 2023 22:51:53 +0530 Subject: [PATCH] Fix hlint issues in tests --- .hlint.ignore | 1 + test/Streamly/Test/Data/Fold.hs | 13 +++++++------ test/Streamly/Test/Data/Serialize/TH.hs | 4 ++-- test/Streamly/Test/FileSystem/Handle.hs | 4 ++-- test/Streamly/Test/Unicode/Char.hs | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.hlint.ignore b/.hlint.ignore index e4ff8cbb0..bd041dbcb 100644 --- a/.hlint.ignore +++ b/.hlint.ignore @@ -13,6 +13,7 @@ test/Streamly/Test/Data/Unfold.hs test/Streamly/Test/FileSystem/Event.hs test/Streamly/Test/Prelude/Concurrent.hs test/Streamly/Test/Data/Stream/Concurrent.hs +test/lib/Streamly/Test/Prelude/Common.hs test/Streamly/Test/Prelude/Fold.hs test/Streamly/Test/Prelude/Rate.hs test/Streamly/Test/Prelude/Serial.hs diff --git a/test/Streamly/Test/Data/Fold.hs b/test/Streamly/Test/Data/Fold.hs index b9cc7384f..f31f25e31 100644 --- a/test/Streamly/Test/Data/Fold.hs +++ b/test/Streamly/Test/Data/Fold.hs @@ -2,7 +2,8 @@ module Main (main) where -import Data.List (sort) +import Data.List (sort, sortBy) +import Data.Ord (comparing, Down(..)) import Data.Semigroup (Sum(..), getSum) import Streamly.Test.Common (checkListEqual, listEquals) import Test.QuickCheck @@ -412,7 +413,7 @@ partitionByM = where action ls = do - let f = \x -> if odd x then return (Left x) else return (Right x) + let f x = if odd x then return (Left x) else return (Right x) v1 <- run $ Stream.fold (Fold.partitionByM f Fold.length Fold.length) @@ -429,7 +430,7 @@ partitionByFstM = where action _ = do - let f = \x -> if odd x then return (Left x) else return (Right x) + let f x = if odd x then return (Left x) else return (Right x) v1 <- run $ Stream.fold @@ -447,7 +448,7 @@ partitionByMinM1 = where action _ = do - let f = \x -> if odd x then return (Left x) else return (Right x) + let f x = if odd x then return (Left x) else return (Right x) v1 <- run $ Stream.fold @@ -465,7 +466,7 @@ partitionByMinM2 = where action _ = do - let f = \x -> if odd x then return (Left x) else return (Right x) + let f x = if odd x then return (Left x) else return (Right x) v1 <- run $ Stream.fold @@ -690,7 +691,7 @@ topBy isTop = forAll (listOf (chooseInt (-50, 100))) $ \ls0 -> if isTop then do lst <- Stream.fold (Fold.top n) (Stream.fromList ls) >>= MArray.toList - assert ((Prelude.take n . Prelude.reverse . sort) ls == lst) + assert ((Prelude.take n . sortBy (comparing Down)) ls == lst) else do lst <- Stream.fold (Fold.bottom n) (Stream.fromList ls) >>= MArray.toList assert ((Prelude.take n . sort) ls == lst) diff --git a/test/Streamly/Test/Data/Serialize/TH.hs b/test/Streamly/Test/Data/Serialize/TH.hs index 756a93b72..e6b45dea0 100644 --- a/test/Streamly/Test/Data/Serialize/TH.hs +++ b/test/Streamly/Test/Data/Serialize/TH.hs @@ -26,7 +26,7 @@ import Test.QuickCheck.Gen (oneof) genDatatype :: String -> Int -> Q [Dec] genDatatype tyName numCons = sequence - ([ dataD + [ dataD (pure []) (mkName tyName) [] @@ -49,7 +49,7 @@ genDatatype tyName numCons = [] ] ] - ]) + ] where diff --git a/test/Streamly/Test/FileSystem/Handle.hs b/test/Streamly/Test/FileSystem/Handle.hs index a7f980f82..3209baa94 100644 --- a/test/Streamly/Test/FileSystem/Handle.hs +++ b/test/Streamly/Test/FileSystem/Handle.hs @@ -75,7 +75,7 @@ readFromHandle = readWithBufferFromHandle :: IO (Stream IO Char) readWithBufferFromHandle = - let f1 = (\h -> (1024, h)) + let f1 h = (1024, h) f2 = Unicode.decodeUtf8 . Stream.unfold Handle.readerWith . f1 in executor f2 @@ -88,7 +88,7 @@ readChunksFromHandle = readChunksWithBuffer :: IO (Stream IO Char) readChunksWithBuffer = - let f1 = (\h -> (1024, h)) + let f1 h = (1024, h) f2 = Unicode.decodeUtf8 . Stream.concatMap Array.read diff --git a/test/Streamly/Test/Unicode/Char.hs b/test/Streamly/Test/Unicode/Char.hs index e3eb953cd..cd3c5961f 100644 --- a/test/Streamly/Test/Unicode/Char.hs +++ b/test/Streamly/Test/Unicode/Char.hs @@ -54,7 +54,7 @@ checkEqual opName op (mc1, mc2) = do checkOp :: String -> NormalizationMode -> [(Text, Text)] -> IO Bool checkOp name op pairs = do res <- mapM (checkEqual name (normalize op)) pairs - return $ all (== True) res + return $ and res checkNFC :: (Text, Text, Text, Text, Text) -> IO Bool checkNFC (c1, c2, c3, c4, c5) =