@@ -340,15 +340,15 @@ sliceSepBy =
340340 where
341341 predicate = (== 1)
342342
343−-- sliceSepByMax :: Property
344−-- sliceSepByMax =
345−-- forAll (chooseInt (min_value, max_value)) $ \n ->
346−-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
347−-- case S.parse (P.sliceSepByMax predicate n FL.toList) (S.fromList ls) of
348−-- Right parsed_list -> checkListEqual parsed_list (Prelude.take n (Prelude.takeWhile (not . predicate) ls))
349−-- Left _ -> property False
350−-- where
351−-- predicate = (== 1)
343+sliceSepByMax :: Property
344+sliceSepByMax =
345+ forAll (chooseInt (min_value, max_value)) $ \n ->
346+ forAll (listOf (chooseInt (0, 1))) $ \ls ->
347+ case S.parse (P.sliceSepByMax predicate n FL.toList) (S.fromList ls) of
348+ Right parsed_list -> checkListEqual parsed_list (Prelude.take n (Prelude.takeWhile (not . predicate) ls))
349+ Left _ -> property False
350+ where
351+ predicate = (== 1)
352352
353353-- splitWithPass :: Property
354354-- splitWithPass =
@@ -450,6 +450,41 @@ sliceSepBy =
450450-- Right _ -> False
451451-- Left _ -> True)
452452
453+many :: Property
454+many =
455+ forAll (listOf (chooseInt (0, 1))) $ \ls ->
456+ let
457+ concatFold = FL.Fold (\concatList curr_list -> return $ concatList ++ curr_list) (return []) return
458+ prsr = P.many concatFold $ P.sliceSepBy (== 1) FL.toList
459+ in
460+ case S.parse prsr (S.fromList ls) of
461+ Right res_list -> checkListEqual res_list (Prelude.filter (== 0) ls)
462+ Left _ -> property False
463+
464+-- many_empty :: Property
465+-- many_empty =
466+-- property (case S.parse (P.many FL.toList (P.die "die")) (S.fromList [1 :: Int]) of
467+-- Right res_list -> checkListEqual res_list ([] :: [Int])
468+-- Left _ -> property False)
469+
470+some :: Property
471+some =
472+ forAll (listOf (chooseInt (0, 1))) $ \genLs ->
473+ let
474+ ls = 0 : genLs
475+ concatFold = FL.Fold (\concatList curr_list -> return $ concatList ++ curr_list) (return []) return
476+ prsr = P.some concatFold $ P.sliceSepBy (== 1) FL.toList
477+ in
478+ case S.parse prsr (S.fromList ls) of
479+ Right res_list -> res_list == Prelude.filter (== 0) ls
480+ Left _ -> False
481+
482+-- someFail :: Property
483+-- someFail =
484+-- property (case S.parse (P.some FL.toList (P.die "die")) (S.fromList [1 :: Int]) of
485+-- Right _ -> False
486+-- Left _ -> True)
487+
453488main :: IO ()
454489main =
455490 hspec $
@@ -485,18 +520,22 @@ main =
485520 prop "P.takeWhile = Prelude.takeWhile" Main.takeWhile
486521 prop "P.takeWhile = Prelude.takeWhile if taken something, else check why failed" takeWhile1
487522 prop "P.sliceSepBy = Prelude.takeWhile (not . predicate)" sliceSepBy
488− -- prop "test for sliceSepByMax function" sliceSepByMax
489− -- prop "pass test for splitWith function" splitWithPass
490− -- prop "left fail test for splitWith function" splitWithFailLeft
491− -- prop "right fail test for splitWith function" splitWithFailRight
492− -- prop "both fail test for splitWith function" splitWithFailBoth
493− -- prop "pass test for teeWith function" teeWithPass
494− -- prop "left fail test for teeWith function" teeWithFailLeft
495− -- prop "right fail test for teeWith function" teeWithFailRight
496− -- prop "both fail test for teeWith function" teeWithFailBoth
497− -- prop "test for deintercalate function" deintercalate
498− -- prop "pass test for shortest function" shortestPass
499− -- prop "left fail test for shortest function" shortestFailLeft
500− -- prop "right fail test for shortest function" shortestFailRight
501− -- prop "both fail test for shortest function" shortestFailBoth
523+ prop "P.sliceSepByMax n predicate = Prelude.take n (Prelude.takeWhile (not . predicate))" sliceSepByMax
524+ -- prop "" splitWithPass
525+ -- prop "" splitWithFailLeft
526+ -- prop "" splitWithFailRight
527+ -- prop "" splitWithFailBoth
528+ -- prop "" teeWithPass
529+ -- prop "" teeWithFailLeft
530+ -- prop "" teeWithFailRight
531+ -- prop "" teeWithFailBoth
532+ -- prop "" deintercalate
533+ -- prop "" shortestPass
534+ -- prop "" shortestFailLeft
535+ -- prop "" shortestFailRight
536+ -- prop "" shortestFailBoth
537+ prop "P.many concatFold $ P.sliceSepBy (== 1) FL.toList = Prelude.filter (== 0)" many
538+ -- prop "[] due to parser being die" many_empty
539+ prop "P.some concatFold $ P.sliceSepBy (== 1) FL.toList = Prelude.filter (== 0)" some
540+ -- prop "fail due to parser being die" someFail
502541 takeProperties