aboutsummaryrefslogtreecommitdiff
path: root/tests/Tests/Helpers.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-11-27 11:52:42 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-25 17:07:39 +0100
commit1673bda95e83aa124241ffdf14d25282d4cad055 (patch)
tree08af8f0afda6fb46341f348a96b64f0bda33a80a /tests/Tests/Helpers.hs
parentb969863e0787ae560d55ca14238a94ac28d302cf (diff)
downloadpandoc-1673bda95e83aa124241ffdf14d25282d4cad055.tar.gz
Update tests to work with runPure.
Diffstat (limited to 'tests/Tests/Helpers.hs')
-rw-r--r--tests/Tests/Helpers.hs11
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