on master help sign in
Add test for groupsByRolling.
b223994pranaysashank
test/Streamly/Test/Prelude/Serial.hs+15−4
@@ -296,6 +296,13 @@ testGroups =
296 r <- run $ S.toList $ S.groups FL.toList $ S.fromList vec
296 r <- run $ S.toList $ S.groups FL.toList $ S.fromList vec
297 assert $ r == group vec
297 assert $ r == group vec
298
298
299+testGroupsByRolling :: Property
300+testGroupsByRolling =
301+ forAll (choose (0, maxStreamLen)) $ \len ->
302+ forAll (vectorOf len (arbitrary :: Gen Int)) $ \vec -> monadicIO $ do
303+ r <- run $ S.toList $ S.groupsByRolling (==) FL.toList $ S.fromList vec
304+ assert $ r == group vec
305+
299-- |
306-- |
300-- If the list is empty, returns Nothing,
307-- If the list is empty, returns Nothing,
301-- else wraps the minimum value of the list in Just.
308-- else wraps the minimum value of the list in Just.
@@ -324,6 +331,13 @@ testGroupsBySep =
324 $ S.fromList vec
331 $ S.fromList vec
325 assert $ decreasing a == True
332 assert $ decreasing a == True
326
333
334+groupingOps :: Spec
335+groupingOps = do
336+ prop "groupsBy" testGroupsBy
337+ prop "S.groups = groups" testGroups
338+ prop "S.groupsByRolling = groups" testGroupsByRolling
339+ prop "testGroupsBySep" testGroupsBySep
340+
327associativityCheck
341associativityCheck
328 :: String
342 :: String
329 -> (SerialT IO Int -> SerialT IO Int)
343 -> (SerialT IO Int -> SerialT IO Int)
@@ -567,10 +581,7 @@ main = hspec
567 serialOps $ eliminationOpsOrdered S.fromFoldable "serially"
581 serialOps $ eliminationOpsOrdered S.fromFoldable "serially"
568 serialOps $ eliminationOpsOrdered folded "serially folded"
582 serialOps $ eliminationOpsOrdered folded "serially folded"
569
583
570− describe "Tests for S.groupsBy" $ do
584+ describe "Tests for S.groupsBy" groupingOps
571− prop "testGroupsBy" testGroupsBy
572− prop "S.groups = groups" testGroups
573− prop "testGroupsBySep" testGroupsBySep
574
585
575 describe "Composed MonadThrow serially" $ composeWithMonadThrow serially
586 describe "Composed MonadThrow serially" $ composeWithMonadThrow serially
576
587