2011-01-18 23:34:34 -08:00
|
|
|
{-# LANGUAGE TypeSynonymInstances #-}
|
2011-01-13 11:11:55 -08:00
|
|
|
-- Utility functions for the test suite.
|
|
|
|
|
2011-01-13 10:59:44 -08:00
|
|
|
module Tests.Helpers where
|
2011-01-12 14:16:35 +01:00
|
|
|
|
|
|
|
import Text.Pandoc
|
2011-01-18 23:34:34 -08:00
|
|
|
import Text.Pandoc.Builder
|
2011-01-12 14:16:35 +01:00
|
|
|
import Test.Framework
|
|
|
|
import Test.Framework.Providers.HUnit
|
|
|
|
import Test.HUnit hiding (Test)
|
|
|
|
|
2011-01-21 10:23:41 -08:00
|
|
|
infix 8 -->
|
|
|
|
|
|
|
|
(-->) :: (Eq a, Show a) => a -> a -> Assertion
|
|
|
|
a --> e = assertEqual " " e a
|
|
|
|
|
2011-01-19 09:44:53 -08:00
|
|
|
-- In the first argument, the String is the input, and the Pandoc
|
|
|
|
-- the output, of a pandoc reader. The input is shown in case
|
|
|
|
-- the test fails.
|
2011-01-18 23:34:34 -08:00
|
|
|
class Expect a where
|
2011-01-19 09:38:14 -08:00
|
|
|
(=?>) :: (String, Pandoc) -> a -> Assertion
|
2011-01-18 23:34:34 -08:00
|
|
|
|
|
|
|
infix 8 =?>
|
|
|
|
|
|
|
|
(=:) :: TestName -> Assertion -> Test
|
|
|
|
(=:) = testCase
|
|
|
|
|
|
|
|
infix 6 =:
|
|
|
|
|
|
|
|
instance Expect Inlines where
|
2011-01-19 09:44:53 -08:00
|
|
|
(s, Pandoc _ [Para ils]) =?> e = assertEqual (show s) (toList e) ils
|
|
|
|
(s, g) =?> e = assertEqual (show s) (doc $ para e) g
|
2011-01-18 23:34:34 -08:00
|
|
|
|
|
|
|
instance Expect Blocks where
|
2011-01-19 09:44:53 -08:00
|
|
|
(s, Pandoc _ bls) =?> e = assertEqual (show s) (toList e) bls
|
2011-01-18 23:34:34 -08:00
|
|
|
|
|
|
|
instance Expect Pandoc where
|
2011-01-19 09:44:53 -08:00
|
|
|
(s, g) =?> e = assertEqual (show s) e g
|
2011-01-12 14:16:35 +01:00
|
|
|
|