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