diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-11-27 11:52:42 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-01-25 17:07:39 +0100 |
commit | 1673bda95e83aa124241ffdf14d25282d4cad055 (patch) | |
tree | 08af8f0afda6fb46341f348a96b64f0bda33a80a /tests/Tests/Helpers.hs | |
parent | b969863e0787ae560d55ca14238a94ac28d302cf (diff) | |
download | pandoc-1673bda95e83aa124241ffdf14d25282d4cad055.tar.gz |
Update tests to work with runPure.
Diffstat (limited to 'tests/Tests/Helpers.hs')
-rw-r--r-- | tests/Tests/Helpers.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/Tests/Helpers.hs b/tests/Tests/Helpers.hs index 69f40fe48..28a11266b 100644 --- a/tests/Tests/Helpers.hs +++ b/tests/Tests/Helpers.hs @@ -3,6 +3,7 @@ module Tests.Helpers ( test , (=?>) + , purely , property , ToString(..) , ToPandoc(..) @@ -11,6 +12,7 @@ module Tests.Helpers ( test import Text.Pandoc.Definition import Text.Pandoc.Builder (Inlines, Blocks, doc, plain) +import Text.Pandoc.Class import Test.Framework import Test.Framework.Providers.HUnit import Test.Framework.Providers.QuickCheck2 @@ -49,6 +51,9 @@ vividize (Second s) = "+ " ++ s property :: QP.Testable a => TestName -> a -> Test property = testProperty +purely :: (b -> PandocPure a) -> b -> a +purely f = either (error . show) id . runPure . f + infix 5 =?> (=?>) :: a -> b -> (a,b) x =?> y = (x, y) @@ -57,17 +62,17 @@ class ToString a where toString :: a -> String instance ToString Pandoc where - toString d = writeNative def{ writerTemplate = s } $ toPandoc d + toString d = purely (writeNative def{ writerTemplate = s }) $ toPandoc d where s = case d of (Pandoc (Meta m) _) | M.null m -> Nothing | otherwise -> Just "" -- need this to get meta output instance ToString Blocks where - toString = writeNative def . toPandoc + toString = purely (writeNative def) . toPandoc instance ToString Inlines where - toString = trimr . writeNative def . toPandoc + toString = trimr . purely (writeNative def) . toPandoc instance ToString String where toString = id |