git.iko.soy/typeable/pandoc
on master help sign in
Add some unit tests for Writers.Docbook
f22ce4fNeil Mayhew
tests/Tests/Writers/Docbook.hsnew file+52
@@ -0,0 +1,52 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+module Tests.Writers.Docbook (tests) where
3+
4+import Test.Framework
5+import Text.Pandoc.Builder
6+import Text.Pandoc
7+import Tests.Helpers
8+import Tests.Arbitrary()
9+
10+docbook :: (ToString a, ToPandoc a) => a -> String
11+docbook = writeDocbook def{ writerWrapText = False } . toPandoc
12+
13+{-
14+ "my test" =: X =?> Y
15+
16+is shorthand for
17+
18+ test docbook "my test" $ X =?> Y
19+
20+which is in turn shorthand for
21+
22+ test docbook "my test" (X,Y)
23+-}
24+
25+infix 4 =:
26+(=:) :: (ToString a, ToPandoc a)
27+ => String -> (a, String) -> Test
28+(=:) = test docbook
29+
30+lineblock :: Blocks
31+lineblock = para ("some text" <> linebreak <>
32+ "and more lines" <> linebreak <>
33+ "and again")
34+lineblock_out :: String
35+lineblock_out = "<literallayout>some text\n" ++
36+ "and more lines\n" ++
37+ "and again</literallayout>"
38+
39+tests :: [Test]
40+tests = [ testGroup "line blocks"
41+ [ "none" =: para "This is a test"
42+ =?> "<para>\n This is a test\n</para>"
43+ , "basic" =: lineblock
44+ =?> lineblock_out
45+ , "blockquote" =: blockQuote lineblock
46+ =?> ("<blockquote>\n" ++ lineblock_out ++ "\n</blockquote>")
47+ , "footnote" =: para ("This is a test" <> note lineblock <> " of footnotes")
48+ =?> ("<para>\n This is a test<footnote>\n" ++
49+ lineblock_out ++
50+ "\n </footnote> of footnotes\n</para>")
51+ ]
52+ ]
tests/test-pandoc.hs+2
@@ -12,6 +12,7 @@ import qualified Tests.Readers.RST
12import qualified Tests.Writers.ConTeXt
12import qualified Tests.Writers.ConTeXt
13import qualified Tests.Writers.LaTeX
13import qualified Tests.Writers.LaTeX
14import qualified Tests.Writers.HTML
14import qualified Tests.Writers.HTML
15+import qualified Tests.Writers.Docbook
15import qualified Tests.Writers.Native
16import qualified Tests.Writers.Native
16import qualified Tests.Writers.Markdown
17import qualified Tests.Writers.Markdown
17import qualified Tests.Shared
18import qualified Tests.Shared
@@ -27,6 +28,7 @@ tests = [ testGroup "Old" Tests.Old.tests
27 , testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
28 , testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
28 , testGroup "LaTeX" Tests.Writers.LaTeX.tests
29 , testGroup "LaTeX" Tests.Writers.LaTeX.tests
29 , testGroup "HTML" Tests.Writers.HTML.tests
30 , testGroup "HTML" Tests.Writers.HTML.tests
31+ , testGroup "Docbook" Tests.Writers.Docbook.tests
30 , testGroup "Markdown" Tests.Writers.Markdown.tests
32 , testGroup "Markdown" Tests.Writers.Markdown.tests
31 ]
33 ]
32 , testGroup "Readers"
34 , testGroup "Readers"