@@ -385,6 +385,22 @@ takeWhile1 =
385385 where
386386 predicate = (== 0)
387387
388+choice :: Property
389+choice =
390+ forAll
391+ ((,,) <$> chooseInt (min_value, max_value)
392+ <*> chooseInt (min_value, max_value)
393+ <*> listOf (chooseInt (0, 1)))
394+ $ \(i, j, ls) ->
395+ case S.parse (P.choice [parser i, parser j]) (S.fromList ls) of
396+ Right parsed_list ->
397+ checkListEqual parsed_list $ take (min i j) ls
398+ Left _ -> property False
399+
400+ where
401+
402+ parser i = P.fromFold (FL.take i FL.toList)
403+
388404groupBy :: Property
389405groupBy =
390406 forAll (listOf (chooseInt (0, 1)))
@@ -401,7 +417,6 @@ groupBy =
401417 | null lst = []
402418 | otherwise = head $ List.groupBy cmp lst
403419
404−
405420wordBy :: Property
406421wordBy =
407422 forAll (listOf (elements [' ', 's']))
@@ -755,6 +770,7 @@ main =
755770 prop ("P.takeP = Prelude.take") takeP
756771 prop "P.groupBy = Prelude.head . Prelude.groupBy" groupBy
757772 prop "many (P.wordBy ' ') = words'" wordBy
773+ prop "choice" choice
758774 -- prop "" splitWithPass
759775 -- prop "" splitWithFailLeft
760776 -- prop "" splitWithFailRight