aboutsummaryrefslogtreecommitdiff
path: root/tests/Tests
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-06-20 16:23:24 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-06-20 16:23:24 -0700
commit793bfc81fe5cb35efa4e0a718d3a82a67a99aeeb (patch)
treee33e9f5d2a5554895f76c5b25cef168d336faa3b /tests/Tests
parent5d0103606f469a6336beb2f7a90f210dd29485bd (diff)
parenta4508d7fcff0fc80af7b9d03177679860f4d00e6 (diff)
downloadpandoc-793bfc81fe5cb35efa4e0a718d3a82a67a99aeeb.tar.gz
Merge pull request #1361 from jkr/testNormalize
Docx reader tests: Introduce NoNormPandoc type.
Diffstat (limited to 'tests/Tests')
-rw-r--r--tests/Tests/Readers/Docx.hs29
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/Tests/Readers/Docx.hs b/tests/Tests/Readers/Docx.hs
index 3a13641a9..e8fa33241 100644
--- a/tests/Tests/Readers/Docx.hs
+++ b/tests/Tests/Readers/Docx.hs
@@ -7,12 +7,37 @@ import Tests.Helpers
import Test.Framework
import qualified Data.ByteString.Lazy as B
import Text.Pandoc.Readers.Docx
+import Text.Pandoc.Writers.Native (writeNative)
+import qualified Data.Map as M
-compareOutput :: ReaderOptions -> FilePath -> FilePath -> IO (Pandoc, Pandoc)
+-- We define a wrapper around pandoc that doesn't normalize in the
+-- tests. Since we do our own normalization, we want to make sure
+-- we're doing it right.
+
+data NoNormPandoc = NoNormPandoc {unNoNorm :: Pandoc}
+ deriving Show
+
+noNorm :: Pandoc -> NoNormPandoc
+noNorm = NoNormPandoc
+
+instance ToString NoNormPandoc where
+ toString d = writeNative def{ writerStandalone = s } $ toPandoc d
+ where s = case d of
+ NoNormPandoc (Pandoc (Meta m) _)
+ | M.null m -> False
+ | otherwise -> True
+
+instance ToPandoc NoNormPandoc where
+ toPandoc = unNoNorm
+
+compareOutput :: ReaderOptions
+ -> FilePath
+ -> FilePath
+ -> IO (NoNormPandoc, NoNormPandoc)
compareOutput opts docxFile nativeFile = do
df <- B.readFile docxFile
nf <- Prelude.readFile nativeFile
- return $ (readDocx opts df, readNative nf)
+ return $ (noNorm (readDocx opts df), noNorm (readNative nf))
testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO Test
testCompareWithOptsIO opts name docxFile nativeFile = do