diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-02-22 11:30:07 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-02-22 11:30:07 -0800 |
commit | 80fde18fb1d983b938476ed5b3771ed5d6158d44 (patch) | |
tree | 9c2f3bbe6c1f28425b65a564df95ba39ef16537a /test | |
parent | 607c014e9d7a7cee0b5f82efb6b6cb80ab75ec18 (diff) | |
download | pandoc-80fde18fb1d983b938476ed5b3771ed5d6158d44.tar.gz |
Text.Pandoc.UTF8: change IO functions to return Text, not String.
[API change] This affects `readFile`, `getContents`, `writeFileWith`,
`writeFile`, `putStrWith`, `putStr`, `putStrLnWith`, `putStrLn`.
`hPutStrWith`, `hPutStr`, `hPutStrLnWith`, `hPutStrLn`, `hGetContents`.
This avoids the need to uselessly create a linked list of characters
when emiting output.
Diffstat (limited to 'test')
-rw-r--r-- | test/Tests/Command.hs | 2 | ||||
-rw-r--r-- | test/Tests/Old.hs | 5 | ||||
-rw-r--r-- | test/Tests/Readers/LaTeX.hs | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/test/Tests/Command.hs b/test/Tests/Command.hs index 07d825f73..59b04eac1 100644 --- a/test/Tests/Command.hs +++ b/test/Tests/Command.hs @@ -130,7 +130,7 @@ runCommandTest testExePath fp num code = let cmdline = "% " <> cmd let x = cmdline <> "\n" <> input <> "^D\n" <> norm let y = cmdline <> "\n" <> input <> "^D\n" <> newnorm - let updated = T.unpack $ T.replace (T.pack x) (T.pack y) (T.pack raw) + let updated = T.replace (T.pack x) (T.pack y) raw UTF8.writeFile fp' updated extractCommandTest :: FilePath -> FilePath -> TestTree diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs index 17ece49fd..160086be2 100644 --- a/test/Tests/Old.hs +++ b/test/Tests/Old.hs @@ -22,6 +22,7 @@ import Test.Tasty (TestTree, testGroup) import Test.Tasty.Golden.Advanced (goldenTest) import Tests.Helpers hiding (test) import qualified Text.Pandoc.UTF8 as UTF8 +import qualified Data.Text as T tests :: FilePath -> [TestTree] tests pandocPath = @@ -231,7 +232,7 @@ tests pandocPath = -- makes sure file is fully closed after reading readFile' :: FilePath -> IO String readFile' f = do s <- UTF8.readFile f - return $! (length s `seq` s) + return $! (T.length s `seq` T.unpack s) lhsWriterTests :: FilePath -> String -> [TestTree] lhsWriterTests pandocPath format @@ -333,7 +334,7 @@ testWithNormalize normalizer pandocPath testname opts inp norm = $ UTF8.toStringLazy out -- filter \r so the tests will work on Windows machines else fail $ "Pandoc failed with error code " ++ show ec - updateGolden = UTF8.writeFile norm + updateGolden = UTF8.writeFile norm . T.pack options = ["--data-dir=../data","--quiet"] ++ [inp] ++ opts compareValues :: FilePath -> [String] -> String -> String -> IO (Maybe String) diff --git a/test/Tests/Readers/LaTeX.hs b/test/Tests/Readers/LaTeX.hs index 77104c853..8385b751e 100644 --- a/test/Tests/Readers/LaTeX.hs +++ b/test/Tests/Readers/LaTeX.hs @@ -54,7 +54,7 @@ tokUntokRt s = untokenize (tokenize "random" t) == t tests :: [TestTree] tests = [ testGroup "tokenization" [ testCase "tokenizer round trip on test case" $ do - orig <- T.pack <$> UTF8.readFile "../test/latex-reader.latex" + orig <- UTF8.readFile "../test/latex-reader.latex" let new = untokenize $ tokenize "../test/latex-reader.latex" orig assertEqual "untokenize . tokenize is identity" orig new |