on master help sign in
Merge Data.Parser.ParserD test cases to Data.Parser (#2458)

Co-authored-by: Harendra Kumar <harendra@composewell.com>

commit9bf458f6825f21727723c97d87159293c315339b authorRanjeet Ranjan <ranjeetr@composewell.com> dateWed 2 Aug 2023, 15:54 (3 years ago) parent3fb676b
5 files changed+256−111
.hlint.ignore+2−2 streamly.cabal+2−1 test/Streamly/Test/Data/Parser.hs+249−105 test/Streamly/Test/Data/Parser/ParserD.hs → test/Streamly/Test/Data/ParserK.hs+1−1 test/streamly-tests.cabal+2−2
.hlint.ignore+2−2
@@ -4,7 +4,7 @@ core/src/Streamly/Internal/Unicode/Stream.hs
44src/Streamly/Internal/Data/SmallArray/Type.hs
55test/Streamly/Test/Data/Array.hs
66test/Streamly/Test/Data/Parser.hs
7−test/Streamly/Test/Data/Parser/ParserD.hs
7+test/Streamly/Test/Data/ParserK.hs
88test/Streamly/Test/Data/SmallArray.hs
99test/Streamly/Test/Data/Unfold.hs
1010test/Streamly/Test/FileSystem/Event.hs
@@ -21,7 +21,7 @@ benchmark/lib/Streamly/Benchmark/Prelude.hs
2121benchmark/NanoBenchmarks.hs
2222benchmark/Streamly/Benchmark/Data/Array.hs
2323benchmark/Streamly/Benchmark/Data/Parser.hs
24−benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs
24+benchmark/Streamly/Benchmark/Data/ParserK.hs
2525benchmark/Streamly/Benchmark/Data/Stream/StreamDK.hs
2626benchmark/Streamly/Benchmark/Data/Stream/StreamK.hs
2727benchmark/Streamly/Benchmark/Data/Unfold.hs
streamly.cabal+2−1
@@ -107,7 +107,8 @@ extra-source-files:
107107 test/Streamly/Test/Data/MutArray.hs
108108 test/Streamly/Test/Data/Ring/Unboxed.hs
109109 test/Streamly/Test/Data/Array/Stream.hs
110− test/Streamly/Test/Data/Parser/ParserD.hs
110+ test/Streamly/Test/Data/Parser.hs
111+ test/Streamly/Test/Data/ParserK.hs
111112 test/Streamly/Test/Data/Stream/Concurrent.hs
112113 test/Streamly/Test/FileSystem/Event.hs
113114 test/Streamly/Test/FileSystem/Event/Common.hs
test/Streamly/Test/Data/Parser.hs+249−105
@@ -1,5 +1,6 @@
11module Main (main) where
22
3+import Control.Applicative ((<|>))
34import Control.Exception (displayException)
45import Data.Foldable (for_)
56import Data.Word (Word8, Word32, Word64)
@@ -8,7 +9,7 @@ import Test.Hspec (Spec, hspec, describe)
89import Test.Hspec.QuickCheck
910import Test.QuickCheck
1011 (arbitrary, forAll, elements, Property, property, listOf,
11− vectorOf, Gen)
12+ vectorOf, Gen, (.&&.))
1213import Test.QuickCheck.Monadic (monadicIO, assert, run)
1314
1415import Prelude hiding (sequence)
@@ -16,10 +17,13 @@ import Prelude hiding (sequence)
1617import qualified Control.Monad.Fail as Fail
1718import qualified Data.List as List
1819import qualified Prelude
20+import qualified Streamly.Data.Stream as S
1921import qualified Streamly.Internal.Data.Array as A
2022import qualified Streamly.Internal.Data.Fold as FL
2123import qualified Streamly.Internal.Data.Parser as P
22−import qualified Streamly.Internal.Data.Stream as S
24+import qualified Streamly.Internal.Data.Producer.Source as Source
25+import qualified Streamly.Internal.Data.Producer as Producer
26+import qualified Streamly.Internal.Data.Unfold as Unfold
2327import qualified Test.Hspec as H
2428
2529#if MIN_VERSION_QuickCheck(2,14,0)
@@ -213,6 +217,13 @@ takeBetween =
213217 Left _ ->
214218 property ((m >= 0 && n >= 0 && m > n) || inputLen < m)
215219
220+take :: Property
221+take =
222+ forAll (chooseInt (min_value, max_value)) $ \n ->
223+ forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
224+ case runIdentity $ S.parse (P.fromFold $ FL.take n FL.toList) (S.fromList ls) of
225+ Right parsed_list -> checkListEqual parsed_list (Prelude.take n ls)
226+ Left _ -> property False
216227
217228takeEQPass :: Property
218229takeEQPass =
@@ -263,7 +274,6 @@ takeGE =
263274 else property False
264275 Left _ -> property (n > list_length)
265276
266−
267277nLessThanEqual0 ::
268278 ( Int
269279 -> FL.Fold Identity Int [Int]
@@ -286,21 +296,23 @@ takeProperties =
286296 prop "takeGE n FL.toList xs = xs" $
287297 nLessThanEqual0 P.takeGE (\_ -> id)
288298
289−-- lookAheadPass :: Property
290−-- lookAheadPass =
291−-- forAll (chooseInt (min_value + 1, max_value)) $ \n ->
292−-- let
293−-- takeWithoutConsume = P.lookAhead $ P.take n FL.toList
294−-- parseTwice = do
295−-- parsed_list_1 <- takeWithoutConsume
296−-- parsed_list_2 <- takeWithoutConsume
297−-- return (parsed_list_1, parsed_list_2)
298−-- in
299−-- forAll (chooseInt (n, max_value)) $ \list_length ->
300−-- forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
301−-- case S.parse parseTwice (S.fromList ls) of
302−-- Right (ls_1, ls_2) -> checkListEqual ls_1 ls_2 .&&. checkListEqual ls_1 (Prelude.take n ls)
303−-- Left _ -> property $ False
299+-- XXX lookAhead can't deal with EOF which in this case means when
300+-- n==list_length, this test will fail. So excluding that case for now.
301+lookAheadPass :: Property
302+lookAheadPass =
303+ forAll (chooseInt (min_value, max_value)) $ \n ->
304+ let
305+ takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.take n FL.toList
306+ parseTwice = do
307+ parsed_list_1 <- takeWithoutConsume
308+ parsed_list_2 <- takeWithoutConsume
309+ return (parsed_list_1, parsed_list_2)
310+ in
311+ forAll (chooseInt (n+1, max_value)) $ \list_length ->
312+ forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
313+ case runIdentity $ S.parse parseTwice (S.fromList ls) of
314+ Right (ls_1, ls_2) -> checkListEqual ls_1 ls_2 .&&. checkListEqual ls_1 (Prelude.take n ls)
315+ Left _ -> property $ False
304316
305317-- lookAheadFail :: Property
306318-- lookAheadFail =
@@ -318,22 +330,22 @@ takeProperties =
318330-- Right _ -> False
319331-- Left _ -> True
320332
321−-- lookAhead :: Property
322−-- lookAhead =
323−-- forAll (chooseInt (min_value, max_value)) $ \n ->
324−-- let
325−-- takeWithoutConsume = P.lookAhead $ P.take n FL.toList
326−-- parseTwice = do
327−-- parsed_list_1 <- takeWithoutConsume
328−-- parsed_list_2 <- takeWithoutConsume
329−-- return (parsed_list_1, parsed_list_2)
330−-- in
331−-- forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
332−-- case S.parse parseTwice (S.fromList ls) of
333−-- Right (ls_1, ls_2) -> checkListEqual ls_1 ls_2 .&&. checkListEqual ls_1 (Prelude.take n ls)
334−-- Left _ -> property ((list_length < n) || (list_length == n && n == 0))
335−-- where
336−-- list_length = Prelude.length ls
333+lookAhead :: Property
334+lookAhead =
335+ forAll (chooseInt (min_value, max_value)) $ \n ->
336+ let
337+ takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.take n FL.toList
338+ parseTwice = do
339+ parsed_list_1 <- takeWithoutConsume
340+ parsed_list_2 <- takeWithoutConsume
341+ return (parsed_list_1, parsed_list_2)
342+ in
343+ forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
344+ case runIdentity $ S.parse parseTwice (S.fromList ls) of
345+ Right (ls_1, ls_2) -> checkListEqual ls_1 ls_2 .&&. checkListEqual ls_1 (Prelude.take n ls)
346+ Left _ -> property ((list_length < n) || (list_length == n && n == 0))
347+ where
348+ list_length = Prelude.length ls
337349
338350takeEndBy_ :: Property
339351takeEndBy_ =
@@ -347,6 +359,16 @@ takeEndBy_ =
347359 prsr = P.many (P.satisfy (const True)) FL.toList
348360 tkwhl ls = Prelude.takeWhile (not . predicate) ls
349361
362+takeEndByOrMax_ :: Property
363+takeEndByOrMax_ =
364+ forAll (chooseInt (min_value, max_value)) $ \n ->
365+ forAll (listOf (chooseInt (0, 1))) $ \ls ->
366+ case runIdentity $ S.parse (P.fromFold $ FL.takeEndBy_ predicate (FL.take n FL.toList)) (S.fromList ls) of
367+ Right parsed_list -> checkListEqual parsed_list (Prelude.take n (Prelude.takeWhile (not . predicate) ls))
368+ Left _ -> property False
369+ where
370+ predicate = (== 1)
371+
350372takeStartBy :: Property
351373takeStartBy =
352374 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
@@ -464,6 +486,25 @@ groupBy =
464486 | null lst = []
465487 | otherwise = head $ List.groupBy cmp lst
466488
489+groupByRolling :: Property
490+groupByRolling =
491+ forAll (listOf (chooseInt (0, 1)))
492+ $ \ls ->
493+ case runIdentity $ S.parse parser (S.fromList ls) of
494+ Right parsed -> checkListEqual parsed (groupByLF Nothing ls)
495+ Left _ -> property False
496+
497+ where
498+
499+ cmp = (==)
500+ parser = P.groupBy cmp FL.toList
501+ groupByLF _ [] = []
502+ groupByLF Nothing (x:xs) = x : groupByLF (Just x) xs
503+ groupByLF (Just y) (x:xs) =
504+ if cmp y x
505+ then x : groupByLF (Just x) xs
506+ else []
507+
467508wordBy :: Property
468509wordBy =
469510 forAll (listOf (elements [' ', 's']))
@@ -530,42 +571,41 @@ parseManyWordQuotedBy =
530571 , ["The qui[ck] brown", "fox"])
531572 ]
532573
574+splitWith :: Property
575+splitWith =
576+ forAll (listOf (chooseInt (0, 1))) $ \ls ->
577+ case runIdentity $ S.parse (P.splitWith (,) (P.satisfy (== 0)) (P.satisfy (== 1))) (S.fromList ls) of
578+ Right (result_first, result_second) -> case ls of
579+ 0 : 1 : _ -> (result_first == 0) && (result_second == 1)
580+ _ -> False
581+ Left _ -> case ls of
582+ 0 : 1 : _ -> False
583+ _ -> True
533584
534−-- splitWithPass :: Property
535−-- splitWithPass =
536−-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
537−-- case S.parse (P.splitWith (,) (P.satisfy (== 0)) (P.satisfy (== 1))) (S.fromList ls) of
538−-- Right (result_first, result_second) -> case ls of
539−-- 0 : 1 : _ -> (result_first == 0) && (result_second == 1)
540−-- _ -> False
541−-- Left _ -> case ls of
542−-- 0 : 1 : _ -> False
543−-- _ -> True
544−
545−-- splitWithFailLeft :: Property
546−-- splitWithFailLeft =
547−-- property (case S.parse (P.splitWith (,) (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
548−-- Right _ -> False
549−-- Left _ -> True)
585+splitWithFailLeft :: Property
586+splitWithFailLeft =
587+ property (case runIdentity $ S.parse (P.splitWith (,) (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
588+ Right _ -> False
589+ Left _ -> True)
550590
551−-- splitWithFailRight :: Property
552−-- splitWithFailRight =
553−-- property (case S.parse (P.splitWith (,) (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
554−-- Right _ -> False
555−-- Left _ -> True)
591+splitWithFailRight :: Property
592+splitWithFailRight =
593+ property (case runIdentity $ S.parse (P.splitWith (,) (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
594+ Right _ -> False
595+ Left _ -> True)
556596
557−-- splitWithFailBoth :: Property
558−-- splitWithFailBoth =
559−-- property (case S.parse (P.splitWith (,) (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
560−-- Right _ -> False
561−-- Left _ -> True)
597+splitWithFailBoth :: Property
598+splitWithFailBoth =
599+ property (case runIdentity $ S.parse (P.splitWith (,) (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
600+ Right _ -> False
601+ Left _ -> True)
562602
563603-- teeWithPass :: Property
564604-- teeWithPass =
565−-- forAll (chooseInt (0, 10000)) $ \n ->
605+-- forAll (chooseInt (min_value, max_value)) $ \n ->
566606-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
567607-- let
568−-- prsr = P.take n FL.toList
608+-- prsr = P.fromFold $ FL.take n FL.toList
569609-- in
570610-- case S.parse (P.teeWith (,) prsr prsr) (S.fromList ls) of
571611-- Right (ls_1, ls_2) -> checkListEqual (Prelude.take n ls) ls_1 .&&. checkListEqual ls_1 ls_2
@@ -610,50 +650,86 @@ deintercalate =
610650-- shortestPass =
611651-- forAll (listOf (chooseInt(min_value, max_value))) $ \ls ->
612652-- let
613−-- prsr_1 = P.takeWhile (<= (mid_value `Prelude.div` 2)) FL.toList
653+-- half_mid_value = mid_value `Prelude.div` 2
654+-- prsr_1 = P.takeWhile (<= half_mid_value) FL.toList
614655-- prsr_2 = P.takeWhile (<= mid_value) FL.toList
615656-- prsr_shortest = P.shortest prsr_1 prsr_2
616657-- in
617658-- case S.parse prsr_shortest (S.fromList ls) of
618−-- Right short_list -> checkListEqual short_list (Prelude.takeWhile (<= 2500) ls)
659+-- Right short_list -> checkListEqual short_list (Prelude.takeWhile (<= half_mid_value) ls)
619660-- Left _ -> property False
620661
621−-- shortestFailLeft :: Property
622−-- shortestFailLeft =
662+-- shortestPassLeft :: Property
663+-- shortestPassLeft =
623664-- property (case S.parse (P.shortest (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
624665-- Right r -> r == 1
625666-- Left _ -> False)
626−
627−-- shortestFailRight :: Property
628−-- shortestFailRight =
667+--
668+-- shortestPassRight :: Property
669+-- shortestPassRight =
629670-- property (case S.parse (P.shortest (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
630671-- Right r -> r == 1
631672-- Left _ -> False)
632673
633674-- shortestFailBoth :: Property
634675-- shortestFailBoth =
635−-- property (case S.parse (P.shortest (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
676+-- property
677+-- (case S.parse
678+-- (P.shortest (P.die "die") (P.die "die"))
679+-- (S.fromList [1 :: Int]) of
680+-- Right _ -> False
681+-- Left _ -> True)
682+--
683+-- longestPass :: Property
684+-- longestPass =
685+-- forAll (listOf (chooseInt(min_value, max_value))) $ \ls ->
686+-- let
687+-- half_mid_value = mid_value `Prelude.div` 2
688+-- prsr_1 = P.takeWhile (<= half_mid_value) FL.toList
689+-- prsr_2 = P.takeWhile (<= mid_value) FL.toList
690+-- prsr_longest = P.longest prsr_1 prsr_2
691+-- in
692+-- case S.parse prsr_longest (S.fromList ls) of
693+-- Right long_list -> long_list == Prelude.takeWhile (<= mid_value) ls
694+-- Left _ -> False
695+--
696+-- longestPassLeft :: Property
697+-- longestPassLeft =
698+-- property (case S.parse (P.shortest (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
699+-- Right r -> r == 1
700+-- Left _ -> False)
701+--
702+-- longestPassRight :: Property
703+-- longestPassRight =
704+-- property (case S.parse (P.shortest (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
705+-- Right r -> r == 1
706+-- Left _ -> False)
707+--
708+-- longestFailBoth :: Property
709+-- longestFailBoth =
710+-- property
711+-- (case S.parse (P.shortest (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
636712-- Right _ -> False
637713-- Left _ -> True)
638714
639715many :: Property
640716many =
641717 forAll (listOf (chooseInt (0, 1))) $ \ls ->
642− let fldstp conL currL = return $ FL.Partial $ conL ++ currL
718+ let fldstp conL currL = return $ FL.Partial (conL ++ currL)
643719 concatFold = FL.Fold fldstp (return (FL.Partial [])) return
644720 prsr =
645− flip P.many concatFold $ P.fromFold $ FL.takeEndBy_ (== 1) FL.toList
646− in
647− case runIdentity $ S.parse prsr (S.fromList ls) of
648− Right res_list -> checkListEqual res_list
649− $ Prelude.filter (== 0) ls
721+ flip P.many concatFold
722+ $ P.fromFold $ FL.takeEndBy_ (== 1) FL.toList
723+ in case runIdentity $ S.parse prsr (S.fromList ls) of
724+ Right res_list ->
725+ checkListEqual res_list (Prelude.filter (== 0) ls)
650726 Left _ -> property False
651727
652−-- many_empty :: Property
653−-- many_empty =
654−-- property (case S.parse (P.many FL.toList (P.die "die")) (S.fromList [1 :: Int]) of
655−-- Right res_list -> checkListEqual res_list ([] :: [Int])
656−-- Left _ -> property False)
728+many_empty :: Property
729+many_empty =
730+ property (case runIdentity $ S.parse (flip P.many FL.toList (P.die "die")) (S.fromList [1 :: Int]) of
731+ Right res_list -> checkListEqual res_list ([] :: [Int])
732+ Left _ -> property False)
657733
658734some :: Property
659735some =
@@ -663,17 +739,17 @@ some =
663739 fldstp conL currL = return $ FL.Partial $ conL ++ currL
664740 concatFold = FL.Fold fldstp (return (FL.Partial [])) return
665741 prsr =
666− flip P.some concatFold $ P.fromFold $ FL.takeEndBy_ (== 1) FL.toList
667− in
668− case runIdentity $ S.parse prsr (S.fromList ls) of
742+ flip P.some concatFold
743+ $ P.fromFold $ FL.takeEndBy_ (== 1) FL.toList
744+ in case runIdentity $ S.parse prsr (S.fromList ls) of
669745 Right res_list -> res_list == Prelude.filter (== 0) ls
670746 Left _ -> False
671747
672−-- someFail :: Property
673−-- someFail =
674−-- property (case S.parse (P.some FL.toList (P.die "die")) (S.fromList [1 :: Int]) of
675−-- Right _ -> False
676−-- Left _ -> True)
748+someFail :: Property
749+someFail =
750+ property (case runIdentity $ S.parse (P.some (P.die "die") FL.toList) (S.fromList [1 :: Int]) of
751+ Right _ -> False
752+ Left _ -> True)
677753
678754-------------------------------------------------------------------------------
679755-- Instances
@@ -687,12 +763,10 @@ applicative =
687763 (,)
688764 <$> P.fromFold (FL.take (length list1) FL.toList)
689765 <*> P.fromFold (FL.take (length list2) FL.toList)
690− in monadicIO $ do
691− s <- S.parse parser (S.fromList $ list1 ++ list2)
692− return $
693− case s of
694− Right (olist1, olist2) -> olist1 == list1 && olist2 == list2
695− Left _ -> False
766+ in
767+ case runIdentity $ S.parse parser (S.fromList $ list1 ++ list2) of
768+ Right (olist1, olist2) -> olist1 == list1 && olist2 == list2
769+ Left _ -> False
696770
697771sequence :: Property
698772sequence =
@@ -708,6 +782,28 @@ sequence =
708782 Right ls -> ls == ins
709783 Left _ -> False
710784
785+altEOF1 :: Property
786+altEOF1 =
787+ monadicIO $ do
788+ s1 <- S.parse
789+ (P.satisfy (> 0) <|> return 66)
790+ (S.fromList ([]::[Int]))
791+ return $
792+ case s1 of
793+ Right x -> x == 66
794+ Left _ -> False
795+
796+altEOF2 :: Property
797+altEOF2 =
798+ monadicIO $ do
799+ s1 <- S.parse
800+ ((P.takeEQ 2 FL.toList) <|> (P.takeEQ 1 FL.toList))
801+ (S.fromList ([51]::[Int]))
802+ return $
803+ case s1 of
804+ Right x -> x == [51]
805+ Left _ -> False
806+
711807monad :: Property
712808monad =
713809 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
@@ -740,6 +836,49 @@ parseMany =
740836 $ S.parseMany p (S.fromList $ concat ins)
741837 listEquals (==) outs ins
742838
839+-- basic sanity test for parsing from arrays
840+parseUnfold :: Property
841+parseUnfold = do
842+ let len = 200
843+ -- ls = input list (stream)
844+ -- clen = chunk size
845+ -- tlen = parser take size
846+ forAll
847+ ((,,)
848+ <$> vectorOf len (chooseAny :: Gen Int)
849+ <*> chooseInt (1, len)
850+ <*> chooseInt (1, len)) $ \(ls, clen, tlen) ->
851+ monadicIO $ do
852+ arrays <- S.toList $ S.chunksOf clen (S.fromList ls)
853+ let src = Source.source (Just (Producer.OuterLoop arrays))
854+ let parser = P.fromFold (FL.take tlen FL.toList)
855+ let readSrc =
856+ Source.producer
857+ $ Producer.concat Producer.fromList A.producer
858+ let streamParser =
859+ Producer.simplify (Source.parseManyD parser readSrc)
860+ xs <- run
861+ $ S.toList
862+ $ S.unfoldMany Unfold.fromList
863+ $ S.catRights
864+ $ S.unfold streamParser src
865+
866+ listEquals (==) xs ls
867+
868+parserSequence :: Property
869+parserSequence =
870+ forAll (vectorOf 11 (listOf (chooseAny :: Gen Int))) $ \ins ->
871+ monadicIO $ do
872+ let parsers = S.fromList
873+ $ fmap (\xs -> P.fromFold $ FL.take (length xs) FL.sum) ins
874+ let sequencedParser = P.sequence parsers FL.sum
875+ outs <-
876+ S.parse sequencedParser $ S.concatMap S.fromList (S.fromList ins)
877+ return $
878+ case outs of
879+ Right x -> x == sum (map sum ins)
880+ Left _ -> False
881+
743882-------------------------------------------------------------------------------
744883-- Test for a particular case hit during fs events testing
745884-------------------------------------------------------------------------------
@@ -1145,11 +1284,15 @@ main =
11451284
11461285 describe "Instances" $ do
11471286 prop "applicative" applicative
1287+ prop "Alternative: end of input 1" altEOF1
1288+ prop "Alternative: end of input 2" altEOF2
11481289 prop "monad" monad
11491290 prop "sequence" sequence
11501291 describe "Stream parsing" $ do
11511292 prop "parseMany" parseMany
11521293 prop "parseMany2Events" parseMany2Events
1294+ prop "parseUnfold" parseUnfold
1295+ prop "parserSequence" parserSequence
11531296
11541297 describe "test for accumulator" $ do
11551298 prop "P.fromFold FL.sum = FL.sum" fromFold
@@ -1174,16 +1317,15 @@ main =
11741317 takeBetweenPass
11751318 prop ("P.takeBetween = Prelude.take when len >= m and len <= n and fail"
11761319 ++ "otherwise fail") Main.takeBetween
1177−
1320+ prop "P.take = Prelude.take" Main.take
11781321 prop "P.takeEQ = Prelude.take when len >= n" takeEQPass
11791322 prop "P.takeEQ = Prelude.take when len >= n and fail otherwise"
11801323 Main.takeEQ
11811324 prop "P.takeGE n ls = ls when len >= n" takeGEPass
11821325 prop "P.takeGE n ls = ls when len >= n and fail otherwise" Main.takeGE
1183− -- prop "lookAhead . take n >> lookAhead . take n = lookAhead . take n" lookAheadPass
1326+ prop "lookAhead . take n >> lookAhead . take n = lookAhead . take n" lookAheadPass
11841327 -- prop "Fail when stream length exceeded" lookAheadFail
1185− -- prop "lookAhead . take n >> lookAhead . take n = lookAhead . take n, else fail" lookAhead
1186− prop "P.takeEndBy_ test" Main.takeEndBy_
1328+ prop "lookAhead . take n >> lookAhead . take n = lookAhead . take n, else fail" lookAhead
11871329 prop ("P.takeStartBy pred = head : Prelude.takeWhile (not . pred)"
11881330 ++ " tail") takeStartBy
11891331 prop "P.takeWhile = Prelude.takeWhile" Main.takeWhile
@@ -1192,13 +1334,14 @@ main =
11921334 prop "takeWhileP prd P.take = takeWhileMaxLen prd" takeWhileP
11931335 prop ("P.takeP = Prelude.take") takeP
11941336 prop "P.groupBy = Prelude.head . Prelude.groupBy" groupBy
1337+ prop "groupByRolling" groupByRolling
11951338 prop "many (P.wordBy ' ') = words'" wordBy
11961339 parseManyWordQuotedBy
11971340 -- prop "choice" choice
1198− -- prop "" splitWithPass
1199− -- prop "" splitWithFailLeft
1200− -- prop "" splitWithFailRight
1201− -- prop "" splitWithFailBoth
1341+ prop "parse 0, then 1, else fail" splitWith
1342+ prop "fail due to die as left parser" splitWithFailLeft
1343+ prop "fail due to die as right parser" splitWithFailRight
1344+ prop "fail due to die as both parsers" splitWithFailBoth
12021345 -- prop "" teeWithPass
12031346 -- prop "" teeWithFailLeft
12041347 -- prop "" teeWithFailRight
@@ -1210,13 +1353,14 @@ main =
12101353 -- prop "" shortestFailBoth
12111354 prop ("P.many concatFold $ P.takeEndBy_ (== 1) FL.toList ="
12121355 ++ "Prelude.filter (== 0)") many
1213− -- prop "[] due to parser being die" many_empty
1356+ prop "[] due to parser being die" many_empty
12141357 prop ("P.some concatFold $ P.takeEndBy_ (== 1) FL.toList ="
12151358 ++ "Prelude.filter (== 0)") some
1216− -- prop "fail due to parser being die" someFail
1359+ prop "fail due to parser being die" someFail
12171360 prop "P.many == S.parseMany" manyEqParseMany
12181361
12191362 prop "takeEndBy_" takeEndBy_
1363+ prop "takeEndByOrMax_" takeEndByOrMax_
12201364 prop "takeEndBy1" takeEndBy1
12211365 prop "takeEndBy2" takeEndBy2
12221366 prop "takeEndByEsc" takeEndByEsc
test/Streamly/Test/Data/Parser/ParserD.hs → test/Streamly/Test/Data/ParserK.hsrenamed+1−1
@@ -757,7 +757,7 @@ parseMany2Events =
757757-------------------------------------------------------------------------------
758758
759759moduleName :: String
760−moduleName = "Data.Parser.ParserD"
760+moduleName = "Data.ParserK"
761761
762762main :: IO ()
763763main =
test/streamly-tests.cabal+2−2
@@ -293,10 +293,10 @@ test-suite Data.Parser
293293 if flag(limit-build-mem)
294294 ghc-options: +RTS -M4000M -RTS
295295
296−test-suite Data.Parser.ParserD
296+test-suite Data.ParserK
297297 import: test-options
298298 type: exitcode-stdio-1.0
299− main-is: Streamly/Test/Data/Parser/ParserD.hs
299+ main-is: Streamly/Test/Data/ParserK.hs
300300 if flag(limit-build-mem)
301301 ghc-options: +RTS -M1500M -RTS
302302