on cd40d90 help sign in
680 lines 26 kB history raw
1module Main (main) where
3import Control.Exception (SomeException(..), displayException)
4import Control.Monad (when)
5import Control.Monad.IO.Class (MonadIO(..))
6import Data.List ((\\))
7import Data.Word (Word8, Word32, Word64)
8import Test.Hspec (Spec, hspec, describe)
9import Test.Hspec.QuickCheck
10import Test.QuickCheck
11 (arbitrary, forAll, choose, elements, Property, property, listOf,
12 vectorOf, counterexample, Gen, chooseAny)
13import Test.QuickCheck.Monadic (monadicIO, PropertyM, assert, monitor, run)
15import Prelude hiding (sequence)
17import qualified Streamly.Internal.Data.Parser as P
18import qualified Streamly.Internal.Data.Stream.IsStream as S
19import qualified Streamly.Internal.Data.Fold as FL
20import qualified Streamly.Internal.Data.Array.Storable.Foreign as A
21import qualified Test.Hspec as H
22import qualified Prelude
24maxTestCount :: Int
25maxTestCount = 100
27min_value :: Int
28min_value = 0
30mid_value :: Int
31mid_value = 5000
33max_value :: Int
34max_value = 10000
36max_length :: Int
37max_length = 1000
39listEquals :: (Show a, Eq a, MonadIO m)
40 => ([a] -> [a] -> Bool) -> [a] -> [a] -> PropertyM m ()
41listEquals eq parsed_list list = do
42 when (not $ parsed_list `eq` list) $ liftIO $ putStrLn $
43 "parsed list " ++ show parsed_list
44 ++ "\nlist " ++ show list
45 ++ "\nparsed list \\\\ list " ++ show (parsed_list \\ list)
46 ++ "\nlist \\\\ parsed list " ++ show (list \\ parsed_list)
47 when (not $ parsed_list `eq` list) $
48 monitor
49 (counterexample $
50 "parsed list " ++ show parsed_list
51 ++ "\nlist " ++ show list
52 ++ "\nparsed list \\\\ list " ++ show (parsed_list \\ list)
53 ++ "\nlist \\\\ parsed list " ++ show (list \\ parsed_list)
54 )
55 assert (parsed_list `eq` list)
57checkListEqual :: (Show a, Eq a) => [a] -> [a] -> Property
58checkListEqual ls_1 ls_2 = monadicIO (listEquals (==) ls_1 ls_2)
60chooseInt :: (Int, Int) -> Gen Int
61chooseInt = choose
63-- Accumulator Tests
65fromFold :: Property
66fromFold =
67 forAll (listOf $ chooseInt (min_value, max_value)) $ \ls ->
68 case (==) <$> (S.parse (P.fromFold FL.sum) (S.fromList ls)) <*> (S.fold FL.sum (S.fromList ls)) of
69 Right is_equal -> is_equal
70 Left _ -> False
72any :: Property
73any =
74 forAll (listOf $ chooseInt (min_value, max_value)) $ \ls ->
75 case S.parse (P.any (> mid_value)) (S.fromList ls) of
76 Right r -> r == (Prelude.any (> mid_value) ls)
77 Left _ -> False
79all :: Property
80all =
81 forAll (listOf $ chooseInt (min_value, max_value)) $ \ls ->
82 case S.parse (P.all (> mid_value)) (S.fromList ls) of
83 Right r -> r == (Prelude.all (> mid_value) ls)
84 Left _ -> False
86yield :: Property
87yield =
88 forAll (chooseInt (min_value, max_value)) $ \x ->
89 case S.parse (P.yield x) (S.fromList [1 :: Int]) of
90 Right r -> r == x
91 Left _ -> False
93yieldM :: Property
94yieldM =
95 forAll (chooseInt (min_value, max_value)) $ \x ->
96 case S.parse (P.yieldM $ return x) (S.fromList [1 :: Int]) of
97 Right r -> r == x
98 Left _ -> False
100die :: Property
101die =
102 property $
103 case S.parse (P.die "die test") (S.fromList [0 :: Int]) of
104 Right _ -> False
105 Left _ -> True
107dieM :: Property
108dieM =
109 property $
110 case S.parse (P.dieM (Right "die test")) (S.fromList [0 :: Int]) of
111 Right _ -> False
112 Left _ -> True
114parserFail :: Property
115parserFail =
116 property $
117 case S.parse (fail err) (S.fromList [0 :: Int]) of
118 Right _ -> False
119 Left (SomeException e) -> err == displayException e
120 where
121 err = "Testing MonadFail.fail."
123-- Element Parser Tests
125peekPass :: Property
126peekPass =
127 forAll (chooseInt (1, max_length)) $ \list_length ->
128 forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
129 case S.parse P.peek (S.fromList ls) of
130 Right head_value -> case ls of
131 head_ls : _ -> head_value == head_ls
132 _ -> False
133 Left _ -> False
135peekFail :: Property
136peekFail =
137 property (case S.parse P.peek (S.fromList []) of
138 Right _ -> False
139 Left _ -> True)
141eofPass :: Property
142eofPass =
143 property (case S.parse P.eof (S.fromList []) of
144 Right _ -> True
145 Left _ -> False)
147eofFail :: Property
148eofFail =
149 forAll (chooseInt (1, max_length)) $ \list_length ->
150 forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
151 case S.parse P.eof (S.fromList ls) of
152 Right _ -> False
153 Left _ -> True
155satisfyPass :: Property
156satisfyPass =
157 forAll (chooseInt (mid_value, max_value)) $ \first_element ->
158 forAll (listOf (chooseInt (min_value, max_value))) $ \ls_tail ->
159 let
160 ls = first_element : ls_tail
161 predicate = (>= mid_value)
162 in
163 case S.parse (P.satisfy predicate) (S.fromList ls) of
164 Right r -> r == first_element
165 Left _ -> False
167satisfy :: Property
168satisfy =
169 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
170 case S.parse (P.satisfy predicate) (S.fromList ls) of
171 Right r -> case ls of
172 [] -> False
173 (x : _) -> predicate x && (r == x)
174 Left _ -> case ls of
175 [] -> True
176 (x : _) -> not $ predicate x
177 where
178 predicate = (>= mid_value)
180-- Sequence Parsers Tests
182take :: Property
183take =
184 forAll (chooseInt (min_value, max_value)) $ \n ->
185 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
186 case S.parse (P.take n FL.toList) (S.fromList ls) of
187 Right parsed_list -> checkListEqual parsed_list (Prelude.take n ls)
188 Left _ -> property False
190takeEQPass :: Property
191takeEQPass =
192 forAll (chooseInt (min_value, max_value)) $ \n ->
193 forAll (chooseInt (n, max_value)) $ \list_length ->
194 forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
195 case S.parse (P.takeEQ n FL.toList) (S.fromList ls) of
196 Right parsed_list -> checkListEqual parsed_list (Prelude.take n ls)
197 Left _ -> property False
199takeEQ :: Property
200takeEQ =
201 forAll (chooseInt (min_value, max_value)) $ \n ->
202 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
203 let
204 list_length = Prelude.length ls
205 in
206 case S.parse (P.takeEQ n FL.toList) (S.fromList ls) of
207 Right parsed_list ->
208 if (n <= list_length) then
209 checkListEqual parsed_list (Prelude.take n ls)
210 else
211 property False
212 Left _ -> property (n > list_length)
214takeGEPass :: Property
215takeGEPass =
216 forAll (chooseInt (min_value, max_value)) $ \n ->
217 forAll (chooseInt (n, max_value)) $ \list_length ->
218 forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
219 case S.parse (P.takeGE n FL.toList) (S.fromList ls) of
220 Right parsed_list -> checkListEqual parsed_list ls
221 Left _ -> property False
223takeGE :: Property
224takeGE =
225 forAll (chooseInt (min_value, max_value)) $ \n ->
226 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
227 let
228 list_length = Prelude.length ls
229 in
230 case S.parse (P.takeGE n FL.toList) (S.fromList ls) of
231 Right parsed_list ->
232 if (n <= list_length) then
233 checkListEqual parsed_list ls
234 else
235 property False
236 Left _ -> property (n > list_length)
238nLessThanEqual0 ::
239 ( Int
240 -> FL.Fold (Either SomeException) Int [Int]
241 -> P.Parser (Either SomeException) Int [Int]
242 )
243 -> (Int -> [Int] -> [Int])
244 -> Property
245nLessThanEqual0 tk ltk =
246 forAll (elements [0, (-1)]) $ \n ->
247 forAll (listOf arbitrary) $ \ls ->
248 case S.parse (tk n FL.toList) (S.fromList ls) of
249 Right parsed_list -> checkListEqual parsed_list (ltk n ls)
250 Left _ -> property False
252takeProperties :: Spec
253takeProperties =
254 describe "take combinators when n <= 0/" $ do
255 prop "take n FL.toList = []" $
256 nLessThanEqual0 P.take (\_ -> const [])
257 prop "takeEQ n FL.toList = []" $
258 nLessThanEqual0 P.takeEQ (\_ -> const [])
259 prop "takeGE n FL.toList xs = xs" $
260 nLessThanEqual0 P.takeGE (\_ -> id)
262-- lookAheadPass :: Property
263-- lookAheadPass =
264-- forAll (chooseInt (min_value + 1, max_value)) $ \n ->
265-- let
266-- takeWithoutConsume = P.lookAhead $ P.take n FL.toList
267-- parseTwice = do
268-- parsed_list_1 <- takeWithoutConsume
269-- parsed_list_2 <- takeWithoutConsume
270-- return (parsed_list_1, parsed_list_2)
271-- in
272-- forAll (chooseInt (n, max_value)) $ \list_length ->
273-- forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
274-- case S.parse parseTwice (S.fromList ls) of
275-- Right (ls_1, ls_2) -> checkListEqual ls_1 ls_2 .&&. checkListEqual ls_1 (Prelude.take n ls)
276-- Left _ -> property $ False
278-- lookAheadFail :: Property
279-- lookAheadFail =
280-- forAll (chooseInt (min_value + 1, max_value)) $ \n ->
281-- let
282-- takeWithoutConsume = P.lookAhead $ P.take n FL.toList
283-- parseTwice = do
284-- parsed_list_1 <- takeWithoutConsume
285-- parsed_list_2 <- takeWithoutConsume
286-- return (parsed_list_1, parsed_list_2)
287-- in
288-- forAll (chooseInt (min_value, n - 1)) $ \list_length ->
289-- forAll (vectorOf list_length (chooseInt (min_value, max_value))) $ \ls ->
290-- case S.parse parseTwice (S.fromList ls) of
291-- Right _ -> False
292-- Left _ -> True
294-- lookAhead :: Property
295-- lookAhead =
296-- forAll (chooseInt (min_value, max_value)) $ \n ->
297-- let
298-- takeWithoutConsume = P.lookAhead $ P.take n FL.toList
299-- parseTwice = do
300-- parsed_list_1 <- takeWithoutConsume
301-- parsed_list_2 <- takeWithoutConsume
302-- return (parsed_list_1, parsed_list_2)
303-- in
304-- forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
305-- case S.parse parseTwice (S.fromList ls) of
306-- Right (ls_1, ls_2) -> checkListEqual ls_1 ls_2 .&&. checkListEqual ls_1 (Prelude.take n ls)
307-- Left _ -> property ((list_length < n) || (list_length == n && n == 0))
308-- where
309-- list_length = Prelude.length ls
311takeWhile :: Property
312takeWhile =
313 forAll (listOf (chooseInt (0, 1))) $ \ ls ->
314 case S.parse (P.takeWhile predicate FL.toList) (S.fromList ls) of
315 Right parsed_list -> checkListEqual parsed_list (Prelude.takeWhile predicate ls)
316 Left _ -> property False
317 where
318 predicate = (== 0)
320takeWhile1 :: Property
321takeWhile1 =
322 forAll (listOf (chooseInt (0, 1))) $ \ ls ->
323 case S.parse (P.takeWhile1 predicate FL.toList) (S.fromList ls) of
324 Right parsed_list -> case ls of
325 [] -> property False
326 (x : _) ->
327 if predicate x then
328 checkListEqual parsed_list (Prelude.takeWhile predicate ls)
329 else
330 property False
331 Left _ -> case ls of
332 [] -> property True
333 (x : _) -> property (not $ predicate x)
334 where
335 predicate = (== 0)
337sliceSepBy :: Property
338sliceSepBy =
339 forAll (listOf (chooseInt (0, 1))) $ \ls ->
340 case S.parse (P.sliceSepBy predicate FL.toList) (S.fromList ls) of
341 Right parsed_list -> checkListEqual parsed_list (Prelude.takeWhile (not . predicate) ls)
342 Left _ -> property False
343 where
344 predicate = (== 1)
346sliceSepByMax :: Property
347sliceSepByMax =
348 forAll (chooseInt (min_value, max_value)) $ \n ->
349 forAll (listOf (chooseInt (0, 1))) $ \ls ->
350 case S.parse (P.sliceSepByMax predicate n FL.toList) (S.fromList ls) of
351 Right parsed_list -> checkListEqual parsed_list (Prelude.take n (Prelude.takeWhile (not . predicate) ls))
352 Left _ -> property False
353 where
354 predicate = (== 1)
356-- splitWithPass :: Property
357-- splitWithPass =
358-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
359-- case S.parse (P.splitWith (,) (P.satisfy (== 0)) (P.satisfy (== 1))) (S.fromList ls) of
360-- Right (result_first, result_second) -> case ls of
361-- 0 : 1 : _ -> (result_first == 0) && (result_second == 1)
362-- _ -> False
363-- Left _ -> case ls of
364-- 0 : 1 : _ -> False
365-- _ -> True
367-- splitWithFailLeft :: Property
368-- splitWithFailLeft =
369-- property (case S.parse (P.splitWith (,) (P.die "die") (P.yield (1 :: Int))) (S.fromList [1 :: Int]) of
370-- Right _ -> False
371-- Left _ -> True)
373-- splitWithFailRight :: Property
374-- splitWithFailRight =
375-- property (case S.parse (P.splitWith (,) (P.yield (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
376-- Right _ -> False
377-- Left _ -> True)
379-- splitWithFailBoth :: Property
380-- splitWithFailBoth =
381-- property (case S.parse (P.splitWith (,) (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
382-- Right _ -> False
383-- Left _ -> True)
385-- teeWithPass :: Property
386-- teeWithPass =
387-- forAll (chooseInt (0, 10000)) $ \n ->
388-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
389-- let
390-- prsr = P.take n FL.toList
391-- in
392-- case S.parse (P.teeWith (,) prsr prsr) (S.fromList ls) of
393-- Right (ls_1, ls_2) -> checkListEqual (Prelude.take n ls) ls_1 .&&. checkListEqual ls_1 ls_2
394-- Left _ -> property False
396-- teeWithFailLeft :: Property
397-- teeWithFailLeft =
398-- property (case S.parse (P.teeWith (,) (P.die "die") (P.yield (1 :: Int))) (S.fromList [1 :: Int]) of
399-- Right _ -> False
400-- Left _ -> True)
402-- teeWithFailRight :: Property
403-- teeWithFailRight =
404-- property (case S.parse (P.teeWith (,) (P.yield (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
405-- Right _ -> False
406-- Left _ -> True)
408-- teeWithFailBoth :: Property
409-- teeWithFailBoth =
410-- property (case S.parse (P.teeWith (,) (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
411-- Right _ -> False
412-- Left _ -> True)
414-- deintercalate :: Property
415-- deintercalate =
416-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
417-- case S.parse (P.deintercalate concatFold prsr_1 concatFold prsr_2) (S.fromList ls) of
418-- Right parsed_list_tuple -> parsed_list_tuple == (partition (== 0) ls)
419-- Left _ -> False
421-- where
422-- prsr_1 = (P.takeWhile (== 0) FL.toList)
423-- prsr_2 = (P.takeWhile (== 1) FL.toList)
424-- concatFold = FL.Fold (\concatList curr_list -> return $ concatList ++ curr_list) (return []) return
426-- shortestPass :: Property
427-- shortestPass =
428-- forAll (listOf (chooseInt(min_value, max_value))) $ \ls ->
429-- let
430-- prsr_1 = P.takeWhile (<= (mid_value `Prelude.div` 2)) FL.toList
431-- prsr_2 = P.takeWhile (<= mid_value) FL.toList
432-- prsr_shortest = P.shortest prsr_1 prsr_2
433-- in
434-- case S.parse prsr_shortest (S.fromList ls) of
435-- Right short_list -> checkListEqual short_list (Prelude.takeWhile (<= 2500) ls)
436-- Left _ -> property False
438-- shortestFailLeft :: Property
439-- shortestFailLeft =
440-- property (case S.parse (P.shortest (P.die "die") (P.yield (1 :: Int))) (S.fromList [1 :: Int]) of
441-- Right r -> r == 1
442-- Left _ -> False)
444-- shortestFailRight :: Property
445-- shortestFailRight =
446-- property (case S.parse (P.shortest (P.yield (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
447-- Right r -> r == 1
448-- Left _ -> False)
450-- shortestFailBoth :: Property
451-- shortestFailBoth =
452-- property (case S.parse (P.shortest (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
453-- Right _ -> False
454-- Left _ -> True)
456many :: Property
457many =
458 forAll (listOf (chooseInt (0, 1))) $ \ls ->
459 let
460 concatFold = FL.Fold (\concatList curr_list -> return $ concatList ++ curr_list) (return []) return
461 prsr = P.many concatFold $ P.sliceSepBy (== 1) FL.toList
462 in
463 case S.parse prsr (S.fromList ls) of
464 Right res_list -> checkListEqual res_list (Prelude.filter (== 0) ls)
465 Left _ -> property False
467-- many_empty :: Property
468-- many_empty =
469-- property (case S.parse (P.many FL.toList (P.die "die")) (S.fromList [1 :: Int]) of
470-- Right res_list -> checkListEqual res_list ([] :: [Int])
471-- Left _ -> property False)
473some :: Property
474some =
475 forAll (listOf (chooseInt (0, 1))) $ \genLs ->
476 let
477 ls = 0 : genLs
478 concatFold = FL.Fold (\concatList curr_list -> return $ concatList ++ curr_list) (return []) return
479 prsr = P.some concatFold $ P.sliceSepBy (== 1) FL.toList
480 in
481 case S.parse prsr (S.fromList ls) of
482 Right res_list -> res_list == Prelude.filter (== 0) ls
483 Left _ -> False
485-- someFail :: Property
486-- someFail =
487-- property (case S.parse (P.some FL.toList (P.die "die")) (S.fromList [1 :: Int]) of
488-- Right _ -> False
489-- Left _ -> True)
491-------------------------------------------------------------------------------
492-- Instances
493-------------------------------------------------------------------------------
495applicative :: Property
496applicative =
497 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
498 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
499 let parser =
500 (,)
501 <$> P.take (length list1) FL.toList
502 <*> P.take (length list2) FL.toList
503 in monadicIO $ do
504 (olist1, olist2) <-
505 run $ S.parse parser (S.fromList $ list1 ++ list2)
506 listEquals (==) olist1 list1
507 listEquals (==) olist2 list2
509sequence :: Property
510sequence =
511 forAll (vectorOf 11 (listOf (chooseAny :: Gen Int))) $ \ ins ->
512 let parsers = fmap (\xs -> P.take (length xs) FL.toList) ins
513 in monadicIO $ do
514 outs <- run $
515 S.parse
516 (Prelude.sequence parsers)
517 (S.fromList $ concat ins)
518 listEquals (==) outs ins
520monad :: Property
521monad =
522 forAll (listOf (chooseAny :: Gen Int)) $ \ list1 ->
523 forAll (listOf (chooseAny :: Gen Int)) $ \ list2 ->
524 let parser = do
525 olist1 <- P.take (length list1) FL.toList
526 olist2 <- P.take (length list2) FL.toList
527 return (olist1, olist2)
528 in monadicIO $ do
529 (olist1, olist2) <-
530 run $ S.parse parser (S.fromList $ list1 ++ list2)
531 listEquals (==) olist1 list1
532 listEquals (==) olist2 list2
534-------------------------------------------------------------------------------
535-- Stream parsing
536-------------------------------------------------------------------------------
538parseMany :: Property
539parseMany =
540 forAll (chooseInt (1,100)) $ \len ->
541 forAll (listOf (vectorOf len (chooseAny :: Gen Int))) $ \ ins ->
542 monadicIO $ do
543 outs <-
544 ( run
545 $ S.toList
546 $ S.parseMany
547 (P.take len FL.toList) (S.fromList $ concat ins)
548 )
549 listEquals (==) outs ins
551-------------------------------------------------------------------------------
552-- Test for a particular case hit during fs events testing
553-------------------------------------------------------------------------------
555evId :: [Word8]
556evId = [96,238,17,9,0,0,0,0]
558evFlags :: [Word8]
559evFlags = [0,4,1,0,0,0,0,0]
561evPathLen :: [Word8]
562evPathLen = [71,0,0,0,0,0,0,0]
564evPath :: [Word8]
565evPath =
566 [47,85,115,101,114,115,47,118,111,108,47,118,101,109,98,97,47,99,111,109
567 ,112,111,115,101,119,101 ,108,108,45,116,101,99,104,47,69,110,103,47,112
568 ,114,111,106,101,99,116,115,47,115,116,114,101,97,109,108,121,47,115,116
569 ,114,101,97,109,108,121,47,116,109,112,47,122,122
570 ]
572event :: [Word8]
573event = evId ++ evFlags ++ evPathLen ++ evPath
575data Event = Event
576 { eventId :: Word64
577 , eventFlags :: Word32
578 , eventAbsPath :: A.Array Word8
579 } deriving (Show, Ord, Eq)
581readOneEvent :: P.Parser IO Word8 Event
582readOneEvent = do
583 arr <- P.takeEQ 24 (A.writeN 24)
584 let arr1 = A.unsafeCast arr :: A.Array Word64
585 eid = A.unsafeIndex arr1 0
586 eflags = A.unsafeIndex arr1 1
587 pathLen = fromIntegral $ A.unsafeIndex arr1 2
588 -- XXX handle if pathLen is 0
589 path <- P.takeEQ pathLen (A.writeN pathLen)
590 return $ Event
591 { eventId = eid
592 , eventFlags = fromIntegral eflags
593 , eventAbsPath = path
594 }
596parseMany2Events :: Property
597parseMany2Events =
598 monadicIO $ do
599 xs <-
600 ( run
601 $ S.toList
602 $ S.parseMany readOneEvent
603 $ S.fromList (concat (replicate 2 event))
604 )
605 assert (length xs == 2)
606 -- XXX assuming little endian machine
607 let ev = Event
608 { eventId = 152170080
609 , eventFlags = 66560
610 , eventAbsPath = A.fromList evPath
611 }
612 in listEquals (==) xs (replicate 2 ev)
614-------------------------------------------------------------------------------
615-- Main
616-------------------------------------------------------------------------------
618main :: IO ()
619main =
620 hspec $
621 H.parallel $
622 modifyMaxSuccess (const maxTestCount) $ do
623 describe "Instances" $ do
624 prop "applicative" applicative
625 prop "monad" monad
626 prop "sequence" sequence
628 describe "Stream parsing" $ do
629 prop "parseMany" parseMany
630 prop "parseMany2Events" parseMany2Events
632 describe "test for accumulator" $ do
633 prop "P.fromFold FL.sum = FL.sum" fromFold
634 prop "P.any = Prelude.any" Main.any
635 prop "P.all = Prelude.all" Main.all
636 prop "yield value provided" yield
637 prop "yield monadic value provided" yieldM
638 prop "fail err = Left (SomeException (ParseError err))" parserFail
639 prop "always fail" die
640 prop "always fail but monadic" dieM
642 describe "test for element parser" $ do
643 prop "peek = head with list length > 0" peekPass
644 prop "peek fail on []" peekFail
645 prop "eof pass on []" eofPass
646 prop "eof fail on non-empty list" eofFail
647 prop "first element exists and >= mid_value" satisfyPass
648 prop "check first element exists and satisfies predicate" satisfy
650 describe "test for sequence parser" $ do
651 prop "P.take = Prelude.take" Main.take
652 prop "P.takeEQ = Prelude.take when len >= n" takeEQPass
653 prop "P.takeEQ = Prelude.take when len >= n and fail otherwise" Main.takeEQ
654 prop "P.takeGE n ls = ls when len >= n" takeGEPass
655 prop "P.takeGE n ls = ls when len >= n and fail otherwise" Main.takeGE
656 -- prop "lookAhead . take n >> lookAhead . take n = lookAhead . take n" lookAheadPass
657 -- prop "Fail when stream length exceeded" lookAheadFail
658 -- prop "lookAhead . take n >> lookAhead . take n = lookAhead . take n, else fail" lookAhead
659 prop "P.takeWhile = Prelude.takeWhile" Main.takeWhile
660 prop "P.takeWhile = Prelude.takeWhile if taken something, else check why failed" takeWhile1
661 prop "P.sliceSepBy = Prelude.takeWhile (not . predicate)" sliceSepBy
662 prop "P.sliceSepByMax n predicate = Prelude.take n (Prelude.takeWhile (not . predicate))" sliceSepByMax
663 -- prop "" splitWithPass
664 -- prop "" splitWithFailLeft
665 -- prop "" splitWithFailRight
666 -- prop "" splitWithFailBoth
667 -- prop "" teeWithPass
668 -- prop "" teeWithFailLeft
669 -- prop "" teeWithFailRight
670 -- prop "" teeWithFailBoth
671 -- prop "" deintercalate
672 -- prop "" shortestPass
673 -- prop "" shortestFailLeft
674 -- prop "" shortestFailRight
675 -- prop "" shortestFailBoth
676 prop "P.many concatFold $ P.sliceSepBy (== 1) FL.toList = Prelude.filter (== 0)" many
677 -- prop "[] due to parser being die" many_empty
678 prop "P.some concatFold $ P.sliceSepBy (== 1) FL.toList = Prelude.filter (== 0)" some
679 -- prop "fail due to parser being die" someFail
680 takeProperties