on master help sign in
add description for test functions
3fa6710Ahmed Zaheer Dadarkar
test/Streamly/Test/Internal/Data/Parser.hs+35−22
@@ -105,6 +105,18 @@ eofFail =
105 Right _ -> False
105 Right _ -> False
106 Left _ -> True
106 Left _ -> True
107
107
108+satisfyPass :: Property
109+satisfyPass =
110+ forAll (chooseInt (mid_value, max_value)) $ \first_element ->
111+ forAll (listOf (chooseInt (min_value, max_value))) $ \ls_tail ->
112+ let
113+ ls = first_element : ls_tail
114+ predicate = (>= mid_value)
115+ in
116+ case S.parse (P.satisfy predicate) (S.fromList ls) of
117+ Right r -> r == first_element
118+ Left _ -> False
119+
108satisfy :: Property
120satisfy :: Property
109satisfy =
121satisfy =
110 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
122 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
@@ -345,32 +357,33 @@ sliceSepBy =
345main :: IO ()
357main :: IO ()
346main = hspec $ do
358main = hspec $ do
347 describe "test for accumulator" $ do
359 describe "test for accumulator" $ do
348− prop "test fromFold function" fromFold
360+ prop "sum after parsing = sum after folding" fromFold
349− prop "test any function" Main.any
361+ prop "compare parser any with prelude any on predicate: list > mid_value" Main.any
350− prop "test all function" Main.all
362+ prop "compare parser all with prelude all on predicate: list > mid_value" Main.all
351− prop "test yield function" yield
363+ prop "yield value provided" yield
352− prop "test yieldM function" yieldM
364+ prop "yield monadic value provided" yieldM
353− prop "test die function" die
365+ prop "always fail" die
354− prop "test dieM function" dieM
366+ prop "always fail but monadic" dieM
355
367
356 describe "test for element parser" $ do
368 describe "test for element parser" $ do
357− prop "pass test for peek function" peekPass
369+ prop "parsed value = head list when length list >= 1" peekPass
358− prop "fail test for peek function" peekFail
370+ prop "peek fail on empty list" peekFail
359− prop "pass test for eof function" eofPass
371+ prop "eof pass on empty list" eofPass
360− prop "fail test for eof function" eofFail
372+ prop "eof fail on non-empty list" eofFail
361− prop "test for satisfy function" satisfy
373+ prop "first element exists and >= mid_value" satisfyPass
374+ prop "check first element exists and satisfies predicate" satisfy
362
375
363 describe "test for sequence parser" $ do
376 describe "test for sequence parser" $ do
364− prop "test for take function" Main.take
377+ prop "compare parser take with prelude take with value n and list" Main.take
365− prop "pass test for takeEq function" takeEQPass
378+ prop "takeEQ on list of length >= n" takeEQPass
366− prop "test for takeEq function" Main.takeEQ
379+ prop "takeEQ on arbitrary sized list and n" Main.takeEQ
367− prop "pass test for takeGE function" takeGEPass
380+ prop "takeGE on list of length >= n" takeGEPass
368− prop "test for takeGE function" Main.takeGE
381+ prop "takeGE on arbitrary sized list and n" Main.takeGE
369− prop "pass test for LookAhead function" lookAheadPass
382+ prop "parse stream twice without exceeding length of list, then check eq of lists" lookAheadPass
370− prop "test for LookAhead function" lookAhead
383+ prop "parse stream twice, then check eq of lists if not failed, else check why failed" lookAhead
371− prop "test for takeWhile function" Main.takeWhile
384+ prop "compare takeWhile of parser and prelude on list and predicate" Main.takeWhile
372− prop "test for takeWhile1 function" takeWhile1
385+ prop "compare with prelude.takeWhile if taken something, else check why failed" takeWhile1
373− prop "test for sliceSepBy function" sliceSepBy
386+ prop "collect zeros until we see one, do not include one" sliceSepBy
374 -- prop "test for sliceSepByMax function" sliceSepByMax
387 -- prop "test for sliceSepByMax function" sliceSepByMax
375 -- prop "pass test for splitWith function" splitWithPass
388 -- prop "pass test for splitWith function" splitWithPass
376 -- prop "left fail test for splitWith function" splitWithFailLeft
389 -- prop "left fail test for splitWith function" splitWithFailLeft