diff options
Diffstat (limited to 'test/Tests')
-rw-r--r-- | test/Tests/Command.hs | 31 | ||||
-rw-r--r-- | test/Tests/Helpers.hs | 25 | ||||
-rw-r--r-- | test/Tests/Old.hs | 28 | ||||
-rw-r--r-- | test/Tests/Readers/Docx.hs | 14 | ||||
-rw-r--r-- | test/Tests/Readers/EPUB.hs | 10 | ||||
-rw-r--r-- | test/Tests/Readers/HTML.hs | 5 | ||||
-rw-r--r-- | test/Tests/Readers/LaTeX.hs | 5 | ||||
-rw-r--r-- | test/Tests/Readers/Markdown.hs | 5 | ||||
-rw-r--r-- | test/Tests/Readers/Odt.hs | 8 | ||||
-rw-r--r-- | test/Tests/Readers/Org.hs | 7 | ||||
-rw-r--r-- | test/Tests/Readers/RST.hs | 8 | ||||
-rw-r--r-- | test/Tests/Readers/Txt2Tags.hs | 8 | ||||
-rw-r--r-- | test/Tests/Shared.hs | 8 | ||||
-rw-r--r-- | test/Tests/Writers/AsciiDoc.hs | 6 | ||||
-rw-r--r-- | test/Tests/Writers/ConTeXt.hs | 6 | ||||
-rw-r--r-- | test/Tests/Writers/Docbook.hs | 6 | ||||
-rw-r--r-- | test/Tests/Writers/Docx.hs | 12 | ||||
-rw-r--r-- | test/Tests/Writers/HTML.hs | 6 | ||||
-rw-r--r-- | test/Tests/Writers/Markdown.hs | 6 | ||||
-rw-r--r-- | test/Tests/Writers/Native.hs | 5 | ||||
-rw-r--r-- | test/Tests/Writers/Org.hs | 6 | ||||
-rw-r--r-- | test/Tests/Writers/Plain.hs | 6 | ||||
-rw-r--r-- | test/Tests/Writers/RST.hs | 6 | ||||
-rw-r--r-- | test/Tests/Writers/TEI.hs | 6 |
24 files changed, 113 insertions, 120 deletions
diff --git a/test/Tests/Command.hs b/test/Tests/Command.hs index ab0402b4d..48ace3e95 100644 --- a/test/Tests/Command.hs +++ b/test/Tests/Command.hs @@ -1,21 +1,20 @@ module Tests.Command (findPandoc, runTest, tests) where -import Tests.Helpers -import Test.Framework -import Test.Framework.Providers.HUnit -import Test.HUnit ( assertBool ) -import System.FilePath ( (</>), takeDirectory, splitDirectories, - joinPath ) -import System.Process +import Data.Algorithm.Diff +import Data.List (isSuffixOf) +import Prelude hiding (readFile) import System.Directory import System.Exit +import System.FilePath (joinPath, splitDirectories, takeDirectory, (</>)) +import System.Process +import Test.Framework +import Test.Framework.Providers.HUnit +import Test.HUnit (assertBool) +import Tests.Helpers import Text.Pandoc -import Data.Algorithm.Diff -import Prelude hiding ( readFile ) -import qualified Text.Pandoc.UTF8 as UTF8 -import Data.List (isSuffixOf) import Text.Pandoc.Shared (trimr) +import qualified Text.Pandoc.UTF8 as UTF8 -- | Run a test with normalize function, return True if test passed. runTest :: String -- ^ Title of test @@ -25,9 +24,9 @@ runTest :: String -- ^ Title of test -> Test runTest testname cmd inp norm = testCase testname $ do let cmd' = cmd ++ " --quiet --data-dir ../data" - let findDynlibDir [] = Nothing + let findDynlibDir [] = Nothing findDynlibDir ("build":xs) = Just $ joinPath (reverse xs) </> "build" - findDynlibDir (_:xs) = findDynlibDir xs + findDynlibDir (_:xs) = findDynlibDir xs let mbDynlibDir = findDynlibDir (reverse $ splitDirectories $ takeDirectory $ takeWhile (/=' ') cmd) let dynlibEnv = case mbDynlibDir of @@ -58,15 +57,15 @@ tests = buildTest $ do isCodeBlock :: Block -> Bool isCodeBlock (CodeBlock _ _) = True -isCodeBlock _ = False +isCodeBlock _ = False extractCode :: Block -> String extractCode (CodeBlock _ code) = code -extractCode _ = "" +extractCode _ = "" dropPercent :: String -> String dropPercent ('%':xs) = dropWhile (== ' ') xs -dropPercent xs = xs +dropPercent xs = xs runCommandTest :: FilePath -> (Int, String) -> IO Test runCommandTest pandocpath (num, code) = do diff --git a/test/Tests/Helpers.hs b/test/Tests/Helpers.hs index ad8b31364..bf9888157 100644 --- a/test/Tests/Helpers.hs +++ b/test/Tests/Helpers.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE TypeSynonymInstances #-} -- Utility functions for the test suite. module Tests.Helpers ( test @@ -13,24 +14,24 @@ module Tests.Helpers ( test ) where -import Text.Pandoc.Definition -import Text.Pandoc.Builder (Inlines, Blocks, doc, plain) -import Text.Pandoc.Class +import Data.Algorithm.Diff +import qualified Data.Map as M +import System.Directory +import System.Environment.Executable (getExecutablePath) +import System.Exit +import System.FilePath import Test.Framework import Test.Framework.Providers.HUnit import Test.Framework.Providers.QuickCheck2 import Test.HUnit (assertBool) -import Text.Pandoc.Shared (trimr) +import qualified Test.QuickCheck.Property as QP +import Text.Pandoc.Builder (Blocks, Inlines, doc, plain) +import Text.Pandoc.Class +import Text.Pandoc.Definition import Text.Pandoc.Options +import Text.Pandoc.Shared (trimr) import Text.Pandoc.Writers.Native (writeNative) import Text.Printf -import System.Environment.Executable (getExecutablePath) -import qualified Test.QuickCheck.Property as QP -import Data.Algorithm.Diff -import qualified Data.Map as M -import System.Exit -import System.Directory -import System.FilePath test :: (ToString a, ToString b, ToString c) => (a -> b) -- ^ function to test diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs index d9877c8a0..253238d21 100644 --- a/test/Tests/Old.hs +++ b/test/Tests/Old.hs @@ -1,16 +1,16 @@ module Tests.Old (tests) where -import Tests.Helpers hiding (test) -import Test.Framework (testGroup, Test ) -import Test.Framework.Providers.HUnit -import Test.HUnit ( assertBool ) -import System.IO ( openTempFile, stderr ) -import System.Process ( runProcess, waitForProcess ) -import System.FilePath ( (</>), (<.>), splitDirectories, joinPath ) +import Data.Algorithm.Diff +import Prelude hiding (readFile) import System.Directory import System.Exit -import Data.Algorithm.Diff -import Prelude hiding ( readFile ) +import System.FilePath (joinPath, splitDirectories, (<.>), (</>)) +import System.IO (openTempFile, stderr) +import System.Process (runProcess, waitForProcess) +import Test.Framework (Test, testGroup) +import Test.Framework.Providers.HUnit +import Test.HUnit (assertBool) +import Tests.Helpers hiding (test) import qualified Text.Pandoc.UTF8 as UTF8 tests :: [Test] @@ -187,10 +187,10 @@ fb2WriterTest title opts inputfile normfile = title (["-t", "fb2"]++opts) inputfile normfile where formatXML xml = splitTags $ zip xml (drop 1 xml) - splitTags [] = [] - splitTags [end] = fst end : snd end : [] + splitTags [] = [] + splitTags [end] = fst end : snd end : [] splitTags (('>','<'):rest) = ">\n" ++ splitTags rest - splitTags ((c,_):rest) = c : splitTags rest + splitTags ((c,_):rest) = c : splitTags rest ignoreBinary = unlines . filter (not . startsWith "<binary ") . lines startsWith tag str = all (uncurry (==)) $ zip tag str @@ -219,9 +219,9 @@ testWithNormalize normalizer testname opts inp norm = testCase testname $ do let normPath = norm let options = ["--quiet", "--data-dir", ".." </> "data"] ++ [inpPath] ++ opts let cmd = pandocPath ++ " " ++ unwords options - let findDynlibDir [] = Nothing + let findDynlibDir [] = Nothing findDynlibDir ("build":xs) = Just $ joinPath (reverse xs) </> "build" - findDynlibDir (_:xs) = findDynlibDir xs + findDynlibDir (_:xs) = findDynlibDir xs let mbDynlibDir = findDynlibDir (reverse $ splitDirectories pandocPath) let dynlibEnv = case mbDynlibDir of Nothing -> [] diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs index e73065012..6e0ea127c 100644 --- a/test/Tests/Readers/Docx.hs +++ b/test/Tests/Readers/Docx.hs @@ -1,15 +1,15 @@ module Tests.Readers.Docx (tests) where -import Text.Pandoc -import Tests.Helpers -import Test.Framework -import Test.HUnit (assertBool) -import Test.Framework.Providers.HUnit +import Codec.Archive.Zip import qualified Data.ByteString.Lazy as B import qualified Data.Map as M -import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory) -import Codec.Archive.Zip +import Test.Framework +import Test.Framework.Providers.HUnit +import Test.HUnit (assertBool) +import Tests.Helpers +import Text.Pandoc import qualified Text.Pandoc.Class as P +import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory) -- We define a wrapper around pandoc that doesn't normalize in the -- tests. Since we do our own normalization, we want to make sure diff --git a/test/Tests/Readers/EPUB.hs b/test/Tests/Readers/EPUB.hs index 9190671c3..f343a75d8 100644 --- a/test/Tests/Readers/EPUB.hs +++ b/test/Tests/Readers/EPUB.hs @@ -1,13 +1,13 @@ module Tests.Readers.EPUB (tests) where -import Text.Pandoc.Options +import qualified Data.ByteString.Lazy as BL import Test.Framework -import Test.HUnit (assertBool) import Test.Framework.Providers.HUnit -import qualified Data.ByteString.Lazy as BL -import Text.Pandoc.Readers.EPUB -import Text.Pandoc.MediaBag (MediaBag, mediaDirectory) +import Test.HUnit (assertBool) import qualified Text.Pandoc.Class as P +import Text.Pandoc.MediaBag (MediaBag, mediaDirectory) +import Text.Pandoc.Options +import Text.Pandoc.Readers.EPUB getMediaBag :: FilePath -> IO MediaBag getMediaBag fp = do diff --git a/test/Tests/Readers/HTML.hs b/test/Tests/Readers/HTML.hs index a1533e42a..0b97f68f8 100644 --- a/test/Tests/Readers/HTML.hs +++ b/test/Tests/Readers/HTML.hs @@ -1,12 +1,11 @@ {-# LANGUAGE OverloadedStrings #-} module Tests.Readers.HTML (tests) where -import Text.Pandoc.Definition import Test.Framework import Tests.Helpers -import Text.Pandoc.Arbitrary() -import Text.Pandoc.Builder import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder html :: String -> Pandoc html = purely $ readHtml def diff --git a/test/Tests/Readers/LaTeX.hs b/test/Tests/Readers/LaTeX.hs index d8572b15b..423735243 100644 --- a/test/Tests/Readers/LaTeX.hs +++ b/test/Tests/Readers/LaTeX.hs @@ -1,12 +1,11 @@ {-# LANGUAGE OverloadedStrings #-} module Tests.Readers.LaTeX (tests) where -import Text.Pandoc.Definition import Test.Framework import Tests.Helpers -import Text.Pandoc.Arbitrary() -import Text.Pandoc.Builder import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder latex :: String -> Pandoc latex = purely $ readLaTeX def{ diff --git a/test/Tests/Readers/Markdown.hs b/test/Tests/Readers/Markdown.hs index 65edf7c38..8903f767f 100644 --- a/test/Tests/Readers/Markdown.hs +++ b/test/Tests/Readers/Markdown.hs @@ -1,12 +1,11 @@ {-# LANGUAGE OverloadedStrings #-} module Tests.Readers.Markdown (tests) where -import Text.Pandoc.Definition import Test.Framework import Tests.Helpers -import Text.Pandoc.Arbitrary() -import Text.Pandoc.Builder import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder markdown :: String -> Pandoc markdown = purely $ readMarkdown def { readerExtensions = diff --git a/test/Tests/Readers/Odt.hs b/test/Tests/Readers/Odt.hs index 653252c5c..c31af38fc 100644 --- a/test/Tests/Readers/Odt.hs +++ b/test/Tests/Readers/Odt.hs @@ -1,11 +1,11 @@ module Tests.Readers.Odt (tests) where -import Control.Monad ( liftM ) -import Text.Pandoc -import Tests.Helpers -import Test.Framework +import Control.Monad (liftM) import qualified Data.ByteString.Lazy as B import qualified Data.Map as M +import Test.Framework +import Tests.Helpers +import Text.Pandoc defopts :: ReaderOptions defopts = def{ readerExtensions = getDefaultExtensions "odt" } diff --git a/test/Tests/Readers/Org.hs b/test/Tests/Readers/Org.hs index ef0530b37..586526815 100644 --- a/test/Tests/Readers/Org.hs +++ b/test/Tests/Readers/Org.hs @@ -1,16 +1,15 @@ {-# LANGUAGE OverloadedStrings #-} module Tests.Readers.Org (tests) where -import Text.Pandoc.Definition +import Data.List (intersperse) import Test.Framework import Tests.Helpers -import Text.Pandoc.Builder import Text.Pandoc -import Data.List (intersperse) +import Text.Pandoc.Builder org :: String -> Pandoc org = purely $ readOrg def{ readerExtensions = getDefaultExtensions "org" } - + orgSmart :: String -> Pandoc orgSmart = purely $ readOrg def { readerExtensions = enableExtension Ext_smart $ getDefaultExtensions "org" } diff --git a/test/Tests/Readers/RST.hs b/test/Tests/Readers/RST.hs index 464720496..7a0a3de28 100644 --- a/test/Tests/Readers/RST.hs +++ b/test/Tests/Readers/RST.hs @@ -1,12 +1,12 @@ -{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} module Tests.Readers.RST (tests) where -import Text.Pandoc.Definition import Test.Framework import Tests.Helpers -import Text.Pandoc.Arbitrary() -import Text.Pandoc.Builder import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder rst :: String -> Pandoc rst = purely $ readRST def{ readerStandalone = True } diff --git a/test/Tests/Readers/Txt2Tags.hs b/test/Tests/Readers/Txt2Tags.hs index 46831d86f..27ced0f5a 100644 --- a/test/Tests/Readers/Txt2Tags.hs +++ b/test/Tests/Readers/Txt2Tags.hs @@ -1,16 +1,14 @@ {-# LANGUAGE OverloadedStrings #-} module Tests.Readers.Txt2Tags (tests) where -import Text.Pandoc.Definition +import Data.List (intersperse) import Test.Framework import Tests.Helpers -import Text.Pandoc.Arbitrary() -import Text.Pandoc.Builder import Text.Pandoc -import Data.List (intersperse) +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder import Text.Pandoc.Class - t2t :: String -> Pandoc -- t2t = handleError . readTxt2Tags (T2TMeta "date" "mtime" "in" "out") def t2t = purely $ \s -> do diff --git a/test/Tests/Shared.hs b/test/Tests/Shared.hs index 9b9aeb6a3..5e056ac3e 100644 --- a/test/Tests/Shared.hs +++ b/test/Tests/Shared.hs @@ -1,12 +1,12 @@ module Tests.Shared (tests) where -import Text.Pandoc.Shared +import System.FilePath.Posix (joinPath) import Test.Framework -import Text.Pandoc.Arbitrary() import Test.Framework.Providers.HUnit -import Test.HUnit ( assertBool, (@?=) ) +import Test.HUnit (assertBool, (@?=)) +import Text.Pandoc.Arbitrary () import Text.Pandoc.Builder -import System.FilePath.Posix (joinPath) +import Text.Pandoc.Shared tests :: [Test] tests = [ testGroup "compactifyDL" diff --git a/test/Tests/Writers/AsciiDoc.hs b/test/Tests/Writers/AsciiDoc.hs index 7103b838b..b4869d628 100644 --- a/test/Tests/Writers/AsciiDoc.hs +++ b/test/Tests/Writers/AsciiDoc.hs @@ -1,10 +1,10 @@ module Tests.Writers.AsciiDoc (tests) where import Test.Framework -import Text.Pandoc.Builder -import Text.Pandoc import Tests.Helpers -import Text.Pandoc.Arbitrary() +import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder asciidoc :: (ToPandoc a) => a -> String asciidoc = purely (writeAsciiDoc def{ writerWrapText = WrapNone }) . toPandoc diff --git a/test/Tests/Writers/ConTeXt.hs b/test/Tests/Writers/ConTeXt.hs index b3e12a571..cbcbe3b94 100644 --- a/test/Tests/Writers/ConTeXt.hs +++ b/test/Tests/Writers/ConTeXt.hs @@ -2,10 +2,10 @@ module Tests.Writers.ConTeXt (tests) where import Test.Framework -import Text.Pandoc.Builder -import Text.Pandoc import Tests.Helpers -import Text.Pandoc.Arbitrary() +import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder context :: (ToPandoc a) => a -> String context = purely (writeConTeXt def) . toPandoc diff --git a/test/Tests/Writers/Docbook.hs b/test/Tests/Writers/Docbook.hs index f34f2495c..5b3270139 100644 --- a/test/Tests/Writers/Docbook.hs +++ b/test/Tests/Writers/Docbook.hs @@ -2,10 +2,10 @@ module Tests.Writers.Docbook (tests) where import Test.Framework -import Text.Pandoc.Builder -import Text.Pandoc import Tests.Helpers -import Text.Pandoc.Arbitrary() +import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder docbook :: (ToPandoc a) => a -> String docbook = docbookWithOpts def{ writerWrapText = WrapNone } diff --git a/test/Tests/Writers/Docx.hs b/test/Tests/Writers/Docx.hs index fd320d224..be32518bf 100644 --- a/test/Tests/Writers/Docx.hs +++ b/test/Tests/Writers/Docx.hs @@ -1,14 +1,14 @@ module Tests.Writers.Docx (tests) where -import Text.Pandoc.Options -import Text.Pandoc.Readers.Native -import Text.Pandoc.Definition -import Tests.Helpers +import System.FilePath ((</>)) import Test.Framework +import Tests.Helpers +import Text.Pandoc.Class (runIOorExplode) +import Text.Pandoc.Definition +import Text.Pandoc.Options import Text.Pandoc.Readers.Docx +import Text.Pandoc.Readers.Native import Text.Pandoc.Writers.Docx -import System.FilePath ((</>)) -import Text.Pandoc.Class (runIOorExplode) type Options = (WriterOptions, ReaderOptions) diff --git a/test/Tests/Writers/HTML.hs b/test/Tests/Writers/HTML.hs index 45de2b042..95450625c 100644 --- a/test/Tests/Writers/HTML.hs +++ b/test/Tests/Writers/HTML.hs @@ -2,10 +2,10 @@ module Tests.Writers.HTML (tests) where import Test.Framework -import Text.Pandoc.Builder -import Text.Pandoc import Tests.Helpers -import Text.Pandoc.Arbitrary() +import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder html :: (ToPandoc a) => a -> String html = purely (writeHtml4String def{ writerWrapText = WrapNone }) . toPandoc diff --git a/test/Tests/Writers/Markdown.hs b/test/Tests/Writers/Markdown.hs index abefe27d5..80ef45170 100644 --- a/test/Tests/Writers/Markdown.hs +++ b/test/Tests/Writers/Markdown.hs @@ -3,10 +3,10 @@ module Tests.Writers.Markdown (tests) where import Test.Framework -import Text.Pandoc.Builder -import Text.Pandoc import Tests.Helpers -import Text.Pandoc.Arbitrary() +import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder defopts :: WriterOptions defopts = def{ writerExtensions = pandocExtensions } diff --git a/test/Tests/Writers/Native.hs b/test/Tests/Writers/Native.hs index 88bad7944..535c761f5 100644 --- a/test/Tests/Writers/Native.hs +++ b/test/Tests/Writers/Native.hs @@ -1,10 +1,9 @@ module Tests.Writers.Native (tests) where import Test.Framework -import Text.Pandoc.Builder -import Text.Pandoc import Tests.Helpers -import Text.Pandoc.Arbitrary() +import Text.Pandoc +import Text.Pandoc.Arbitrary () p_write_rt :: Pandoc -> Bool p_write_rt d = diff --git a/test/Tests/Writers/Org.hs b/test/Tests/Writers/Org.hs index e2c58327b..6943081d3 100644 --- a/test/Tests/Writers/Org.hs +++ b/test/Tests/Writers/Org.hs @@ -2,10 +2,10 @@ module Tests.Writers.Org (tests) where import Test.Framework -import Text.Pandoc.Builder -import Text.Pandoc import Tests.Helpers -import Text.Pandoc.Arbitrary() +import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder infix 4 =: (=:) :: (ToString a, ToPandoc a) diff --git a/test/Tests/Writers/Plain.hs b/test/Tests/Writers/Plain.hs index bead6857c..854ed6b12 100644 --- a/test/Tests/Writers/Plain.hs +++ b/test/Tests/Writers/Plain.hs @@ -2,10 +2,10 @@ module Tests.Writers.Plain (tests) where import Test.Framework -import Text.Pandoc.Builder -import Text.Pandoc import Tests.Helpers -import Text.Pandoc.Arbitrary() +import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder infix 4 =: diff --git a/test/Tests/Writers/RST.hs b/test/Tests/Writers/RST.hs index dd55580c9..1b250f737 100644 --- a/test/Tests/Writers/RST.hs +++ b/test/Tests/Writers/RST.hs @@ -2,10 +2,10 @@ module Tests.Writers.RST (tests) where import Test.Framework -import Text.Pandoc.Builder -import Text.Pandoc import Tests.Helpers -import Text.Pandoc.Arbitrary() +import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder infix 4 =: (=:) :: (ToString a, ToPandoc a) diff --git a/test/Tests/Writers/TEI.hs b/test/Tests/Writers/TEI.hs index 703f565bb..713309784 100644 --- a/test/Tests/Writers/TEI.hs +++ b/test/Tests/Writers/TEI.hs @@ -2,10 +2,10 @@ module Tests.Writers.TEI (tests) where import Test.Framework -import Text.Pandoc.Builder -import Text.Pandoc import Tests.Helpers -import Text.Pandoc.Arbitrary() +import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder {- "my test" =: X =?> Y |