aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-01-21 10:23:41 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-01-21 10:23:41 -0800
commitd0726920db29fee60f09c45be2974bf8d9eb464f (patch)
tree023a6dc2c0d5a43048dae7a735dd8f9d2bab72b1 /tests
parent5c35be13625895f52c66f98be81751b49b1b0365 (diff)
downloadpandoc-d0726920db29fee60f09c45be2974bf8d9eb464f.tar.gz
Added Tests.Writers.ConTeXt and helpers for writer tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/Tests/Helpers.hs5
-rw-r--r--tests/Tests/Writers/ConTeXt.hs29
-rw-r--r--tests/test-pandoc.hs4
3 files changed, 38 insertions, 0 deletions
diff --git a/tests/Tests/Helpers.hs b/tests/Tests/Helpers.hs
index 6a677f7b9..f8236a54b 100644
--- a/tests/Tests/Helpers.hs
+++ b/tests/Tests/Helpers.hs
@@ -9,6 +9,11 @@ import Test.Framework
import Test.Framework.Providers.HUnit
import Test.HUnit hiding (Test)
+infix 8 -->
+
+(-->) :: (Eq a, Show a) => a -> a -> Assertion
+a --> e = assertEqual " " e a
+
-- In the first argument, the String is the input, and the Pandoc
-- the output, of a pandoc reader. The input is shown in case
-- the test fails.
diff --git a/tests/Tests/Writers/ConTeXt.hs b/tests/Tests/Writers/ConTeXt.hs
new file mode 100644
index 000000000..cdc98be5d
--- /dev/null
+++ b/tests/Tests/Writers/ConTeXt.hs
@@ -0,0 +1,29 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.ConTeXt (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Text.Pandoc.Shared (removeTrailingSpace)
+import Tests.Helpers
+
+inlines :: Inlines -> String
+inlines = removeTrailingSpace .
+ writeConTeXt defaultWriterOptions . doc . plain
+
+blocks :: Blocks -> String
+blocks = writeConTeXt defaultWriterOptions . doc
+
+tests :: [Test]
+tests = [ testGroup "inline code"
+ [ "with '}'" =:
+ inlines (code "}") --> "\\mono{\\letterclosebrace{}}"
+ , "without '}'" =:
+ inlines (code "]") --> "\\type{]}"
+ ]
+ , testGroup "headers"
+ [ "level 1" =:
+ blocks (header 1 "My header") --> "\\subject{My header}"
+ ]
+ ]
+
diff --git a/tests/test-pandoc.hs b/tests/test-pandoc.hs
index 316060c83..faa2735c9 100644
--- a/tests/test-pandoc.hs
+++ b/tests/test-pandoc.hs
@@ -6,12 +6,16 @@ import Test.Framework
import qualified Tests.Old
import qualified Tests.Readers.LaTeX
+import qualified Tests.Writers.ConTeXt
tests :: [Test]
tests = [ testGroup "Old" Tests.Old.tests
, testGroup "Readers"
[ testGroup "LaTeX" Tests.Readers.LaTeX.tests
]
+ , testGroup "Writers"
+ [ testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
+ ]
]
main :: IO ()