From 2426a64771339efb4a776799d9bf593d6b8d09a3 Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Sun, 28 Jun 2015 15:54:30 +0200 Subject: Add simple tests for do-notation parsing. --- .../test/Haddock/Backends/Hyperlinker/ParserSpec.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'haddock-api/test/Haddock/Backends') diff --git a/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs b/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs index fa880a37..5e69b446 100644 --- a/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs +++ b/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs @@ -67,6 +67,24 @@ parseSpec = do , TkIdentifier, TkSpace, TkGlyph, TkSpace, TkIdentifier ] + it "should parse do-notation syntax" $ do + "do { foo <- getLine; putStrLn foo }" `shouldParseTo` + [ TkKeyword, TkSpace, TkSpecial, TkSpace + , TkIdentifier, TkSpace, TkGlyph, TkSpace + , TkIdentifier, TkSpecial, TkSpace + , TkIdentifier, TkSpace, TkIdentifier, TkSpace, TkSpecial + ] + + unlines + [ "do" + , " foo <- getLine" + , " putStrLn foo" + ] `shouldParseTo` + [ TkKeyword, TkSpace, TkIdentifier + , TkSpace, TkGlyph, TkSpace, TkIdentifier, TkSpace + , TkIdentifier, TkSpace, TkIdentifier, TkSpace + ] + shouldParseTo :: String -> [TokenType] -> Expectation str `shouldParseTo` tokens = map tkType (parse str) `shouldBe` tokens -- cgit v1.2.3