@@ -10,11 +10,12 @@ import Test.QuickCheck
1010 property, listOf, vectorOf, (.&&.), Gen, suchThat)
1111import Test.QuickCheck.Monadic (monadicIO, assert, run)
1212
13+import qualified Data.List as List
14+import qualified Prelude
15+import qualified Streamly.Internal.Data.Array.Storable.Foreign as A
16+import qualified Streamly.Internal.Data.Fold as FL
1317import qualified Streamly.Internal.Data.Parser.ParserD as P
1418import qualified Streamly.Internal.Data.Stream.IsStream as S
15−import qualified Streamly.Internal.Data.Fold as FL
16−import qualified Streamly.Internal.Data.Array.Storable.Foreign as A
17−import qualified Prelude
1819import qualified Test.Hspec as H
1920
2021import Prelude hiding (sequence)
@@ -287,6 +288,22 @@ takeWhile1 =
287288 where
288289 predicate = (== 0)
289290
291+groupBy :: Property
292+groupBy =
293+ forAll (listOf (chooseInt (0, 1)))
294+ $ \ls ->
295+ case S.parseD parser (S.fromList ls) of
296+ Right parsed -> checkListEqual parsed (groupByLF ls)
297+ Left _ -> property False
298+
299+ where
300+
301+ cmp = (==)
302+ parser = P.groupBy cmp FL.toList
303+ groupByLF lst
304+ | null lst = []
305+ | otherwise = head $ List.groupBy cmp lst
306+
290307sliceSepBy :: Property
291308sliceSepBy =
292309 forAll (listOf (chooseInt (0, 1))) $ \ls ->
@@ -637,6 +654,7 @@ main =
637654 prop "lookAhead . take n >> lookAhead . take n = lookAhead . take n, else fail" lookAhead
638655 prop "P.takeWhile = Prelude.takeWhile" Main.takeWhile
639656 prop "P.takeWhile1 = Prelude.takeWhile if taken something, else check why failed" takeWhile1
657+ prop "P.groupBy = Prelude.head . Prelude.groupBy" groupBy
640658 prop "P.sliceSepBy = Prelude.takeWhile (not . predicate)" sliceSepBy
641659 prop "P.sliceSepByMax = Prelude.take n (Prelude.takeWhile (not . predicate)" sliceSepByMax
642660 prop "parse 0, then 1, else fail" splitWith