on master help sign in
Add tests for sort and mergeBy
commit732a916fdc6aae2558765ed3155ceb34a75fe869 authorRanjeet Kumar Ranjan <ranjeetr@composewell.com> dateFri 1 Oct 2021, 12:20 (5 years ago) parenta8a9ae8
1 file changed+8−1
test/Streamly/Test/Prelude/Serial.hs+8−1
test/Streamly/Test/Prelude/Serial.hs+8−1
@@ -14,7 +14,7 @@ import Control.Monad ( when, forM_ )
1414import Data.Function ( (&) )
1515import Data.IORef ( newIORef, readIORef, writeIORef, modifyIORef' )
1616import Data.Int (Int64)
17−import Data.List (group, intercalate)
17+import Data.List (sort, group, intercalate)
1818import Data.Maybe ( isJust, fromJust )
1919import Foreign.Storable (Storable)
2020#if __GLASGOW_HASKELL__ < 808
@@ -502,6 +502,12 @@ foldIterateM =
502502 Nothing -> assert $ s1 == 0
503503 Just s2 -> assert $ s1 == s2
504504
505+sortBy :: Property
506+sortBy = forAll (listOf (chooseInt (0, max_length))) $ \lst -> monadicIO $ do
507+ let s1 = sort lst
508+ s2 <- S.toList $ IS.sortBy compare $ S.fromList lst
509+ assert $ s1 == s2
510+
505511moduleName :: String
506512moduleName = "Prelude.Serial"
507513
@@ -693,3 +699,4 @@ main = hspec
693699
694700 describe "Nesting" $ do
695701 prop "foldIterateM" foldIterateM
702+ prop "sortBy" sortBy