git.iko.soy/typeable/pandoc
on master help sign in
Add new style FB2 tests
commitd99776ea0405143d1b95f740a68b2a67cb0e73dd authorAlexander Krotov <ilabdsf@gmail.com> dateSat 28 Oct 2017, 18:13 (9 years ago) parentb39f782
3 files changed+37
pandoc.cabal+1 test/Tests/Writers/FB2.hs+34 test/test-pandoc.hs+2
pandoc.cabal+1
@@ -594,6 +594,7 @@ test-suite test-pandoc
594594 Tests.Writers.RST
595595 Tests.Writers.TEI
596596 Tests.Writers.Muse
597+ Tests.Writers.FB2
597598 ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind -threaded
598599 default-language: Haskell98
599600
test/Tests/Writers/FB2.hsnew file+34
@@ -0,0 +1,34 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+module Tests.Writers.FB2 (tests) where
3+
4+import Test.Tasty
5+import Tests.Helpers
6+import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
9+
10+fb2 :: String -> String
11+fb2 x = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++
12+ "<FictionBook xmlns=\"http://www.gribuser.ru/xml/fictionbook/2.0\" xmlns:l=\"http://www.w3.org/1999/xlink\"><description><title-info /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section>" ++ x ++ "</section></body></FictionBook>"
13+
14+infix 4 =:
15+(=:) :: (ToString a, ToPandoc a)
16+ => String -> (a, String) -> TestTree
17+(=:) = test (purely (writeFB2 def) . toPandoc)
18+
19+tests :: [TestTree]
20+tests = [ testGroup "block elements"
21+ ["para" =: para "Lorem ipsum cetera."
22+ =?> fb2 "<p>Lorem ipsum cetera.</p>"
23+ ]
24+ , testGroup "inlines"
25+ [
26+ "Emphasis" =: emph ("emphasized")
27+ =?> fb2 "<emphasis>emphasized</emphasis>"
28+ ]
29+ , "bullet list" =: bulletList [ plain $ text "first"
30+ , plain $ text "second"
31+ , plain $ text "third"
32+ ]
33+ =?> fb2 "<p>\x2022 first</p><p>\x2022 second</p><p>\x2022 third</p>"
34+ ]
test/test-pandoc.hs+2
@@ -23,6 +23,7 @@ import qualified Tests.Writers.AsciiDoc
2323import qualified Tests.Writers.ConTeXt
2424import qualified Tests.Writers.Docbook
2525import qualified Tests.Writers.Docx
26+import qualified Tests.Writers.FB2
2627import qualified Tests.Writers.HTML
2728import qualified Tests.Writers.LaTeX
2829import qualified Tests.Writers.Markdown
@@ -52,6 +53,7 @@ tests = testGroup "pandoc tests" [ Tests.Command.tests
5253 , testGroup "RST" Tests.Writers.RST.tests
5354 , testGroup "TEI" Tests.Writers.TEI.tests
5455 , testGroup "Muse" Tests.Writers.Muse.tests
56+ , testGroup "FB2" Tests.Writers.FB2.tests
5557 ]
5658 , testGroup "Readers"
5759 [ testGroup "LaTeX" Tests.Readers.LaTeX.tests