hlint code improvements.

This commit is contained in:
John MacFarlane
2018-01-19 21:25:24 -08:00
parent 8b3707de04
commit b8ffd834cf
66 changed files with 349 additions and 381 deletions
+3 -3
View File
@@ -40,7 +40,7 @@ runTest testname pandocpath cmd inp norm = testCase testname $ do
-- filter \r so the tests will work on Windows machines
let out = filter (/= '\r') $ err' ++ out'
result <- if ec == ExitSuccess
then do
then
if out == norm
then return TestPassed
else return
@@ -52,6 +52,7 @@ runTest testname pandocpath cmd inp norm = testCase testname $ do
assertBool (show result) (result == TestPassed)
tests :: TestTree
{-# NOINLINE tests #-}
tests = unsafePerformIO $ do
pandocpath <- findPandoc
files <- filter (".md" `isSuffixOf`) <$>
@@ -89,7 +90,6 @@ extractCommandTest pandocpath fp = unsafePerformIO $ do
contents <- UTF8.toText <$> BS.readFile ("command" </> fp)
Pandoc _ blocks <- runIOorExplode (readMarkdown
def{ readerExtensions = pandocExtensions } contents)
let codeblocks = map extractCode $ filter isCodeBlock $ blocks
let codeblocks = map extractCode $ filter isCodeBlock blocks
let cases = map (runCommandTest pandocpath) $ zip [1..] codeblocks
return $ testGroup fp cases
+1 -1
View File
@@ -224,7 +224,7 @@ tests = [
<> " bar")
, "escaped auto link" =:
"foo ~http://foo.example.com/bar/baz.html bar"
=?> para ("foo http://foo.example.com/bar/baz.html bar")
=?> para "foo http://foo.example.com/bar/baz.html bar"
, "wiki link simple" =:
"foo [[http://foo.example.com/foo.png]] bar"
=?> para ("foo "
+5 -6
View File
@@ -5,6 +5,7 @@ import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as B
import qualified Data.Map as M
import qualified Data.Text as T
import Data.Maybe
import System.IO.Unsafe
import Test.Tasty
import Test.Tasty.HUnit
@@ -46,7 +47,7 @@ compareOutput opts docxFile nativeFile = do
nf <- UTF8.toText <$> BS.readFile nativeFile
p <- runIOorExplode $ readDocx opts df
df' <- runIOorExplode $ readNative def nf
return $ (noNorm p, noNorm df')
return (noNorm p, noNorm df')
testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO TestTree
testCompareWithOptsIO opts name docxFile nativeFile = do
@@ -87,11 +88,9 @@ compareMediaPathIO mediaPath mediaBag docxPath = do
Nothing -> error ("couldn't find " ++
mediaPath ++
" in media bag")
docxBS = case docxMedia of
Just bs -> bs
Nothing -> error ("couldn't find " ++
mediaPath ++
" in media bag")
docxBS = fromMaybe (error ("couldn't find " ++
mediaPath ++
" in media bag")) docxMedia
return $ mbBS == docxBS
compareMediaBagIO :: FilePath -> IO Bool
+1 -1
View File
@@ -17,7 +17,7 @@ getMediaBag fp = do
testMediaBag :: FilePath -> [(String, String, Int)] -> IO ()
testMediaBag fp bag = do
actBag <- (mediaDirectory <$> getMediaBag fp)
actBag <- mediaDirectory <$> getMediaBag fp
assertBool (show "MediaBag did not match:\nExpected: "
++ show bag
++ "\nActual: "
+3 -3
View File
@@ -30,8 +30,8 @@ spcSep = mconcat . intersperse space
-- Tables and definition lists don't round-trip yet
makeRoundTrip :: Block -> Block
makeRoundTrip (Table{}) = Para [Str "table was here"]
makeRoundTrip (DefinitionList{}) = Para [Str "deflist was here"]
makeRoundTrip Table{} = Para [Str "table was here"]
makeRoundTrip DefinitionList{} = Para [Str "deflist was here"]
makeRoundTrip x = x
-- Demand that any AST produced by Muse reader and written by Muse writer can be read back exactly the same way.
@@ -44,7 +44,7 @@ roundTrip b = d'' == d'''
d'' = rewrite d'
d''' = rewrite d''
rewrite = amuse . T.pack . (++ "\n") . T.unpack .
(purely $ writeMuse def { writerExtensions = extensionsFromList [Ext_amuse]
purely (writeMuse def { writerExtensions = extensionsFromList [Ext_amuse]
, writerWrapText = WrapPreserve
})
+1 -1
View File
@@ -130,7 +130,7 @@ tests =
mconcat [ para "foo"
, headerWith ("thing-other-thing", [], [])
1
((strikeout "thing") <> " other thing")
(strikeout "thing" <> " other thing")
]
, "Comment Trees" =:
+9 -9
View File
@@ -75,16 +75,16 @@ tests =
]
, "Bullet List with Decreasing Indent" =:
(" - Discovery\n\
\ - Human After All\n") =?>
" - Discovery\n\
\ - Human After All\n" =?>
mconcat [ bulletList [ plain "Discovery" ]
, bulletList [ plain ("Human" <> space <> "After" <> space <> "All")]
]
, "Header follows Bullet List" =:
(" - Discovery\n\
" - Discovery\n\
\ - Human After All\n\
\* Homework") =?>
\* Homework" =?>
mconcat [ bulletList [ plain "Discovery"
, plain ("Human" <> space <> "After" <> space <> "All")
]
@@ -92,9 +92,9 @@ tests =
]
, "Bullet List Unindented with trailing Header" =:
("- Discovery\n\
"- Discovery\n\
\- Homework\n\
\* NotValidListItem") =?>
\* NotValidListItem" =?>
mconcat [ bulletList [ plain "Discovery"
, plain "Homework"
]
@@ -166,14 +166,14 @@ tests =
, "Ordered List in Bullet List" =:
("- Emacs\n" <>
" 1. Org\n") =?>
bulletList [ (plain "Emacs") <>
(orderedList [ plain "Org"])
bulletList [ plain "Emacs" <>
orderedList [ plain "Org"]
]
, "Bullet List in Ordered List" =:
("1. GNU\n" <>
" - Freedom\n") =?>
orderedList [ (plain "GNU") <> bulletList [ (plain "Freedom") ] ]
orderedList [ plain "GNU" <> bulletList [ plain "Freedom" ] ]
, "Definition List" =:
T.unlines [ "- PLL :: phase-locked loop"
+2 -2
View File
@@ -107,8 +107,8 @@ tests =
] =?>
mconcat [ para "first block"
, orderedList
[ (para "top-level section 1" <>
orderedList [ para "subsection" ])
[ para "top-level section 1" <>
orderedList [ para "subsection" ]
, para "top-level section 2" ]
]
+30 -29
View File
@@ -36,7 +36,7 @@ tests =
, "Underline" =:
"_underline_" =?>
para (underlineSpan $ "underline")
para (underlineSpan "underline")
, "Strikeout" =:
"+Kill Bill+" =?>
@@ -127,11 +127,12 @@ tests =
, "Markup should work properly after a blank line" =:
T.unlines ["foo", "", "/bar/"] =?>
(para $ text "foo") <> (para $ emph $ text "bar")
para (text "foo") <>
para (emph $ text "bar")
, "Inline math must stay within three lines" =:
T.unlines [ "$a", "b", "c$", "$d", "e", "f", "g$" ] =?>
para ((math "a\nb\nc") <> softbreak <>
para (math "a\nb\nc" <> softbreak <>
"$d" <> softbreak <> "e" <> softbreak <>
"f" <> softbreak <> "g$")
@@ -139,7 +140,7 @@ tests =
"$a$ $b$! $c$?" =?>
para (spcSep [ math "a"
, "$b$!"
, (math "c") <> "?"
, math "c" <> "?"
])
, "Markup may not span more than two lines" =:
@@ -166,12 +167,12 @@ tests =
para (mconcat $ intersperse softbreak
[ "a" <> subscript "(a(b)(c)d)"
, "e" <> superscript "(f(g)h)"
, "i" <> (subscript "(jk)") <> "l)"
, "m" <> (superscript "()") <> "n"
, "i" <> subscript "(jk)" <> "l)"
, "m" <> superscript "()" <> "n"
, "o" <> subscript "p{q{}r}"
, "s" <> superscript "t{u}v"
, "w" <> (subscript "xy") <> "z}"
, "1" <> (superscript "") <> "2"
, "w" <> subscript "xy" <> "z}"
, "1" <> superscript "" <> "2"
, "3" <> subscript "{}"
, "4" <> superscript ("(a(" <> strong "b(c" <> ")d))")
])
@@ -182,17 +183,17 @@ tests =
, testGroup "Images"
[ "Image" =:
"[[./sunset.jpg]]" =?>
(para $ image "./sunset.jpg" "" "")
para (image "./sunset.jpg" "" "")
, "Image with explicit file: prefix" =:
"[[file:sunrise.jpg]]" =?>
(para $ image "sunrise.jpg" "" "")
para (image "sunrise.jpg" "" "")
, "Multiple images within a paragraph" =:
T.unlines [ "[[file:sunrise.jpg]]"
, "[[file:sunset.jpg]]"
] =?>
(para $ (image "sunrise.jpg" "" "")
para ((image "sunrise.jpg" "" "")
<> softbreak
<> (image "sunset.jpg" "" ""))
@@ -200,75 +201,75 @@ tests =
T.unlines [ "#+ATTR_HTML: :width 50%"
, "[[file:guinea-pig.gif]]"
] =?>
(para $ imageWith ("", [], [("width", "50%")]) "guinea-pig.gif" "" "")
para (imageWith ("", [], [("width", "50%")]) "guinea-pig.gif" "" "")
]
, "Explicit link" =:
"[[http://zeitlens.com/][pseudo-random /nonsense/]]" =?>
(para $ link "http://zeitlens.com/" ""
para (link "http://zeitlens.com/" ""
("pseudo-random" <> space <> emph "nonsense"))
, "Self-link" =:
"[[http://zeitlens.com/]]" =?>
(para $ link "http://zeitlens.com/" "" "http://zeitlens.com/")
para (link "http://zeitlens.com/" "" "http://zeitlens.com/")
, "Absolute file link" =:
"[[/url][hi]]" =?>
(para $ link "file:///url" "" "hi")
para (link "file:///url" "" "hi")
, "Link to file in parent directory" =:
"[[../file.txt][moin]]" =?>
(para $ link "../file.txt" "" "moin")
para (link "../file.txt" "" "moin")
, "Empty link (for gitit interop)" =:
"[[][New Link]]" =?>
(para $ link "" "" "New Link")
para (link "" "" "New Link")
, "Image link" =:
"[[sunset.png][file:dusk.svg]]" =?>
(para $ link "sunset.png" "" (image "dusk.svg" "" ""))
para (link "sunset.png" "" (image "dusk.svg" "" ""))
, "Image link with non-image target" =:
"[[http://example.com][./logo.png]]" =?>
(para $ link "http://example.com" "" (image "./logo.png" "" ""))
para (link "http://example.com" "" (image "./logo.png" "" ""))
, "Plain link" =:
"Posts on http://zeitlens.com/ can be funny at times." =?>
(para $ spcSep [ "Posts", "on"
para (spcSep [ "Posts", "on"
, link "http://zeitlens.com/" "" "http://zeitlens.com/"
, "can", "be", "funny", "at", "times."
])
, "Angle link" =:
"Look at <http://moltkeplatz.de> for fnords." =?>
(para $ spcSep [ "Look", "at"
para (spcSep [ "Look", "at"
, link "http://moltkeplatz.de" "" "http://moltkeplatz.de"
, "for", "fnords."
])
, "Absolute file link" =:
"[[file:///etc/passwd][passwd]]" =?>
(para $ link "file:///etc/passwd" "" "passwd")
para (link "file:///etc/passwd" "" "passwd")
, "File link" =:
"[[file:target][title]]" =?>
(para $ link "target" "" "title")
para (link "target" "" "title")
, "Anchor" =:
"<<anchor>> Link here later." =?>
(para $ spanWith ("anchor", [], []) mempty <>
para (spanWith ("anchor", [], []) mempty <>
"Link" <> space <> "here" <> space <> "later.")
, "Inline code block" =:
"src_emacs-lisp{(message \"Hello\")}" =?>
(para $ codeWith ( ""
para (codeWith ( ""
, [ "commonlisp" ]
, [ ("org-language", "emacs-lisp") ])
"(message \"Hello\")")
, "Inline code block with arguments" =:
"src_sh[:export both :results output]{echo 'Hello, World'}" =?>
(para $ codeWith ( ""
para (codeWith ( ""
, [ "bash" ]
, [ ("org-language", "sh")
, ("export", "both")
@@ -279,7 +280,7 @@ tests =
, "Inline code block with toggle" =:
"src_sh[:toggle]{echo $HOME}" =?>
(para $ codeWith ( ""
para (codeWith ( ""
, [ "bash" ]
, [ ("org-language", "sh")
, ("toggle", "yes")
@@ -415,7 +416,7 @@ tests =
in [
"Berkeley-style in-text citation" =:
"See @Dominik201408." =?>
(para $ "See "
para ("See "
<> cite [dominikInText] "@Dominik201408"
<> ".")
@@ -468,7 +469,7 @@ tests =
, "MathML symbol in LaTeX-style" =:
"There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: '\\nbsp')." =?>
para ("There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: ' ').")
para "There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: ' ')."
, "MathML symbol in LaTeX-style, including braces" =:
"\\Aacute{}stor" =?>
-1
View File
@@ -84,4 +84,3 @@ tests =
, para "next"
]
]
+2 -2
View File
@@ -38,9 +38,9 @@ tests =
, test orgSmart "Single quotes can be followed by emphasized text"
("Singles on the '/meat market/'" =?>
para ("Singles on the " <> (singleQuoted $ emph "meat market")))
para ("Singles on the " <> singleQuoted (emph "meat market")))
, test orgSmart "Double quotes can be followed by emphasized text"
("Double income, no kids: \"/DINK/\"" =?>
para ("Double income, no kids: " <> (doubleQuoted $ emph "DINK")))
para ("Double income, no kids: " <> doubleQuoted (emph "DINK")))
]
+14 -14
View File
@@ -30,32 +30,32 @@ tests =
, "Title" =:
"#+TITLE: Hello, World" =?>
let titleInline = toList $ "Hello," <> space <> "World"
meta = setMeta "title" (MetaInlines titleInline) $ nullMeta
meta = setMeta "title" (MetaInlines titleInline) nullMeta
in Pandoc meta mempty
, "Author" =:
"#+author: John /Emacs-Fanboy/ Doe" =?>
let author = toList . spcSep $ [ "John", emph "Emacs-Fanboy", "Doe" ]
meta = setMeta "author" (MetaList [MetaInlines author]) $ nullMeta
meta = setMeta "author" (MetaList [MetaInlines author]) nullMeta
in Pandoc meta mempty
, "Multiple authors" =:
"#+author: James Dewey Watson, Francis Harry Compton Crick " =?>
let watson = MetaInlines $ toList "James Dewey Watson"
crick = MetaInlines $ toList "Francis Harry Compton Crick"
meta = setMeta "author" (MetaList [watson, crick]) $ nullMeta
meta = setMeta "author" (MetaList [watson, crick]) nullMeta
in Pandoc meta mempty
, "Date" =:
"#+Date: Feb. *28*, 2014" =?>
let date = toList . spcSep $ [ "Feb.", (strong "28") <> ",", "2014" ]
meta = setMeta "date" (MetaInlines date) $ nullMeta
let date = toList . spcSep $ [ "Feb.", strong "28" <> ",", "2014" ]
meta = setMeta "date" (MetaInlines date) nullMeta
in Pandoc meta mempty
, "Description" =:
"#+DESCRIPTION: Explanatory text" =?>
let description = "Explanatory text"
meta = setMeta "description" (MetaString description) $ nullMeta
meta = setMeta "description" (MetaString description) nullMeta
in Pandoc meta mempty
, "Properties drawer" =:
@@ -94,7 +94,7 @@ tests =
, "#+author: Max"
] =?>
let author = MetaInlines [Str "Max"]
meta = setMeta "author" (MetaList [author]) $ nullMeta
meta = setMeta "author" (MetaList [author]) nullMeta
in Pandoc meta mempty
, "Logbook drawer" =:
@@ -135,7 +135,7 @@ tests =
, "Search links are read as emph" =:
"[[Wally][Where's Wally?]]" =?>
(para (emph $ "Where's" <> space <> "Wally?"))
para (emph $ "Where's" <> space <> "Wally?")
, "Link to nonexistent anchor" =:
T.unlines [ "<<link-here>> Target."
@@ -149,25 +149,25 @@ tests =
T.unlines [ "#+LINK: wp https://en.wikipedia.org/wiki/%s"
, "[[wp:Org_mode][Wikipedia on Org-mode]]"
] =?>
(para (link "https://en.wikipedia.org/wiki/Org_mode" ""
("Wikipedia" <> space <> "on" <> space <> "Org-mode")))
para (link "https://en.wikipedia.org/wiki/Org_mode" ""
("Wikipedia" <> space <> "on" <> space <> "Org-mode"))
, "Link abbreviation, defined after first use" =:
T.unlines [ "[[zl:non-sense][Non-sense articles]]"
, "#+LINK: zl http://zeitlens.com/tags/%s.html"
] =?>
(para (link "http://zeitlens.com/tags/non-sense.html" ""
("Non-sense" <> space <> "articles")))
para (link "http://zeitlens.com/tags/non-sense.html" ""
("Non-sense" <> space <> "articles"))
, "Link abbreviation, URL encoded arguments" =:
T.unlines [ "#+link: expl http://example.com/%h/foo"
, "[[expl:Hello, World!][Moin!]]"
] =?>
(para (link "http://example.com/Hello%2C%20World%21/foo" "" "Moin!"))
para (link "http://example.com/Hello%2C%20World%21/foo" "" "Moin!")
, "Link abbreviation, append arguments" =:
T.unlines [ "#+link: expl http://example.com/"
, "[[expl:foo][bar]]"
] =?>
(para (link "http://example.com/foo" "" "bar"))
para (link "http://example.com/foo" "" "bar")
]
+14 -15
View File
@@ -36,8 +36,8 @@ tests = [ "line block with blank line" =:
, ":Parameter i: integer"
, ":Final: item"
, " on two lines" ]
=?> ( doc
$ para "para" <>
=?>
doc (para "para" <>
definitionList [ (str "Hostname", [para "media08"])
, (text "IP address", [para "10.0.0.19"])
, (str "Size", [para "3ru"])
@@ -56,10 +56,10 @@ tests = [ "line block with blank line" =:
, ""
, ":Version: 1"
]
=?> ( setMeta "version" (para "1")
$ setMeta "title" ("Title" :: Inlines)
=?>
setMeta "version" (para "1") (setMeta "title" ("Title" :: Inlines)
$ setMeta "subtitle" ("Subtitle" :: Inlines)
$ doc mempty )
$ doc mempty)
, "with inline markup" =: T.unlines
[ ":*Date*: today"
, ""
@@ -73,8 +73,8 @@ tests = [ "line block with blank line" =:
, ".. _two: http://example.com"
, ".. _three: http://example.org"
]
=?> ( setMeta "date" (str "today")
$ doc
=?>
setMeta "date" (str "today") (doc
$ definitionList [ (emph "one", [para "emphasis"])
, (link "http://example.com" "" "two", [para "reference"])
, (link "http://example.org" "" "three", [para "another one"])
@@ -102,13 +102,12 @@ tests = [ "line block with blank line" =:
, " def func(x):"
, " return y"
] =?>
( doc $ codeBlockWith
doc (codeBlockWith
( ""
, ["sourceCode", "python", "numberLines", "class1", "class2", "class3"]
, [ ("startFrom", "34") ]
)
"def func(x):\n return y"
)
"def func(x):\n return y")
, "Code directive with number-lines, no line specified" =: T.unlines
[ ".. code::python"
, " :number-lines: "
@@ -116,13 +115,12 @@ tests = [ "line block with blank line" =:
, " def func(x):"
, " return y"
] =?>
( doc $ codeBlockWith
doc (codeBlockWith
( ""
, ["sourceCode", "python", "numberLines"]
, [ ("startFrom", "") ]
)
"def func(x):\n return y"
)
"def func(x):\n return y")
, testGroup "literal / line / code blocks"
[ "indented literal block" =: T.unlines
[ "::"
@@ -131,7 +129,8 @@ tests = [ "line block with blank line" =:
, ""
, " can go on for many lines"
, "but must stop here"]
=?> (doc $
=?>
doc (
codeBlock "block quotes\n\ncan go on for many lines" <>
para "but must stop here")
, "line block with 3 lines" =: "| a\n| b\n| c"
@@ -185,6 +184,6 @@ tests = [ "line block with blank line" =:
, ".. [1]"
, " bar"
] =?>
(para $ "foo" <> (note $ para "bar"))
para ("foo" <> (note $ para "bar"))
]
]
+4 -4
View File
@@ -30,11 +30,11 @@ simpleTable' :: Int
-> [Blocks]
-> [[Blocks]]
-> Blocks
simpleTable' n = table "" (take n $ repeat (AlignCenter, 0.0))
simpleTable' n = table "" (replicate n (AlignCenter, 0.0))
tests :: [TestTree]
tests =
[ testGroup "Inlines" $
[ testGroup "Inlines"
[ "Plain String" =:
"Hello, World" =?>
para (spcSep [ "Hello,", "World" ])
@@ -114,7 +114,7 @@ tests =
]
, testGroup "Basic Blocks" $
, testGroup "Basic Blocks"
["Paragraph, lines grouped together" =:
"A paragraph\n A blank line ends the \n current paragraph\n"
=?> para "A paragraph\n A blank line ends the\n current paragraph"
@@ -197,7 +197,7 @@ tests =
]
, testGroup "Lists" $
, testGroup "Lists"
[ "Simple Bullet Lists" =:
("- Item1\n" <>
"- Item2\n") =?>
+18 -18
View File
@@ -19,21 +19,21 @@ tests = [ testGroup "compactifyDL"
testCollapse :: [TestTree]
testCollapse = map (testCase "collapse")
[ (collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""]))
, (collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"]))
, (collapseFilePath (joinPath [ ".",".","..","foo"]) @?= (joinPath [ joinPath ["..", "foo"]]))
, (collapseFilePath (joinPath [ "..","foo"]) @?= (joinPath [ "..","foo"]))
, (collapseFilePath (joinPath [ "","bar","..","baz"]) @?= (joinPath [ "","baz"]))
, (collapseFilePath (joinPath [ "","..","baz"]) @?= (joinPath [ "","..","baz"]))
, (collapseFilePath (joinPath [ ".","foo","..",".","bar","..",".",".","baz"]) @?= (joinPath [ "baz"]))
, (collapseFilePath (joinPath [ ".",""]) @?= (joinPath [ ""]))
, (collapseFilePath (joinPath [ ".",".",""]) @?= (joinPath [ ""]))
, (collapseFilePath (joinPath [ "..",""]) @?= (joinPath [ ".."]))
, (collapseFilePath (joinPath [ "..",".",""]) @?= (joinPath [ ".."]))
, (collapseFilePath (joinPath [ ".","..",""]) @?= (joinPath [ ".."]))
, (collapseFilePath (joinPath [ "..","..",""]) @?= (joinPath [ "..",".."]))
, (collapseFilePath (joinPath [ "parent","foo","baz","..","bar"]) @?= (joinPath [ "parent","foo","bar"]))
, (collapseFilePath (joinPath [ "parent","foo","baz","..","..","bar"]) @?= (joinPath [ "parent","bar"]))
, (collapseFilePath (joinPath [ "parent","foo",".."]) @?= (joinPath [ "parent"]))
, (collapseFilePath (joinPath [ "","parent","foo","..","..","bar"]) @?= (joinPath [ "","bar"]))
, (collapseFilePath (joinPath [ "",".","parent","foo"]) @?= (joinPath [ "","parent","foo"]))]
[ collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""])
, collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"])
, collapseFilePath (joinPath [ ".",".","..","foo"]) @?= (joinPath [ joinPath ["..", "foo"]])
, collapseFilePath (joinPath [ "..","foo"]) @?= (joinPath [ "..","foo"])
, collapseFilePath (joinPath [ "","bar","..","baz"]) @?= (joinPath [ "","baz"])
, collapseFilePath (joinPath [ "","..","baz"]) @?= (joinPath [ "","..","baz"])
, collapseFilePath (joinPath [ ".","foo","..",".","bar","..",".",".","baz"]) @?= (joinPath [ "baz"])
, collapseFilePath (joinPath [ ".",""]) @?= (joinPath [ ""])
, collapseFilePath (joinPath [ ".",".",""]) @?= (joinPath [ ""])
, collapseFilePath (joinPath [ "..",""]) @?= (joinPath [ ".."])
, collapseFilePath (joinPath [ "..",".",""]) @?= (joinPath [ ".."])
, collapseFilePath (joinPath [ ".","..",""]) @?= (joinPath [ ".."])
, collapseFilePath (joinPath [ "..","..",""]) @?= (joinPath [ "..",".."])
, collapseFilePath (joinPath [ "parent","foo","baz","..","bar"]) @?= (joinPath [ "parent","foo","bar"])
, collapseFilePath (joinPath [ "parent","foo","baz","..","..","bar"]) @?= (joinPath [ "parent","bar"])
, collapseFilePath (joinPath [ "parent","foo",".."]) @?= (joinPath [ "parent"])
, collapseFilePath (joinPath [ "","parent","foo","..","..","bar"]) @?= (joinPath [ "","bar"])
, collapseFilePath (joinPath [ "",".","parent","foo"]) @?= (joinPath [ "","parent","foo"])]
+3 -4
View File
@@ -41,9 +41,9 @@ tests = [ testGroup "inline code"
, "without '}'" =: code "]" =?> "\\type{]}"
, testProperty "code property" $ \s -> null s ||
if '{' `elem` s || '}' `elem` s
then (context' $ code s) == "\\mono{" ++
(context' $ str s) ++ "}"
else (context' $ code s) == "\\type{" ++ s ++ "}"
then context' (code s) == "\\mono{" ++
context' (str s) ++ "}"
else context' (code s) == "\\type{" ++ s ++ "}"
]
, testGroup "headers"
[ "level 1" =:
@@ -124,4 +124,3 @@ tests = [ testGroup "inline code"
, "\\stopplacetable" ]
]
]
+1 -1
View File
@@ -230,7 +230,7 @@ tests = [ testGroup "line blocks"
]
]
]
, testGroup "writer options" $
, testGroup "writer options"
[ testGroup "top-level division" $
let
headers = header 1 (text "header1")
+1 -1
View File
@@ -23,7 +23,7 @@ tests = [ testGroup "block elements"
]
, testGroup "inlines"
[
"Emphasis" =: emph ("emphasized")
"Emphasis" =: emph "emphasized"
=?> fb2 "<emphasis>emphasized</emphasis>"
]
, "bullet list" =: bulletList [ plain $ text "first"
-2
View File
@@ -120,5 +120,3 @@ tests = [ testGroup "inline code"
\</sec>"
]
]
+21 -21
View File
@@ -80,7 +80,7 @@ noteTestDoc =
".") <>
blockQuote (para ("A note inside a block quote." <>
note (para "The second note.")) <>
para ("A second paragraph.")) <>
para "A second paragraph.") <>
header 1 "Second Header" <>
para "Some more text."
@@ -91,7 +91,7 @@ noteTests = testGroup "note and reference location"
[ test (markdownWithOpts defopts)
"footnotes at the end of a document" $
noteTestDoc =?>
(unlines $ [ "First Header"
(unlines [ "First Header"
, "============"
, ""
, "This is a footnote.[^1] And this is a [link](https://www.google.com)."
@@ -112,7 +112,7 @@ noteTests = testGroup "note and reference location"
, test (markdownWithOpts defopts{writerReferenceLocation=EndOfBlock})
"footnotes at the end of blocks" $
noteTestDoc =?>
(unlines $ [ "First Header"
(unlines [ "First Header"
, "============"
, ""
, "This is a footnote.[^1] And this is a [link](https://www.google.com)."
@@ -133,7 +133,7 @@ noteTests = testGroup "note and reference location"
, test (markdownWithOpts defopts{writerReferenceLocation=EndOfBlock, writerReferenceLinks=True})
"footnotes and reference links at the end of blocks" $
noteTestDoc =?>
(unlines $ [ "First Header"
(unlines [ "First Header"
, "============"
, ""
, "This is a footnote.[^1] And this is a [link]."
@@ -156,7 +156,7 @@ noteTests = testGroup "note and reference location"
, test (markdownWithOpts defopts{writerReferenceLocation=EndOfSection})
"footnotes at the end of section" $
noteTestDoc =?>
(unlines $ [ "First Header"
(unlines [ "First Header"
, "============"
, ""
, "This is a footnote.[^1] And this is a [link](https://www.google.com)."
@@ -186,27 +186,27 @@ shortcutLinkRefsTests =
(=:) = test (purely (writeMarkdown defopts{writerReferenceLinks = True}) . toPandoc)
in testGroup "Shortcut reference links"
[ "Simple link (shortcutable)"
=: (para (link "/url" "title" "foo"))
=: para (link "/url" "title" "foo")
=?> "[foo]\n\n [foo]: /url \"title\""
, "Followed by another link (unshortcutable)"
=: (para ((link "/url1" "title1" "first")
<> (link "/url2" "title2" "second")))
=: para ((link "/url1" "title1" "first")
<> (link "/url2" "title2" "second"))
=?> unlines [ "[first][][second]"
, ""
, " [first]: /url1 \"title1\""
, " [second]: /url2 \"title2\""
]
, "Followed by space and another link (unshortcutable)"
=: (para ((link "/url1" "title1" "first") <> " "
<> (link "/url2" "title2" "second")))
=: para ((link "/url1" "title1" "first") <> " "
<> (link "/url2" "title2" "second"))
=?> unlines [ "[first][] [second]"
, ""
, " [first]: /url1 \"title1\""
, " [second]: /url2 \"title2\""
]
, "Reference link is used multiple times (unshortcutable)"
=: (para ((link "/url1" "" "foo") <> (link "/url2" "" "foo")
<> (link "/url3" "" "foo")))
=: para ((link "/url1" "" "foo") <> (link "/url2" "" "foo")
<> (link "/url3" "" "foo"))
=?> unlines [ "[foo][][foo][1][foo][2]"
, ""
, " [foo]: /url1"
@@ -214,8 +214,8 @@ shortcutLinkRefsTests =
, " [2]: /url3"
]
, "Reference link is used multiple times (unshortcutable)"
=: (para ((link "/url1" "" "foo") <> " " <> (link "/url2" "" "foo")
<> " " <> (link "/url3" "" "foo")))
=: para ((link "/url1" "" "foo") <> " " <> (link "/url2" "" "foo")
<> " " <> (link "/url3" "" "foo"))
=?> unlines [ "[foo][] [foo][1] [foo][2]"
, ""
, " [foo]: /url1"
@@ -223,43 +223,43 @@ shortcutLinkRefsTests =
, " [2]: /url3"
]
, "Reference link is followed by text in brackets"
=: (para ((link "/url" "" "link") <> "[text in brackets]"))
=: para ((link "/url" "" "link") <> "[text in brackets]")
=?> unlines [ "[link][]\\[text in brackets\\]"
, ""
, " [link]: /url"
]
, "Reference link is followed by space and text in brackets"
=: (para ((link "/url" "" "link") <> " [text in brackets]"))
=: para ((link "/url" "" "link") <> " [text in brackets]")
=?> unlines [ "[link][] \\[text in brackets\\]"
, ""
, " [link]: /url"
]
, "Reference link is followed by RawInline"
=: (para ((link "/url" "" "link") <> rawInline "markdown" "[rawText]"))
=: para ((link "/url" "" "link") <> rawInline "markdown" "[rawText]")
=?> unlines [ "[link][][rawText]"
, ""
, " [link]: /url"
]
, "Reference link is followed by space and RawInline"
=: (para ((link "/url" "" "link") <> space <> rawInline "markdown" "[rawText]"))
=: para ((link "/url" "" "link") <> space <> rawInline "markdown" "[rawText]")
=?> unlines [ "[link][] [rawText]"
, ""
, " [link]: /url"
]
, "Reference link is followed by RawInline with space"
=: (para ((link "/url" "" "link") <> rawInline "markdown" " [rawText]"))
=: para ((link "/url" "" "link") <> rawInline "markdown" " [rawText]")
=?> unlines [ "[link][] [rawText]"
, ""
, " [link]: /url"
]
, "Reference link is followed by citation"
=: (para ((link "/url" "" "link") <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]")))
=: para ((link "/url" "" "link") <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]"))
=?> unlines [ "[link][][@author]"
, ""
, " [link]: /url"
]
, "Reference link is followed by space and citation"
=: (para ((link "/url" "" "link") <> space <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]")))
=: para ((link "/url" "" "link") <> space <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]"))
=?> unlines [ "[link][] [@author]"
, ""
, " [link]: /url"
+1 -1
View File
@@ -18,5 +18,5 @@ p_write_blocks_rt bs =
tests :: [TestTree]
tests = [ testProperty "p_write_rt" p_write_rt
, testProperty "p_write_blocks_rt" $ mapSize
(\x -> if x > 3 then 3 else x) $ p_write_blocks_rt
(\x -> if x > 3 then 3 else x) p_write_blocks_rt
]
+6 -6
View File
@@ -72,7 +72,7 @@ numSlideTests = testGroup "Number of slides in output"
def
(doc $
para "first slide" <>
(para $ image "lalune.jpg" "" "") <>
para (image "lalune.jpg" "" "") <>
para "foo")
, testNumberOfSlides
"With image slide, header" 3
@@ -80,14 +80,14 @@ numSlideTests = testGroup "Number of slides in output"
(doc $
para "first slide" <>
header 2 "image header" <>
(para $ image "lalune.jpg" "" "") <>
para (image "lalune.jpg" "" "") <>
para "foo")
, testNumberOfSlides
"With table, no header" 3
def
(doc $
para "first slide" <>
(simpleTable [para "foo" <> para "bar"] [[para "this" <> para "that"]]) <>
simpleTable [para "foo" <> para "bar"] [[para "this" <> para "that"]] <>
para "foo")
, testNumberOfSlides
"With table, header" 3
@@ -95,7 +95,7 @@ numSlideTests = testGroup "Number of slides in output"
(doc $
para "first slide" <>
header 2 "table header" <>
(simpleTable [para "foo" <> para "bar"] [[para "this" <> para "that"]]) <>
simpleTable [para "foo" <> para "bar"] [[para "this" <> para "that"]] <>
para "foo")
, testNumberOfSlides
"hrule" 2
@@ -117,7 +117,7 @@ contentTypesFileExists opts pd =
testCase "Existence of [Content_Types].xml file" $
do archive <- getPptxArchive opts pd
assertBool "Missing [Content_Types].xml file" $
"[Content_Types].xml" `elem` (filesInArchive archive)
"[Content_Types].xml" `elem` filesInArchive archive
@@ -138,7 +138,7 @@ prop_ContentOverrides pd = do
Nothing -> throwIO $
PandocSomeError "Missing [Content_Types].xml file"
typesElem <- case parseXMLDoc contentTypes of
Just element -> return $ element
Just element -> return element
Nothing -> throwIO $
PandocSomeError "[Content_Types].xml cannot be parsed"
let ns = findAttr (QName "xmlns" Nothing Nothing) typesElem
+1 -1
View File
@@ -31,7 +31,7 @@ tests = [ testGroup "block elements"
]
, testGroup "inlines"
[
"Emphasis" =: emph ("emphasized")
"Emphasis" =: emph "emphasized"
=?> "<p><hi rendition=\"simple:italic\">emphasized</hi></p>"
,"SingleQuoted" =: singleQuoted (text "quoted material")
=?> "<p><quote>quoted material</quote></p>"