git.iko.soy/typeable/pandoc
on master help sign in
Added native writer tests.
commit373d05601a37caa6ea84c1ec46d3ef5c3c28a75f authorJohn MacFarlane <jgm@berkeley.edu> dateSat 22 Jan 2011, 12:28 (16 years ago) parent209b300
4 files changed+25−4
pandoc.cabal+1 tests/Tests/Arbitrary.hs+2−4 tests/Tests/Writers/Native.hs+20 tests/test-pandoc.hs+2
pandoc.cabal+1
@@ -349,4 +349,5 @@ Executable test-pandoc
349349 Tests.Helpers
350350 Tests.Arbitrary
351351 Tests.Readers.LaTeX
352+ Tests.Writers.Native
352353 Tests.Writers.ConTeXt
tests/Tests/Arbitrary.hs+2−4
@@ -91,10 +91,8 @@ arbBlock n = frequency $ [ (10, liftM Plain arbitrary)
9191 ]
9292
9393instance Arbitrary Pandoc where
94− arbitrary
95− = do x1 <- arbitrary
96− x2 <- arbitrary
97− return $ normalize (Pandoc x1 x2)
94+ arbitrary = resize 8 $ liftM normalize
95+ $ liftM2 Pandoc arbitrary arbitrary
9896
9997{-
10098instance Arbitrary CitationMode where
tests/Tests/Writers/Native.hsnew file+20
@@ -0,0 +1,20 @@
1+module Tests.Writers.Native (tests) where
2+
3+import Test.Framework
4+import Text.Pandoc.Builder
5+import Text.Pandoc
6+import Tests.Helpers
7+import Tests.Arbitrary()
8+
9+p_write_rt :: Pandoc -> Bool
10+p_write_rt d =
11+ read (writeNative defaultWriterOptions{ writerStandalone = True } d) == d
12+
13+p_write_blocks_rt :: [Block] -> Bool
14+p_write_blocks_rt bs =
15+ read (writeNative defaultWriterOptions (Pandoc (Meta [] [] []) bs)) == bs
16+
17+tests :: [Test]
18+tests = [ property "p_write_rt" p_write_rt
19+ , property "p_write_blocks_rt" p_write_blocks_rt
20+ ]
tests/test-pandoc.hs+2
@@ -7,6 +7,7 @@ import Test.Framework
77import qualified Tests.Old
88import qualified Tests.Readers.LaTeX
99import qualified Tests.Writers.ConTeXt
10+import qualified Tests.Writers.Native
1011
1112tests :: [Test]
1213tests = [ testGroup "Old" Tests.Old.tests
@@ -15,6 +16,7 @@ tests = [ testGroup "Old" Tests.Old.tests
1516 ]
1617 , testGroup "Writers"
1718 [ testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
19+ , testGroup "Native" Tests.Writers.Native.tests
1820 ]
1921 ]
2022