git.iko.soy/typeable/pandoc
on master help sign in
Add some unit tests for Writers.Docbook

These are primarily aimed at testing the new treatment of line breaks, but hopefully other tests can be added more easily now as features and changes are implemented in the writer. Adapted from Tests.Writers.HTML.tests.

commitf22ce4ff283ac48a50d999ee5fad56ac1e4d1dce authorNeil Mayhew <neiljhmayhew@gmail.com> dateFri 11 Apr 2014, 23:19 (13 years ago) parent464d7a8
2 files changed+54
tests/Tests/Writers/Docbook.hs+52 tests/test-pandoc.hs+2
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
1212import qualified Tests.Writers.ConTeXt
1313import qualified Tests.Writers.LaTeX
1414import qualified Tests.Writers.HTML
15+import qualified Tests.Writers.Docbook
1516import qualified Tests.Writers.Native
1617import qualified Tests.Writers.Markdown
1718import qualified Tests.Shared
@@ -27,6 +28,7 @@ tests = [ testGroup "Old" Tests.Old.tests
2728 , testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
2829 , testGroup "LaTeX" Tests.Writers.LaTeX.tests
2930 , testGroup "HTML" Tests.Writers.HTML.tests
31+ , testGroup "Docbook" Tests.Writers.Docbook.tests
3032 , testGroup "Markdown" Tests.Writers.Markdown.tests
3133 ]
3234 , testGroup "Readers"