[commit: haddock] master: Add tests related to parsing basic language constructs. (86ccbbf)

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


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

On branch  : master
Link       : http://git.haskell.org/haddock.git/commitdiff/86ccbbf208fad2b27d2d76d9a32a80b452274d2e

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

commit 86ccbbf208fad2b27d2d76d9a32a80b452274d2e
Author: Łukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date:   Sun Jun 28 12:41:08 2015 +0200

    Add tests related to parsing basic language constructs.


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

86ccbbf208fad2b27d2d76d9a32a80b452274d2e
 .../test/Haddock/Backends/Hyperlinker/ParserSpec.hs  | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs b/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs
index d596422..fa880a3 100644
--- a/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs
+++ b/haddock-api/test/Haddock/Backends/Hyperlinker/ParserSpec.hs
@@ -47,6 +47,26 @@ parseSpec = do
         "x # y" `shouldParseTo`
             [TkIdentifier, TkSpace, TkCpp, TkSpace,TkIdentifier]
 
+    it "should distinguish basic language constructs" $ do
+        "(* 2) <$> (\"abc\", foo)" `shouldParseTo`
+            [ TkSpecial, TkOperator, TkSpace, TkNumber, TkSpecial
+            , TkSpace, TkOperator, TkSpace
+            , TkSpecial, TkString, TkSpecial, TkSpace, TkIdentifier, TkSpecial
+            ]
+        "let foo' = foo in foo' + foo'" `shouldParseTo`
+            [ TkKeyword, TkSpace, TkIdentifier
+            , TkSpace, TkGlyph, TkSpace
+            , TkIdentifier, TkSpace, TkKeyword, TkSpace
+            , TkIdentifier, TkSpace, TkOperator, TkSpace, TkIdentifier
+            ]
+        "square x = y^2 where y = x" `shouldParseTo`
+            [ TkIdentifier, TkSpace, TkIdentifier
+            , TkSpace, TkGlyph, TkSpace
+            , TkIdentifier, TkOperator, TkNumber
+            , TkSpace, TkKeyword, TkSpace
+            , TkIdentifier, TkSpace, TkGlyph, TkSpace, TkIdentifier
+            ]
+
 
 shouldParseTo :: String -> [TokenType] -> Expectation
 str `shouldParseTo` tokens = map tkType (parse str) `shouldBe` tokens



More information about the ghc-commits mailing list