on master help sign in
Add a test for deintercalate
0409d4bHarendra Kumar
test/Streamly/Test/Data/Parser.hs+14−11
@@ -504,17 +504,20 @@ wordBy =
504-- Right _ -> False
504-- Right _ -> False
505-- Left _ -> True)
505-- Left _ -> True)
506
506
507−-- deintercalate :: Property
507+deintercalate :: Property
508−-- deintercalate =
508+deintercalate =
509−-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
509+ forAll (listOf (chooseAny :: Gen Int)) $ \ls ->
510−-- case S.parse (P.deintercalate concatFold prsr_1 concatFold prsr_2) (S.fromList ls) of
510+ case S.parse p (S.fromList ls) of
511−-- Right parsed_list_tuple -> parsed_list_tuple == (partition (== 0) ls)
511+ Right evenOdd -> evenOdd == List.partition even ls
512−-- Left _ -> False
512+ Left _ -> False
513
513
514−-- where
514+ where
515−-- prsr_1 = (P.takeWhile (== 0) FL.toList)
515+ p1 = P.takeWhile even FL.toList
516−-- prsr_2 = (P.takeWhile (== 1) FL.toList)
516+ p2 = P.takeWhile odd FL.toList
517−-- concatFold = FL.Fold (\concatList curr_list -> return $ concatList ++ curr_list) (return []) return
517+ partition =
518+ FL.tee (fmap concat $ FL.lefts FL.toList)
519+ (fmap concat $ FL.rights FL.toList)
520+ p = P.deintercalate partition p1 p2
518
521
519-- shortestPass :: Property
522-- shortestPass :: Property
520-- shortestPass =
523-- shortestPass =
@@ -794,7 +797,7 @@ main =
794 -- prop "" teeWithFailLeft
797 -- prop "" teeWithFailLeft
795 -- prop "" teeWithFailRight
798 -- prop "" teeWithFailRight
796 -- prop "" teeWithFailBoth
799 -- prop "" teeWithFailBoth
797− -- prop "" deintercalate
800+ prop "deintercalate" deintercalate
798 -- prop "" shortestPass
801 -- prop "" shortestPass
799 -- prop "" shortestFailLeft
802 -- prop "" shortestFailLeft
800 -- prop "" shortestFailRight
803 -- prop "" shortestFailRight