From 373d05601a37caa6ea84c1ec46d3ef5c3c28a75f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 22 Jan 2011 12:28:30 -0800 Subject: Added native writer tests. --- pandoc.cabal | 1 + tests/Tests/Arbitrary.hs | 6 ++---- tests/Tests/Writers/Native.hs | 20 ++++++++++++++++++++ tests/test-pandoc.hs | 2 ++ 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 tests/Tests/Writers/Native.hs 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 ] ] -- cgit v1.2.3