mirror of
https://github.com/composewell/streamly.git
synced 2024-09-11 11:37:22 +03:00
Add a test case for ParserK.toParser
This commit is contained in:
parent
f64ff6d5b9
commit
7fbc066e73
@ -795,6 +795,29 @@ toParser = do
|
||||
r3 <- runP1 [0,1::Int]
|
||||
fromRight undefined r3 `shouldBe` 0
|
||||
|
||||
-- NOTE: Without fusionBreaker this test would pass even if toParser has
|
||||
-- incorrect implementation because of fusion rules.
|
||||
let p2 =
|
||||
ParserK.toParser
|
||||
$ fusionBreaker
|
||||
$ ParserK.adapt (Parser.takeWhile (<= 3) FL.toList)
|
||||
runP2 xs = Stream.parseBreak p2 (Stream.fromList xs)
|
||||
describe "toParser . adapt" $ do
|
||||
it "(<= 3) for [1, 2, 3, 4, 5]" $ do
|
||||
(a, b) <- runP2 ([1, 2, 3, 4, 5] :: [Int])
|
||||
fromRight undefined a `shouldBe` [1, 2, 3]
|
||||
rest <- Stream.toList b
|
||||
rest `shouldBe` [4, 5]
|
||||
it "(<= 3) for [1, 2, 3]" $ do
|
||||
(a, b) <- runP2 ([1, 2, 3] :: [Int])
|
||||
fromRight undefined a `shouldBe` [1, 2, 3]
|
||||
rest <- Stream.toList b
|
||||
rest `shouldBe` []
|
||||
|
||||
{-# NOINLINE fusionBreaker #-}
|
||||
fusionBreaker :: a -> a
|
||||
fusionBreaker = id
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Main
|
||||
-------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user