on 52ddfee help sign in
1373 lines 50 kB history raw
1module Main (main) where
3import Control.Applicative ((<|>))
4import Control.Exception (displayException)
5import Data.Foldable (for_)
6import Data.Word (Word8, Word32, Word64)
7import Streamly.Test.Common (listEquals, checkListEqual, chooseInt)
8import Test.Hspec (Spec, hspec, describe)
9import Test.Hspec.QuickCheck
10import Test.QuickCheck
11 (arbitrary, forAll, elements, Property, property, listOf,
12 vectorOf, Gen, (.&&.))
13import Test.QuickCheck.Monadic (monadicIO, assert, run)
15import Prelude hiding (sequence)
17import qualified Control.Monad.Fail as Fail
18import qualified Data.List as List
19import qualified Prelude
20import qualified Streamly.Data.Stream as S
21import qualified Streamly.Internal.Data.Array as A
22import qualified Streamly.Internal.Data.Fold as FL
23import qualified Streamly.Internal.Data.Parser as P
24import qualified Streamly.Internal.Data.Producer as Producer
25import qualified Streamly.Internal.Data.Unfold as Unfold
26import qualified Test.Hspec as H
28#if MIN_VERSION_QuickCheck(2,14,0)
30import Test.QuickCheck (chooseAny)
31import Control.Monad.Identity (Identity(runIdentity, Identity))
32import Streamly.Internal.Data.Parser (ParseError(..))
34#else
36import System.Random (Random(random))
37import Test.QuickCheck.Gen (Gen(MkGen))
39-- | Generates a random element over the natural range of `a`.
40chooseAny :: Random a => Gen a
41chooseAny = MkGen (\r _ -> let (x,_) = random r in x)
43#endif
45maxTestCount :: Int
46maxTestCount = 100
48min_value :: Int
49min_value = 0
51mid_value :: Int
52mid_value = 5000
54max_value :: Int
55max_value = 10000
57max_length :: Int
58max_length = 1000
60-- Accumulator Tests
62fromFold :: Property
63fromFold =
64 forAll (listOf $ chooseInt (min_value, max_value)) $ \ls ->
65 monadicIO $ do
66 s1 <- S.parse (P.fromFold FL.sum) (S.fromList ls)
67 o2 <- S.fold FL.sum (S.fromList ls)
68 return $
69 case s1 of
70 Right o1 -> o1 == o2
71 Left _ -> False
73fromPure :: Property
74fromPure =
75 forAll (chooseInt (min_value, max_value)) $ \x ->
76 case runIdentity $ S.parse (P.fromPure x) (S.fromList [1 :: Int]) of
77 Right r -> r == x
78 Left _ -> False
80fromEffect :: Property
81fromEffect =
82 forAll (chooseInt (min_value, max_value)) $ \x ->
83 case runIdentity $ S.parse (P.fromEffect $ return x) (S.fromList [1 :: Int]) of
84 Right r -> r == x
85 Left _ -> False
87die :: Property
88die =
89 property $
90 case runIdentity $ S.parse (P.die "die test") (S.fromList [0 :: Int]) of
91 Right _ -> False
92 Left _ -> True
94dieM :: Property
95dieM =
96 property $
97 case runIdentity $ S.parse (P.dieM (Identity "die test")) (S.fromList [0 :: Int]) of
98 Right _ -> False
99 Left _ -> True
101parserFail :: Property
102parserFail =
103 property $
104 case runIdentity $ S.parse (Fail.fail err) (S.fromList [0 :: Int]) of
105 Right _ -> False
106 Left (ParseError e) -> err == e
107 where
108 err = "Testing MonadFail.fail."
110-- Element Parser Tests
112peekPass :: Property
113peekPass =
114 forAll (chooseInt (1, max_length)) $ \list_length ->
115 forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
116 case runIdentity $ S.parse P.peek (S.fromList ls) of
117 Right head_value -> case ls of
118 head_ls : _ -> head_value == head_ls
119 _ -> False
120 Left _ -> False
122peekFail :: Property
123peekFail =
124 property (case runIdentity $ S.parse P.peek (S.fromList []) of
125 Right _ -> False
126 Left _ -> True)
128eofPass :: Property
129eofPass =
130 property (case runIdentity $ S.parse P.eof (S.fromList []) of
131 Right _ -> True
132 Left _ -> False)
134eofFail :: Property
135eofFail =
136 forAll (chooseInt (1, max_length)) $ \list_length ->
137 forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
138 case runIdentity $ S.parse P.eof (S.fromList ls) of
139 Right _ -> False
140 Left _ -> True
142satisfyPass :: Property
143satisfyPass =
144 forAll (chooseInt (mid_value, max_value)) $ \first_element ->
145 forAll (listOf (chooseInt (min_value, max_value))) $ \ls_tail ->
146 let
147 ls = first_element : ls_tail
148 predicate = (>= mid_value)
149 in
150 case runIdentity $ S.parse (P.satisfy predicate) (S.fromList ls) of
151 Right r -> r == first_element
152 Left _ -> False
154satisfy :: Property
155satisfy =
156 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
157 case runIdentity $ S.parse (P.satisfy predicate) (S.fromList ls) of
158 Right r -> case ls of
159 [] -> False
160 (x : _) -> predicate x && (r == x)
161 Left _ -> case ls of
162 [] -> True
163 (x : _) -> not $ predicate x
164 where
165 predicate = (>= mid_value)
167onePass :: Property
168onePass =
169 forAll (chooseInt (1, max_value)) $ \int ->
170 property (case runIdentity $ S.parse P.one (S.fromList [int]) of
171 Right i -> i == int
172 Left _ -> False)
174one :: Property
175one =
176 property $
177 case runIdentity $ S.parse P.one (S.fromList []) of
178 Left _ -> True
179 Right _ -> False
181-- Sequence Parsers Tests
182takeBetweenPass :: Property
183takeBetweenPass =
184 forAll (chooseInt (min_value, max_value)) $ \m ->
185 forAll (chooseInt (m, max_value)) $ \n ->
186 forAll (chooseInt (m, max_value)) $ \list_length ->
187 forAll (vectorOf list_length (chooseInt (min_value, max_value)))
188 $ \ls ->
189 case runIdentity $ S.parse (P.takeBetween m n FL.toList)
190 (S.fromList ls) of
191 Right parsed_list ->
192 let lpl = Prelude.length parsed_list
193 in checkListEqual parsed_list
194 $ Prelude.take lpl ls
195 Left _ -> property False
197takeBetween :: Property
198takeBetween =
199 forAll (chooseInt (min_value, max_value)) $ \m ->
200 forAll (chooseInt (min_value, max_value)) $ \n ->
201 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
202 go m n ls
204 where
206 go m n ls =
207 let inputLen = Prelude.length ls
208 in do
209 let p = P.takeBetween m n FL.toList
210 case runIdentity $ S.parse p (S.fromList ls) of
211 Right xs ->
212 let parsedLen = Prelude.length xs
213 in if inputLen >= m && parsedLen >= m && parsedLen <= n
214 then checkListEqual xs $ Prelude.take parsedLen ls
215 else property False
216 Left _ ->
217 property ((m >= 0 && n >= 0 && m > n) || inputLen < m)
219take :: Property
220take =
221 forAll (chooseInt (min_value, max_value)) $ \n ->
222 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
223 case runIdentity $ S.parse (P.fromFold $ FL.take n FL.toList) (S.fromList ls) of
224 Right parsed_list -> checkListEqual parsed_list (Prelude.take n ls)
225 Left _ -> property False
227takeEQPass :: Property
228takeEQPass =
229 forAll (chooseInt (min_value, max_value)) $ \n ->
230 forAll (chooseInt (n, max_value)) $ \list_length ->
231 forAll (vectorOf list_length
232 (chooseInt (min_value, max_value))) $ \ls ->
233 case runIdentity $ S.parse (P.takeEQ n FL.toList) (S.fromList ls) of
234 Right parsed_list ->
235 checkListEqual parsed_list (Prelude.take n ls)
236 Left _ -> property False
238takeEQ :: Property
239takeEQ =
240 forAll (chooseInt (min_value, max_value)) $ \n ->
241 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
242 let
243 list_length = Prelude.length ls
244 in
245 case runIdentity $ S.parse (P.takeEQ n FL.toList) (S.fromList ls) of
246 Right parsed_list ->
247 if n <= list_length
248 then checkListEqual parsed_list (Prelude.take n ls)
249 else property False
250 Left _ -> property (n > list_length)
252takeGEPass :: Property
253takeGEPass =
254 forAll (chooseInt (min_value, max_value)) $ \n ->
255 forAll (chooseInt (n, max_value)) $ \list_length ->
256 forAll (vectorOf list_length (chooseInt (min_value, max_value)))
257 $ \ls ->
258 case runIdentity $ S.parse (P.takeGE n FL.toList) (S.fromList ls) of
259 Right parsed_list -> checkListEqual parsed_list ls
260 Left _ -> property False
262takeGE :: Property
263takeGE =
264 forAll (chooseInt (min_value, max_value)) $ \n ->
265 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
266 let
267 list_length = Prelude.length ls
268 in
269 case runIdentity $ S.parse (P.takeGE n FL.toList) (S.fromList ls) of
270 Right parsed_list ->
271 if n <= list_length
272 then checkListEqual parsed_list ls
273 else property False
274 Left _ -> property (n > list_length)
276nLessThanEqual0 ::
277 ( Int
278 -> FL.Fold Identity Int [Int]
279 -> P.Parser Int Identity [Int]
280 )
281 -> (Int -> [Int] -> [Int])
282 -> Property
283nLessThanEqual0 tk ltk =
284 forAll (elements [0, (-1)]) $ \n ->
285 forAll (listOf arbitrary) $ \ls ->
286 case runIdentity $ S.parse (tk n FL.toList) (S.fromList ls) of
287 Right parsed_list -> checkListEqual parsed_list (ltk n ls)
288 Left _ -> property False
290takeProperties :: Spec
291takeProperties =
292 describe "take combinators when n <= 0/" $ do
293 prop "takeEQ n FL.toList = []" $
294 nLessThanEqual0 P.takeEQ (\_ -> const [])
295 prop "takeGE n FL.toList xs = xs" $
296 nLessThanEqual0 P.takeGE (\_ -> id)
298-- XXX lookAhead can't deal with EOF which in this case means when
299-- n==list_length, this test will fail. So excluding that case for now.
300lookAheadPass :: Property
301lookAheadPass =
302 forAll (chooseInt (min_value, max_value)) $ \n ->
303 let
304 takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.take n FL.toList
305 parseTwice = do
306 parsed_list_1 <- takeWithoutConsume
307 parsed_list_2 <- takeWithoutConsume
308 return (parsed_list_1, parsed_list_2)
309 in
310 forAll (chooseInt (n+1, max_value)) $ \list_length ->
311 forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
312 case runIdentity $ S.parse parseTwice (S.fromList ls) of
313 Right (ls_1, ls_2) -> checkListEqual ls_1 ls_2 .&&. checkListEqual ls_1 (Prelude.take n ls)
314 Left _ -> property $ False
316-- lookAheadFail :: Property
317-- lookAheadFail =
318-- forAll (chooseInt (min_value + 1, max_value)) $ \n ->
319-- let
320-- takeWithoutConsume = P.lookAhead $ P.take n FL.toList
321-- parseTwice = do
322-- parsed_list_1 <- takeWithoutConsume
323-- parsed_list_2 <- takeWithoutConsume
324-- return (parsed_list_1, parsed_list_2)
325-- in
326-- forAll (chooseInt (min_value, n - 1)) $ \list_length ->
327-- forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
328-- case S.parse parseTwice (S.fromList ls) of
329-- Right _ -> False
330-- Left _ -> True
332lookAhead :: Property
333lookAhead =
334 forAll (chooseInt (min_value, max_value)) $ \n ->
335 let
336 takeWithoutConsume = P.lookAhead $ P.fromFold $ FL.take n FL.toList
337 parseTwice = do
338 parsed_list_1 <- takeWithoutConsume
339 parsed_list_2 <- takeWithoutConsume
340 return (parsed_list_1, parsed_list_2)
341 in
342 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
343 case runIdentity $ S.parse parseTwice (S.fromList ls) of
344 Right (ls_1, ls_2) -> checkListEqual ls_1 ls_2 .&&. checkListEqual ls_1 (Prelude.take n ls)
345 Left _ -> property ((list_length < n) || (list_length == n && n == 0))
346 where
347 list_length = Prelude.length ls
349takeEndBy_ :: Property
350takeEndBy_ =
351 forAll (listOf (chooseInt (min_value, max_value ))) $ \ls ->
352 case runIdentity $ S.parse (P.takeEndBy_ predicate prsr) (S.fromList ls) of
353 Right parsed_list ->
354 checkListEqual parsed_list (tkwhl ls)
355 Left _ -> property False
356 where
357 predicate = (>= 100)
358 prsr = P.many (P.satisfy (const True)) FL.toList
359 tkwhl ls = Prelude.takeWhile (not . predicate) ls
361takeEndByOrMax_ :: Property
362takeEndByOrMax_ =
363 forAll (chooseInt (min_value, max_value)) $ \n ->
364 forAll (listOf (chooseInt (0, 1))) $ \ls ->
365 case runIdentity $ S.parse (P.fromFold $ FL.takeEndBy_ predicate (FL.take n FL.toList)) (S.fromList ls) of
366 Right parsed_list -> checkListEqual parsed_list (Prelude.take n (Prelude.takeWhile (not . predicate) ls))
367 Left _ -> property False
368 where
369 predicate = (== 1)
371takeStartBy :: Property
372takeStartBy =
373 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
374 let ls1 = 1:ls
375 in
376 case runIdentity $ S.parse parser (S.fromList ls1) of
377 Right parsed_list ->
378 if not $ Prelude.null ls1
379 then
380 let tls = Prelude.takeWhile (not . predicate) (tail ls1)
381 in checkListEqual parsed_list $
382 if predicate (head ls1)
383 then head ls1 : tls
384 else Prelude.takeWhile (not . predicate) ls1
385 else property $ Prelude.null parsed_list
386 Left _ -> property False
387 where
388 predicate = odd
389 parser = P.takeStartBy predicate FL.toList
391takeWhile :: Property
392takeWhile =
393 forAll (listOf (chooseInt (0, 1))) $ \ ls ->
394 case runIdentity $ S.parse (P.takeWhile predicate FL.toList) (S.fromList ls) of
395 Right parsed_list ->
396 checkListEqual parsed_list (Prelude.takeWhile predicate ls)
397 Left _ -> property False
398 where
399 predicate = (== 0)
401takeP :: Property
402takeP =
403 forAll
404 ((,) <$> chooseInt (min_value, max_value)
405 <*> listOf (chooseInt (0, 1)))
406 $ \(takeNum, ls) ->
407 case runIdentity $ S.parse
408 (P.takeP takeNum (P.fromFold FL.toList))
409 (S.fromList ls) of
410 Right parsed_list ->
411 checkListEqual parsed_list (Prelude.take takeNum ls)
412 Left _ -> property False
414takeWhile1 :: Property
415takeWhile1 =
416 forAll (listOf (chooseInt (0, 1))) $ \ ls ->
417 case runIdentity $ S.parse (P.takeWhile1 predicate FL.toList) (S.fromList ls) of
418 Right parsed_list -> case ls of
419 [] -> property False
420 (x : _) ->
421 if predicate x
422 then
423 checkListEqual parsed_list
424 $ Prelude.takeWhile predicate ls
425 else
426 property False
427 Left _ -> case ls of
428 [] -> property True
429 (x : _) -> property (not $ predicate x)
430 where
431 predicate = (== 0)
433takeWhileP :: Property
434takeWhileP =
435 forAll (listOf (chooseInt (0, 1))) $ \ls ->
436 forAll (chooseInt (min_value, max_value)) $ \n ->
437 let
438 predicate = (== 1)
440 prsr =
441 P.takeWhileP predicate
442 $ P.fromFold (FL.take n FL.toList)
444 takeWhileTillLen maxLen prd list =
445 Prelude.take maxLen $ Prelude.takeWhile prd list
446 in
447 case runIdentity $ S.parse prsr (S.fromList ls) of
448 Right parsed_list ->
449 checkListEqual
450 parsed_list
451 (takeWhileTillLen n predicate ls)
452 Left _ -> property False
454{-
455choice :: Property
456choice =
457 forAll
458 ((,,) <$> chooseInt (min_value, max_value)
459 <*> chooseInt (min_value, max_value)
460 <*> listOf (chooseInt (0, 1)))
461 $ \(i, j, ls) ->
462 case S.parse (P.choice [parser i, parser j]) (S.fromList ls) of
463 Right parsed_list ->
464 checkListEqual parsed_list $ take (min i j) ls
465 Left _ -> property False
467 where
469 parser i = P.fromFold (FL.take i FL.toList)
470-}
472groupBy :: Property
473groupBy =
474 forAll (listOf (chooseInt (0, 1)))
475 $ \ls ->
476 case runIdentity $ S.parse parser (S.fromList ls) of
477 Right parsed -> checkListEqual parsed (groupByLF ls)
478 Left _ -> property False
480 where
482 cmp = (==)
483 parser = P.groupBy cmp FL.toList
484 groupByLF lst
485 | null lst = []
486 | otherwise = head $ List.groupBy cmp lst
488groupByRolling :: Property
489groupByRolling =
490 forAll (listOf (chooseInt (0, 1)))
491 $ \ls ->
492 case runIdentity $ S.parse parser (S.fromList ls) of
493 Right parsed -> checkListEqual parsed (groupByLF Nothing ls)
494 Left _ -> property False
496 where
498 cmp = (==)
499 parser = P.groupBy cmp FL.toList
500 groupByLF _ [] = []
501 groupByLF Nothing (x:xs) = x : groupByLF (Just x) xs
502 groupByLF (Just y) (x:xs) =
503 if cmp y x
504 then x : groupByLF (Just x) xs
505 else []
507wordBy :: Property
508wordBy =
509 forAll (listOf (elements [' ', 's']))
510 $ \ls ->
511 case runIdentity $ S.parse parser (S.fromList ls) of
512 Right parsed -> checkListEqual parsed (words' ls)
513 Left _ -> property False
515 where
517 predicate = (== ' ')
518 parser = P.many (P.wordBy predicate FL.toList) FL.toList
519 words' lst =
520 let wrds = words lst
521 in if wrds == [] && length lst > 0 then [""] else wrds
523parseManyWordQuotedBy :: H.SpecWith ()
524parseManyWordQuotedBy =
525 describe "parseMany wordQuotedBy"
526 $ for_ testCases
527 $ \c@(kQ, isQ, input, expected) -> do
528 let inpStrm = S.fromList input
530 esc = '\\'
532 spc ' ' = True
533 spc _ = False
535 tr _ _ = Nothing
537 parser = P.wordWithQuotes kQ tr esc isQ spc FL.toList
538 result <- H.runIO $ S.fold FL.toList $ S.catRights $ S.parseMany parser inpStrm
539 H.it (showCase c) $ result `H.shouldBe` expected
541 where
543 showCase (kQ, _, input, expected) =
544 show kQ ++ ", " ++ input ++ " -> " ++ show expected
546 testCases =
547 [ ( True
548 , \x -> if x == '\'' then Just '\'' else Nothing
549 , "The quick brown fox"
550 , ["The", "quick", "brown", "fox"])
551 , ( True
552 , \x -> if x == '\'' then Just '\'' else Nothing
553 , "The' quick brown' fox"
554 , ["The' quick brown'", "fox"])
555 , ( False
556 , \x -> if x == '\'' then Just '\'' else Nothing
557 , "The' quick brown' fox"
558 , ["The quick brown", "fox"])
559 , ( True
560 , \x -> if x == '[' then Just ']' else Nothing
561 , "The[ quick brown] fox"
562 , ["The[ quick brown]", "fox"])
563 , ( True
564 , \x -> if x == '[' then Just ']' else Nothing
565 , "The[ qui[ck] brown] \\ f[ ox]"
566 , ["The[ qui[ck] brown]", " f[ ox]"])
567 , ( False
568 , \x -> if x == '[' then Just ']' else Nothing
569 , "The[ qui[ck] brown] fox"
570 , ["The qui[ck] brown", "fox"])
571 ]
573splitWith :: Property
574splitWith =
575 forAll (listOf (chooseInt (0, 1))) $ \ls ->
576 case runIdentity $ S.parse (P.splitWith (,) (P.satisfy (== 0)) (P.satisfy (== 1))) (S.fromList ls) of
577 Right (result_first, result_second) -> case ls of
578 0 : 1 : _ -> (result_first == 0) && (result_second == 1)
579 _ -> False
580 Left _ -> case ls of
581 0 : 1 : _ -> False
582 _ -> True
584splitWithFailLeft :: Property
585splitWithFailLeft =
586 property (case runIdentity $ S.parse (P.splitWith (,) (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
587 Right _ -> False
588 Left _ -> True)
590splitWithFailRight :: Property
591splitWithFailRight =
592 property (case runIdentity $ S.parse (P.splitWith (,) (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
593 Right _ -> False
594 Left _ -> True)
596splitWithFailBoth :: Property
597splitWithFailBoth =
598 property (case runIdentity $ S.parse (P.splitWith (,) (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
599 Right _ -> False
600 Left _ -> True)
602-- teeWithPass :: Property
603-- teeWithPass =
604-- forAll (chooseInt (min_value, max_value)) $ \n ->
605-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
606-- let
607-- prsr = P.fromFold $ FL.take n FL.toList
608-- in
609-- case S.parse (P.teeWith (,) prsr prsr) (S.fromList ls) of
610-- Right (ls_1, ls_2) -> checkListEqual (Prelude.take n ls) ls_1 .&&. checkListEqual ls_1 ls_2
611-- Left _ -> property False
613-- teeWithFailLeft :: Property
614-- teeWithFailLeft =
615-- property (case S.parse (P.teeWith (,) (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
616-- Right _ -> False
617-- Left _ -> True)
619-- teeWithFailRight :: Property
620-- teeWithFailRight =
621-- property (case S.parse (P.teeWith (,) (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
622-- Right _ -> False
623-- Left _ -> True)
625-- teeWithFailBoth :: Property
626-- teeWithFailBoth =
627-- property (case S.parse (P.teeWith (,) (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
628-- Right _ -> False
629-- Left _ -> True)
631{-
632deintercalate :: Property
633deintercalate =
634 forAll (listOf (chooseAny :: Gen Int)) $ \ls ->
635 case runIdentity $ S.parse p (S.fromList ls) of
636 Right evenOdd -> evenOdd == List.partition even ls
637 Left _ -> False
639 where
640 p1 = P.takeWhile even FL.toList
641 p2 = P.takeWhile odd FL.toList
642 partition =
643 FL.tee (fmap concat $ FL.catLefts FL.toList)
644 (fmap concat $ FL.catRights FL.toList)
645 p = P.deintercalate p1 p2 partition
646-}
648-- shortestPass :: Property
649-- shortestPass =
650-- forAll (listOf (chooseInt(min_value, max_value))) $ \ls ->
651-- let
652-- half_mid_value = mid_value `Prelude.div` 2
653-- prsr_1 = P.takeWhile (<= half_mid_value) FL.toList
654-- prsr_2 = P.takeWhile (<= mid_value) FL.toList
655-- prsr_shortest = P.shortest prsr_1 prsr_2
656-- in
657-- case S.parse prsr_shortest (S.fromList ls) of
658-- Right short_list -> checkListEqual short_list (Prelude.takeWhile (<= half_mid_value) ls)
659-- Left _ -> property False
661-- shortestPassLeft :: Property
662-- shortestPassLeft =
663-- property (case S.parse (P.shortest (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
664-- Right r -> r == 1
665-- Left _ -> False)
666--
667-- shortestPassRight :: Property
668-- shortestPassRight =
669-- property (case S.parse (P.shortest (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
670-- Right r -> r == 1
671-- Left _ -> False)
673-- shortestFailBoth :: Property
674-- shortestFailBoth =
675-- property
676-- (case S.parse
677-- (P.shortest (P.die "die") (P.die "die"))
678-- (S.fromList [1 :: Int]) of
679-- Right _ -> False
680-- Left _ -> True)
681--
682-- longestPass :: Property
683-- longestPass =
684-- forAll (listOf (chooseInt(min_value, max_value))) $ \ls ->
685-- let
686-- half_mid_value = mid_value `Prelude.div` 2
687-- prsr_1 = P.takeWhile (<= half_mid_value) FL.toList
688-- prsr_2 = P.takeWhile (<= mid_value) FL.toList
689-- prsr_longest = P.longest prsr_1 prsr_2
690-- in
691-- case S.parse prsr_longest (S.fromList ls) of
692-- Right long_list -> long_list == Prelude.takeWhile (<= mid_value) ls
693-- Left _ -> False
694--
695-- longestPassLeft :: Property
696-- longestPassLeft =
697-- property (case S.parse (P.shortest (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
698-- Right r -> r == 1
699-- Left _ -> False)
700--
701-- longestPassRight :: Property
702-- longestPassRight =
703-- property (case S.parse (P.shortest (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
704-- Right r -> r == 1
705-- Left _ -> False)
706--
707-- longestFailBoth :: Property
708-- longestFailBoth =
709-- property
710-- (case S.parse (P.shortest (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
711-- Right _ -> False
712-- Left _ -> True)
714many :: Property
715many =
716 forAll (listOf (chooseInt (0, 1))) $ \ls ->
717 let fldstp conL currL = return $ FL.Partial (conL ++ currL)
718 concatFold = FL.Fold fldstp (return (FL.Partial [])) return
719 prsr =
720 flip P.many concatFold
721 $ P.fromFold $ FL.takeEndBy_ (== 1) FL.toList
722 in case runIdentity $ S.parse prsr (S.fromList ls) of
723 Right res_list ->
724 checkListEqual res_list (Prelude.filter (== 0) ls)
725 Left _ -> property False
727many_empty :: Property
728many_empty =
729 property (case runIdentity $ S.parse (flip P.many FL.toList (P.die "die")) (S.fromList [1 :: Int]) of
730 Right res_list -> checkListEqual res_list ([] :: [Int])
731 Left _ -> property False)
733some :: Property
734some =
735 forAll (listOf (chooseInt (0, 1))) $ \genLs ->
736 let
737 ls = 0 : genLs
738 fldstp conL currL = return $ FL.Partial $ conL ++ currL
739 concatFold = FL.Fold fldstp (return (FL.Partial [])) return
740 prsr =
741 flip P.some concatFold
742 $ P.fromFold $ FL.takeEndBy_ (== 1) FL.toList
743 in case runIdentity $ S.parse prsr (S.fromList ls) of
744 Right res_list -> res_list == Prelude.filter (== 0) ls
745 Left _ -> False
747someFail :: Property
748someFail =
749 property (case runIdentity $ S.parse (P.some (P.die "die") FL.toList) (S.fromList [1 :: Int]) of
750 Right _ -> False
751 Left _ -> True)
753-------------------------------------------------------------------------------
754-- Instances
755-------------------------------------------------------------------------------
757applicative :: Property
758applicative =
759 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
760 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
761 let parser =
762 (,)
763 <$> P.fromFold (FL.take (length list1) FL.toList)
764 <*> P.fromFold (FL.take (length list2) FL.toList)
765 in
766 case runIdentity $ S.parse parser (S.fromList $ list1 ++ list2) of
767 Right (olist1, olist2) -> olist1 == list1 && olist2 == list2
768 Left _ -> False
770sequence :: Property
771sequence =
772 forAll (vectorOf 11 (listOf (chooseAny :: Gen Int))) $ \ ins ->
773 let p xs = P.fromFold (FL.take (length xs) FL.toList)
774 in monadicIO $ do
775 outs <- run $
776 S.parse
777 (Prelude.sequence $ fmap p ins)
778 (S.fromList $ concat ins)
779 return $
780 case outs of
781 Right ls -> ls == ins
782 Left _ -> False
784altEOF1 :: Property
785altEOF1 =
786 monadicIO $ do
787 s1 <- S.parse
788 (P.satisfy (> 0) <|> return 66)
789 (S.fromList ([]::[Int]))
790 return $
791 case s1 of
792 Right x -> x == 66
793 Left _ -> False
795altEOF2 :: Property
796altEOF2 =
797 monadicIO $ do
798 s1 <- S.parse
799 ((P.takeEQ 2 FL.toList) <|> (P.takeEQ 1 FL.toList))
800 (S.fromList ([51]::[Int]))
801 return $
802 case s1 of
803 Right x -> x == [51]
804 Left _ -> False
806monad :: Property
807monad =
808 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
809 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
810 let parser = do
811 olist1 <- P.fromFold (FL.take (length list1) FL.toList)
812 olist2 <- P.fromFold (FL.take (length list2) FL.toList)
813 return (olist1, olist2)
814 in monadicIO $ do
815 s <- S.parse parser (S.fromList $ list1 ++ list2)
816 return $
817 case s of
818 Right (olist1, olist2) -> olist1 == list1 && olist2 == list2
819 Left _ -> False
821-------------------------------------------------------------------------------
822-- Stream parsing
823-------------------------------------------------------------------------------
825parseMany :: Property
826parseMany =
827 forAll (chooseInt (1,100)) $ \len ->
828 forAll (listOf (vectorOf len (chooseAny :: Gen Int))) $ \ ins ->
829 monadicIO $ do
830 outs <- do
831 let p = P.fromFold $ FL.take len FL.toList
832 run
833 $ S.fold FL.toList
834 $ S.catRights
835 $ S.parseMany p (S.fromList $ concat ins)
836 listEquals (==) outs ins
838-- basic sanity test for parsing from arrays
839parseUnfold :: Property
840parseUnfold = do
841 let len = 200
842 -- ls = input list (stream)
843 -- clen = chunk size
844 -- tlen = parser take size
845 forAll
846 ((,,)
847 <$> vectorOf len (chooseAny :: Gen Int)
848 <*> chooseInt (1, len)
849 <*> chooseInt (1, len)) $ \(ls, clen, tlen) ->
850 monadicIO $ do
851 arrays <- S.toList $ S.chunksOf clen (S.fromList ls)
852 let src = Producer.source (Just (Producer.OuterLoop arrays))
853 let parser = P.fromFold (FL.take tlen FL.toList)
854 let readSrc =
855 Producer.producer
856 $ Producer.concat Producer.fromList A.producer
857 let streamParser =
858 Producer.simplify (Producer.parseManyD parser readSrc)
859 xs <- run
860 $ S.toList
861 $ S.unfoldMany Unfold.fromList
862 $ S.catRights
863 $ S.unfold streamParser src
865 listEquals (==) xs ls
867parserSequence :: Property
868parserSequence =
869 forAll (vectorOf 11 (listOf (chooseAny :: Gen Int))) $ \ins ->
870 monadicIO $ do
871 let parsers = S.fromList
872 $ fmap (\xs -> P.fromFold $ FL.take (length xs) FL.sum) ins
873 let sequencedParser = P.sequence parsers FL.sum
874 outs <-
875 S.parse sequencedParser $ S.concatMap S.fromList (S.fromList ins)
876 return $
877 case outs of
878 Right x -> x == sum (map sum ins)
879 Left _ -> False
881-------------------------------------------------------------------------------
882-- Test for a particular case hit during fs events testing
883-------------------------------------------------------------------------------
885evId :: [Word8]
886evId = [96,238,17,9,0,0,0,0]
888evFlags :: [Word8]
889evFlags = [0,4,1,0,0,0,0,0]
891evPathLen :: [Word8]
892evPathLen = [71,0,0,0,0,0,0,0]
894evPath :: [Word8]
895evPath =
896 [47,85,115,101,114,115,47,118,111,108,47,118,101,109,98,97,47,99,111,109
897 ,112,111,115,101,119,101 ,108,108,45,116,101,99,104,47,69,110,103,47,112
898 ,114,111,106,101,99,116,115,47,115,116,114,101,97,109,108,121,47,115,116
899 ,114,101,97,109,108,121,47,116,109,112,47,122,122
900 ]
902event :: [Word8]
903event = evId ++ evFlags ++ evPathLen ++ evPath
905data Event = Event
906 { eventId :: Word64
907 , eventFlags :: Word32
908 , eventAbsPath :: A.Array Word8
909 } deriving (Show, Ord, Eq)
911readOneEvent :: P.Parser Word8 IO Event
912readOneEvent = do
913 arr <- P.takeEQ 24 (A.writeN 24)
914 let arr1 = A.castUnsafe arr :: A.Array Word64
915 eid = A.getIndexUnsafe 0 arr1
916 eflags = A.getIndexUnsafe 1 arr1
917 pathLen = fromIntegral $ A.getIndexUnsafe 2 arr1
918 -- XXX handle if pathLen is 0
919 path <- P.takeEQ pathLen (A.writeN pathLen)
920 return $ Event
921 { eventId = eid
922 , eventFlags = fromIntegral eflags
923 , eventAbsPath = path
924 }
926parseMany2Events :: Property
927parseMany2Events =
928 monadicIO $ do
929 xs <-
930 ( run
931 $ S.fold FL.toList
932 $ S.catRights
933 $ S.parseMany readOneEvent
934 $ S.fromList (concat (replicate 2 event))
935 )
936 assert (length xs == 2)
937 -- XXX assuming little endian machine
938 let ev = Event
939 { eventId = 152170080
940 , eventFlags = 66560
941 , eventAbsPath = A.fromList evPath
942 }
943 in listEquals (==) xs (replicate 2 ev)
945manyEqParseMany :: Property
946manyEqParseMany =
947 forAll (listOf (chooseInt (0, 100))) $ \lst ->
948 forAll (chooseInt (1, 100)) $ \i ->
949 monadicIO $ do
950 let strm = S.fromList lst
951 r1 <- run $ S.parse (P.many (split i) FL.toList) strm
952 r2 <- run $ S.fold FL.toList $ S.catRights $ S.parseMany (split i) strm
953 return $
954 case r1 of
955 Right o1 -> o1 == r2
956 Left _ -> False
958 where
960 split i = P.fromFold (FL.take i FL.toList)
963takeEndBy1 :: Property
964takeEndBy1 =
965 forAll (listOf (chooseInt (0, 1))) $ \ls ->
966 case runIdentity $ S.parse (P.takeEndBy predicate prsr) (S.fromList ls) of
967 Right parsed_list ->
968 checkListEqual
969 parsed_list
970 (takeWhileAndFirstFail (not . predicate) ls)
971 Left _ -> property False
972 where
973 prsr = P.many (P.satisfy (const True)) FL.toList
975 predicate = (== 1)
977 takeWhileAndFirstFail prd (x : xs) =
978 if prd x
979 then x : takeWhileAndFirstFail prd xs
980 else [x]
981 takeWhileAndFirstFail _ [] = []
983splitWithSuffix
984 :: Monad m
985 => (a -> Bool) -> FL.Fold m a b -> S.Stream m a -> S.Stream m b
986splitWithSuffix predicate f = S.foldMany (FL.takeEndBy predicate f)
988takeEndBy2 :: Property
989takeEndBy2 =
990 forAll (listOf (chooseInt (0, 1))) $ \ls ->
991 let
992 strm = S.fromList ls
994 predicate = (==0)
996 eitherParsedList =
997 S.fold FL.toList
998 $ S.catRights
999 $ S.parseMany (P.takeEndBy predicate prsr) strm
1001 where
1003 prsr = P.many (P.satisfy (const True)) FL.toList
1005 eitherSplitList =
1006 case ls of
1007 [] -> return []
1008 _ ->
1009 if last ls == 0
1010 then S.fold FL.toList $ S.append strm1 (S.fromList [])
1011 else S.fold FL.toList strm1
1013 where
1015 strm1 = splitWithSuffix predicate FL.toList strm
1016 in
1017 case eitherParsedList of
1018 Left _ -> property False
1019 Right parsedList ->
1020 case eitherSplitList of
1021 Left _ -> property False
1022 Right splitList -> checkListEqual parsedList splitList
1024takeEndByEsc :: Property
1025takeEndByEsc =
1026 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
1027 let
1028 msg = "takeEndByEsc: trailing escape"
1030 isSep = even
1032 isEsc x = x `mod` 6 == 0
1034 prsr = P.takeEndByEsc isEsc isSep prsr0
1036 where
1038 prsr0 = P.many (P.satisfy (const True)) FL.toList
1040 escapeSep maybePrevEsc [] =
1041 case maybePrevEsc of
1042 Nothing -> []
1043 Just prevEsc -> [prevEsc]
1044 escapeSep maybePrevEsc (x : xs) =
1045 case maybePrevEsc of
1046 Nothing ->
1047 if isEsc x
1048 then escapeSep (Just x) xs
1049 else
1050 if isSep x
1051 then [x]
1052 else x : escapeSep Nothing xs
1053 Just _ ->
1054 x : escapeSep Nothing xs
1055 in
1056 case runIdentity $ S.parse prsr (S.fromList ls) of
1057 Right parsed_list -> checkListEqual parsed_list $ escapeSep Nothing ls
1058 Left err -> property (displayException err == msg)
1060takeFramedByEsc_ :: Property
1061takeFramedByEsc_ =
1062 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
1063 let
1064 isBegin = (== 0)
1066 isEnd = (== 1)
1068 isEsc = (== 2)
1070 prsr = P.takeFramedByEsc_ isEsc isBegin isEnd FL.toList
1072 checkPass (x : xs) maybePrevEsc openMinusClose =
1073 case maybePrevEsc of
1074 Nothing ->
1075 if isEsc x
1076 then checkPass xs (Just x) openMinusClose
1077 else
1078 if isBegin x
1079 then checkPass xs Nothing (openMinusClose + 1)
1080 else
1081 if isEnd x
1082 then
1083 case openMinusClose of
1084 0 -> False
1085 1 -> True
1086 _ ->
1087 checkPass
1088 xs
1089 Nothing
1090 (openMinusClose - 1)
1091 else
1092 checkPass xs Nothing openMinusClose
1093 Just _ -> checkPass xs Nothing openMinusClose
1094 checkPass [] _ _ = False
1096 checkPassBeg [] = False
1097 checkPassBeg xxs@(x:_)
1098 | isBegin x = checkPass xxs Nothing (0 :: Int)
1099 | otherwise = False
1101 escapeFrame begin end escape l =
1102 let
1103 helper (x : xs) maybePrevEsc openMinusClose =
1104 case maybePrevEsc of
1105 Nothing ->
1106 if escape x
1107 then helper xs (Just x) openMinusClose
1108 else
1109 if begin x
1110 then helper xs Nothing (openMinusClose + 1)
1111 else
1112 if end x
1113 then
1114 if openMinusClose - 1 == 0
1115 then []
1116 else
1117 helper
1118 xs
1119 Nothing
1120 (openMinusClose - 1)
1121 else
1122 x : helper xs Nothing openMinusClose
1123 Just prevEsc ->
1124 if escape x || begin x || end x
1125 then x : helper xs Nothing openMinusClose
1126 else
1127 prevEsc : x : helper xs Nothing openMinusClose
1128 helper [] _ _ = error "Cannot Reach Here"
1129 in
1130 helper l Nothing (0 :: Int)
1131 in
1132 case runIdentity $ S.parse prsr (S.fromList ls) of
1133 Right parsed_list ->
1134 if checkPassBeg ls
1135 then checkListEqual parsed_list $
1136 escapeFrame isBegin isEnd isEsc ls
1137 else property False
1138 Left _ ->
1139 if checkPassBeg ls
1140 then property False
1141 else property True
1143takeFramedByEsc_Pass :: Property
1144takeFramedByEsc_Pass =
1145 forAll (listOf (chooseInt (min_value, max_value))) $ \list ->
1146 let
1147 ls = (0 : list) ++ (Prelude.replicate (Prelude.length list + 1) 1)
1149 isBegin = (== 0)
1151 isEnd = (== 1)
1153 isEsc = (== 2)
1155 prsr = P.takeFramedByEsc_ isEsc isBegin isEnd FL.toList
1157 escapeFrame begin end escape l =
1158 let
1159 helper (x : xs) maybePrevEsc openMinusClose =
1160 case maybePrevEsc of
1161 Nothing ->
1162 if escape x
1163 then helper xs (Just x) openMinusClose
1164 else
1165 if begin x
1166 then
1167 if openMinusClose == 0
1168 then helper xs Nothing (openMinusClose + 1)
1169 else x : helper xs Nothing (openMinusClose + 1)
1170 else
1171 if end x
1172 then
1173 if openMinusClose - 1 == 0
1174 then []
1175 else
1176 x :
1177 helper
1178 xs
1179 Nothing
1180 (openMinusClose - 1)
1181 else
1182 x : helper xs Nothing openMinusClose
1183 Just _ ->
1184 x : helper xs Nothing openMinusClose
1185 helper [] _ _ = error "Cannot Reach Here"
1186 in
1187 helper l Nothing (0 :: Int)
1188 in
1189 case runIdentity $ S.parse prsr (S.fromList ls) of
1190 Right parsed_list -> checkListEqual parsed_list $ escapeFrame isBegin isEnd isEsc ls
1191 _ -> property False
1193takeFramedByEsc_Fail1 :: Property
1194takeFramedByEsc_Fail1 =
1195 let
1196 msg = "takeFramedByEsc_: missing frame end"
1198 isBegin = (== 0)
1200 isEnd = (== 0)
1202 isEsc = (== 2)
1204 prsr = P.takeFramedByEsc_ isEsc isBegin isEnd FL.toList
1206 ls = [0 :: Int]
1207 in
1208 case runIdentity $ S.parse prsr (S.fromList ls) of
1209 Right _ -> property False
1210 Left err -> property (displayException err == msg)
1212takeFramedByEsc_Fail2 :: Property
1213takeFramedByEsc_Fail2 =
1214 let
1215 msg = "takeFramedByEsc_: missing frame start"
1217 isBegin = (== 0)
1219 isEnd = (== 1)
1221 isEsc = (== 1)
1223 prsr = P.takeFramedByEsc_ isEsc isBegin isEnd FL.toList
1225 ls = [1 :: Int]
1226 in
1227 case runIdentity $ S.parse prsr (S.fromList ls) of
1228 Right _ -> property False
1229 Left err -> property (displayException err == msg)
1231takeFramedByEsc_Fail3 :: Property
1232takeFramedByEsc_Fail3 =
1233 let
1234 msg = "takeFramedByEsc_: missing frame end"
1236 isBegin = (== 2)
1238 isEnd = (== 1)
1240 isEsc = (== 2)
1242 prsr = P.takeFramedByEsc_ isEsc isBegin isEnd FL.toList
1244 ls = [2 :: Int]
1245 in
1246 case runIdentity $ S.parse prsr (S.fromList ls) of
1247 Right _ -> property False
1248 Left err -> property $ (displayException err == msg)
1250takeStartBy_ :: Property
1251takeStartBy_ =
1252 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
1253 let ls1 = 1:ls
1254 msg = "takeFramedByGeneric: empty token"
1255 in
1256 case runIdentity $ S.parse parser (S.fromList ls1) of
1257 Right parsed_list ->
1258 if not $ Prelude.null ls1
1259 then
1260 let tls = Prelude.takeWhile (not . predicate) (tail ls1)
1261 in checkListEqual parsed_list $
1262 if predicate (head ls1)
1263 then tls
1264 else Prelude.takeWhile (not . predicate) ls1
1265 else property $ Prelude.null parsed_list
1266 Left err -> property (displayException err == msg)
1267 where
1268 predicate = odd
1269 parser = P.takeStartBy_ predicate FL.toList
1270-------------------------------------------------------------------------------
1271-- Main
1272-------------------------------------------------------------------------------
1274moduleName :: String
1275moduleName = "Data.Parser"
1277main :: IO ()
1278main =
1279 hspec $
1280 H.parallel $
1281 modifyMaxSuccess (const maxTestCount) $ do
1282 describe moduleName $ do
1284 describe "Instances" $ do
1285 prop "applicative" applicative
1286 prop "Alternative: end of input 1" altEOF1
1287 prop "Alternative: end of input 2" altEOF2
1288 prop "monad" monad
1289 prop "sequence" sequence
1290 describe "Stream parsing" $ do
1291 prop "parseMany" parseMany
1292 prop "parseMany2Events" parseMany2Events
1293 prop "parseUnfold" parseUnfold
1294 prop "parserSequence" parserSequence
1296 describe "test for accumulator" $ do
1297 prop "P.fromFold FL.sum = FL.sum" fromFold
1298 prop "fromPure value provided" fromPure
1299 prop "fromPure monadic value provided" fromEffect
1300 prop "fail err = Left (SomeException (ParseError err))" parserFail
1301 prop "always fail" die
1302 prop "always fail but monadic" dieM
1304 describe "test for element parser" $ do
1305 prop "peek = head with list length > 0" peekPass
1306 prop "peek fail on []" peekFail
1307 prop "eof pass on []" eofPass
1308 prop "eof fail on non-empty list" eofFail
1309 prop "first element exists and >= mid_value" satisfyPass
1310 prop "one pass on [Int]" onePass
1311 prop "one fail on []" one
1312 prop "check first element exists and satisfies predicate" satisfy
1314 describe "test for sequence parser" $ do
1315 prop "P.takeBetween = Prelude.take when len >= m and len <= n"
1316 takeBetweenPass
1317 prop ("P.takeBetween = Prelude.take when len >= m and len <= n and fail"
1318 ++ "otherwise fail") Main.takeBetween
1319 prop "P.take = Prelude.take" Main.take
1320 prop "P.takeEQ = Prelude.take when len >= n" takeEQPass
1321 prop "P.takeEQ = Prelude.take when len >= n and fail otherwise"
1322 Main.takeEQ
1323 prop "P.takeGE n ls = ls when len >= n" takeGEPass
1324 prop "P.takeGE n ls = ls when len >= n and fail otherwise" Main.takeGE
1325 prop "lookAhead . take n >> lookAhead . take n = lookAhead . take n" lookAheadPass
1326 -- prop "Fail when stream length exceeded" lookAheadFail
1327 prop "lookAhead . take n >> lookAhead . take n = lookAhead . take n, else fail" lookAhead
1328 prop ("P.takeStartBy pred = head : Prelude.takeWhile (not . pred)"
1329 ++ " tail") takeStartBy
1330 prop "P.takeWhile = Prelude.takeWhile" Main.takeWhile
1331 prop ("P.takeWhile1 = Prelude.takeWhile if taken something,"
1332 ++ " else check why failed") takeWhile1
1333 prop "takeWhileP prd P.take = takeWhileMaxLen prd" takeWhileP
1334 prop ("P.takeP = Prelude.take") takeP
1335 prop "P.groupBy = Prelude.head . Prelude.groupBy" groupBy
1336 prop "groupByRolling" groupByRolling
1337 prop "many (P.wordBy ' ') = words'" wordBy
1338 parseManyWordQuotedBy
1339 -- prop "choice" choice
1340 prop "parse 0, then 1, else fail" splitWith
1341 prop "fail due to die as left parser" splitWithFailLeft
1342 prop "fail due to die as right parser" splitWithFailRight
1343 prop "fail due to die as both parsers" splitWithFailBoth
1344 -- prop "" teeWithPass
1345 -- prop "" teeWithFailLeft
1346 -- prop "" teeWithFailRight
1347 -- prop "" teeWithFailBoth
1348 -- prop "deintercalate" deintercalate
1349 -- prop "" shortestPass
1350 -- prop "" shortestFailLeft
1351 -- prop "" shortestFailRight
1352 -- prop "" shortestFailBoth
1353 prop ("P.many concatFold $ P.takeEndBy_ (== 1) FL.toList ="
1354 ++ "Prelude.filter (== 0)") many
1355 prop "[] due to parser being die" many_empty
1356 prop ("P.some concatFold $ P.takeEndBy_ (== 1) FL.toList ="
1357 ++ "Prelude.filter (== 0)") some
1358 prop "fail due to parser being die" someFail
1359 prop "P.many == S.parseMany" manyEqParseMany
1361 prop "takeEndBy_" takeEndBy_
1362 prop "takeEndByOrMax_" takeEndByOrMax_
1363 prop "takeEndBy1" takeEndBy1
1364 prop "takeEndBy2" takeEndBy2
1365 prop "takeEndByEsc" takeEndByEsc
1366 prop "takeFramedByEsc_" takeFramedByEsc_
1367 prop "takeFramedByEsc_Pass" takeFramedByEsc_Pass
1368 prop "takeFramedByEsc_Fail1" takeFramedByEsc_Fail1
1369 prop "takeFramedByEsc_Fail2" takeFramedByEsc_Fail2
1370 prop "takeFramedByEsc_Fail3" takeFramedByEsc_Fail3
1371 prop "takeStartBy_" takeStartBy_
1373 takeProperties