diff options
author | Simon Hengel <sol@typeful.net> | 2014-11-16 08:58:40 +0800 |
---|---|---|
committer | Simon Hengel <sol@typeful.net> | 2014-11-16 10:20:19 +0800 |
commit | 06517a6a4c5c6c7a89ea4ad57d85ffc458393a07 (patch) | |
tree | aa06a22a299eb9d8f7e5efa5528a7c31534bd6d3 /haddock-library/test/Documentation/Haddock/ParserSpec.hs | |
parent | c2b84c0c55bce1120db9826391de0466c33b3062 (diff) |
(wip) Add support for @since (closes #26)
Diffstat (limited to 'haddock-library/test/Documentation/Haddock/ParserSpec.hs')
-rw-r--r-- | haddock-library/test/Documentation/Haddock/ParserSpec.hs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/haddock-library/test/Documentation/Haddock/ParserSpec.hs b/haddock-library/test/Documentation/Haddock/ParserSpec.hs index 5550e836..7b0ef78d 100644 --- a/haddock-library/test/Documentation/Haddock/ParserSpec.hs +++ b/haddock-library/test/Documentation/Haddock/ParserSpec.hs @@ -22,8 +22,8 @@ instance IsString (Doc String) where instance IsString a => IsString (Maybe a) where fromString = Just . fromString -parseParas :: String -> Doc String -parseParas = Parse.toRegular . Parse.parseParas +parseParas :: String -> (Maybe Version, Doc String) +parseParas = fmap Parse.toRegular . Parse.parseParas parseString :: String -> Doc String parseString = Parse.toRegular . Parse.parseString @@ -358,12 +358,30 @@ spec = do describe "parseParas" $ do let infix 1 `shouldParseTo` shouldParseTo :: String -> Doc String -> Expectation - shouldParseTo input ast = parseParas input `shouldBe` ast + shouldParseTo input ast = snd (parseParas input) `shouldBe` ast it "is total" $ do property $ \xs -> (length . show . parseParas) xs `shouldSatisfy` (> 0) + context "when parsing @since" $ do + it "adds specified version to the result" $ do + parseParas "@since 0.5.0" `shouldBe` (Just [0,5,0], DocEmpty) + + it "ignores trailing whitespace" $ do + parseParas "@since 0.5.0 \t " `shouldBe` (Just [0,5,0], DocEmpty) + + it "does not allow trailing input" $ do + parseParas "@since 0.5.0 foo" `shouldBe` (Nothing, DocParagraph "@since 0.5.0 foo") + + context "when given multiple times" $ do + it "gives last occurrence precedence" $ do + (parseParas . unlines) [ + "@since 0.5.0" + , "@since 0.6.0" + , "@since 0.7.0" + ] `shouldBe` (Just [0,7,0], DocEmpty) + context "when parsing text paragraphs" $ do let filterSpecial = filter (`notElem` (".(=#-[*`\v\f\n\t\r\\\"'_/@<> " :: String)) |