[commit: haddock] master: Add simple tests for do-notation parsing. (2426a64)

git at git.haskell.org git at git.haskell.org
Wed Jul 8 08:41:19 UTC 2015


Repository : ssh://git@git.haskell.org/haddock

On branch  : master
Link       : http://git.haskell.org/haddock.git/commitdiff/2426a64771339efb4a776799d9bf593d6b8d09a3

>---------------------------------------------------------------

commit 2426a64771339efb4a776799d9bf593d6b8d09a3
Author: Łukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date:   Sun Jun 28 15:54:30 2015 +0200

    Add simple tests for do-notation parsing.


>---------------------------------------------------------------

2426a64771339efb4a776799d9bf593d6b8d09a3
 .../test/Haddock/Backends/Hyperlinker/ParserSpec.hs    | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs b/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs
index fa880a3..5e69b44 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



More information about the ghc-commits mailing list