aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-01-22 12:28:30 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-01-22 12:37:19 -0800
commit373d05601a37caa6ea84c1ec46d3ef5c3c28a75f (patch)
tree0f66fcab854d4d1e71dc566ed82cc5acc914f2ef
parent209b300d6adeb2427c0058b808945ac39f851b24 (diff)
downloadpandoc-373d05601a37caa6ea84c1ec46d3ef5c3c28a75f.tar.gz
Added native writer tests.
-rw-r--r--pandoc.cabal1
-rw-r--r--tests/Tests/Arbitrary.hs6
-rw-r--r--tests/Tests/Writers/Native.hs20
-rw-r--r--tests/test-pandoc.hs2
4 files changed, 25 insertions, 4 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index cb7e52499..39136e3ea 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -349,4 +349,5 @@ Executable test-pandoc
Tests.Helpers
Tests.Arbitrary
Tests.Readers.LaTeX
+ Tests.Writers.Native
Tests.Writers.ConTeXt
diff --git a/tests/Tests/Arbitrary.hs b/tests/Tests/Arbitrary.hs
index 825902e4c..af882889f 100644
--- a/tests/Tests/Arbitrary.hs
+++ b/tests/Tests/Arbitrary.hs
@@ -91,10 +91,8 @@ arbBlock n = frequency $ [ (10, liftM Plain arbitrary)
]
instance Arbitrary Pandoc where
- arbitrary
- = do x1 <- arbitrary
- x2 <- arbitrary
- return $ normalize (Pandoc x1 x2)
+ arbitrary = resize 8 $ liftM normalize
+ $ liftM2 Pandoc arbitrary arbitrary
{-
instance Arbitrary CitationMode where
diff --git a/tests/Tests/Writers/Native.hs b/tests/Tests/Writers/Native.hs
new file mode 100644
index 000000000..234fe938a
--- /dev/null
+++ b/tests/Tests/Writers/Native.hs
@@ -0,0 +1,20 @@
+module Tests.Writers.Native (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Tests.Arbitrary()
+
+p_write_rt :: Pandoc -> Bool
+p_write_rt d =
+ read (writeNative defaultWriterOptions{ writerStandalone = True } d) == d
+
+p_write_blocks_rt :: [Block] -> Bool
+p_write_blocks_rt bs =
+ read (writeNative defaultWriterOptions (Pandoc (Meta [] [] []) bs)) == bs
+
+tests :: [Test]
+tests = [ property "p_write_rt" p_write_rt
+ , property "p_write_blocks_rt" p_write_blocks_rt
+ ]
diff --git a/tests/test-pandoc.hs b/tests/test-pandoc.hs
index faa2735c9..e8f792e2d 100644
--- a/tests/test-pandoc.hs
+++ b/tests/test-pandoc.hs
@@ -7,6 +7,7 @@ import Test.Framework
import qualified Tests.Old
import qualified Tests.Readers.LaTeX
import qualified Tests.Writers.ConTeXt
+import qualified Tests.Writers.Native
tests :: [Test]
tests = [ testGroup "Old" Tests.Old.tests
@@ -15,6 +16,7 @@ tests = [ testGroup "Old" Tests.Old.tests
]
, testGroup "Writers"
[ testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
+ , testGroup "Native" Tests.Writers.Native.tests
]
]