aboutsummaryrefslogtreecommitdiff
path: root/haddock-library/test/Documentation/Haddock/ParserSpec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'haddock-library/test/Documentation/Haddock/ParserSpec.hs')
-rw-r--r--haddock-library/test/Documentation/Haddock/ParserSpec.hs24
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))