Skip to content

Commit

Permalink
Add a second quickcheck property for sinkParser
Browse files Browse the repository at this point in the history
  • Loading branch information
commandodev authored and Ben Ford committed Jan 30, 2012
1 parent 93b150d commit cfb79fb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion attoparsec-conduit/test/main.hs
Expand Up @@ -44,6 +44,7 @@ testParseWord s = (AC8.string $ C8.pack s) <* AC8.space

main :: IO ()
main = hspecX $ do

describe "parserSink" $ do
let pWord = testParseWord "test"
let src = CL.sourceList $ C8.pack <$> lines "test one two"
Expand All @@ -63,4 +64,12 @@ main = hspecX $ do
\inp inp2 -> not (S.null inp) ==>
let res = runST $ runExceptionT_ $ runResourceT $ CL.sourceList [inp, inp2]
$$ CA.sinkParser $ AC8.takeWhile (/=' ')
in res == C8.takeWhile (/=' ') (inp `mappend` inp2)
in res == C8.takeWhile (/=' ') (inp `mappend` inp2)

prop "parse first word leaves exactly tail" $
\inp inp2 -> not (S.null inp) ==>
let res = runST $ runExceptionT_ $ runResourceT $ do
bsrc <- C.bufferSource $ CL.sourceList [inp, inp2]
_ <- bsrc $$ CA.sinkParser $ AC8.takeWhile (/=' ')
C8.concat <$> (bsrc $$ CL.consume)
in res == C8.dropWhile (/=' ') (inp `mappend` inp2)

0 comments on commit cfb79fb

Please sign in to comment.