@@ -105,6 +105,18 @@ eofFail =
105105 Right _ -> False
106106 Left _ -> True
107107
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+
108120satisfy :: Property
109121satisfy =
110122 forAll (listOf (chooseInt (min_value, max_value))) $ \ls ->
@@ -345,32 +357,33 @@ sliceSepBy =
345357main :: IO ()
346358main = hspec $ do
347359 describe "test for accumulator" $ do
348− prop "test fromFold function" fromFold
349− prop "test any function" Main.any
350− prop "test all function" Main.all
351− prop "test yield function" yield
352− prop "test yieldM function" yieldM
353− prop "test die function" die
354− prop "test dieM function" dieM
360+ prop "sum after parsing = sum after folding" fromFold
361+ prop "compare parser any with prelude any on predicate: list > mid_value" Main.any
362+ prop "compare parser all with prelude all on predicate: list > mid_value" Main.all
363+ prop "yield value provided" yield
364+ prop "yield monadic value provided" yieldM
365+ prop "always fail" die
366+ prop "always fail but monadic" dieM
355367
356368 describe "test for element parser" $ do
357− prop "pass test for peek function" peekPass
358− prop "fail test for peek function" peekFail
359− prop "pass test for eof function" eofPass
360− prop "fail test for eof function" eofFail
361− prop "test for satisfy function" satisfy
369+ prop "parsed value = head list when length list >= 1" peekPass
370+ prop "peek fail on empty list" peekFail
371+ prop "eof pass on empty list" eofPass
372+ prop "eof fail on non-empty list" eofFail
373+ prop "first element exists and >= mid_value" satisfyPass
374+ prop "check first element exists and satisfies predicate" satisfy
362375
363376 describe "test for sequence parser" $ do
364− prop "test for take function" Main.take
365− prop "pass test for takeEq function" takeEQPass
366− prop "test for takeEq function" Main.takeEQ
367− prop "pass test for takeGE function" takeGEPass
368− prop "test for takeGE function" Main.takeGE
369− prop "pass test for LookAhead function" lookAheadPass
370− prop "test for LookAhead function" lookAhead
371− prop "test for takeWhile function" Main.takeWhile
372− prop "test for takeWhile1 function" takeWhile1
373− prop "test for sliceSepBy function" sliceSepBy
377+ prop "compare parser take with prelude take with value n and list" Main.take
378+ prop "takeEQ on list of length >= n" takeEQPass
379+ prop "takeEQ on arbitrary sized list and n" Main.takeEQ
380+ prop "takeGE on list of length >= n" takeGEPass
381+ prop "takeGE on arbitrary sized list and n" Main.takeGE
382+ prop "parse stream twice without exceeding length of list, then check eq of lists" lookAheadPass
383+ prop "parse stream twice, then check eq of lists if not failed, else check why failed" lookAhead
384+ prop "compare takeWhile of parser and prelude on list and predicate" Main.takeWhile
385+ prop "compare with prelude.takeWhile if taken something, else check why failed" takeWhile1
386+ prop "collect zeros until we see one, do not include one" sliceSepBy
374387 -- prop "test for sliceSepByMax function" sliceSepByMax
375388 -- prop "pass test for splitWith function" splitWithPass
376389 -- prop "left fail test for splitWith function" splitWithFailLeft