git.iko.soy/typeable/pandoc
on 2.7 help sign in
52 lines 2.4 kB history raw
1{-# LANGUAGE NoImplicitPrelude #-}
2{- |
3 Module : Tests.Shared
4 Copyright : © 2006-2019 John MacFarlane
5 License : GNU GPL, version 2 or above
7 Maintainer : John MacFarlane <jgm@berkeley@edu>
8 Stability : alpha
9 Portability : portable
11Tests for functions used in many parts of the library.
12-}
13module Tests.Shared (tests) where
15import Prelude
16import System.FilePath.Posix (joinPath)
17import Test.Tasty
18import Test.Tasty.HUnit (assertBool, testCase, (@?=))
19import Text.Pandoc.Arbitrary ()
20import Text.Pandoc.Builder
21import Text.Pandoc.Shared
23tests :: [TestTree]
24tests = [ testGroup "compactifyDL"
25 [ testCase "compactifyDL with empty def" $
26 assertBool "compactifyDL"
27 (let x = [(str "word", [para (str "def"), mempty])]
28 in compactifyDL x == x)
29 ]
30 , testGroup "collapseFilePath" testCollapse
31 ]
33testCollapse :: [TestTree]
34testCollapse = map (testCase "collapse")
35 [ collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""])
36 , collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"])
37 , collapseFilePath (joinPath [ ".",".","..","foo"]) @?= (joinPath [ joinPath ["..", "foo"]])
38 , collapseFilePath (joinPath [ "..","foo"]) @?= (joinPath [ "..","foo"])
39 , collapseFilePath (joinPath [ "","bar","..","baz"]) @?= (joinPath [ "","baz"])
40 , collapseFilePath (joinPath [ "","..","baz"]) @?= (joinPath [ "","..","baz"])
41 , collapseFilePath (joinPath [ ".","foo","..",".","bar","..",".",".","baz"]) @?= (joinPath [ "baz"])
42 , collapseFilePath (joinPath [ ".",""]) @?= (joinPath [ ""])
43 , collapseFilePath (joinPath [ ".",".",""]) @?= (joinPath [ ""])
44 , collapseFilePath (joinPath [ "..",""]) @?= (joinPath [ ".."])
45 , collapseFilePath (joinPath [ "..",".",""]) @?= (joinPath [ ".."])
46 , collapseFilePath (joinPath [ ".","..",""]) @?= (joinPath [ ".."])
47 , collapseFilePath (joinPath [ "..","..",""]) @?= (joinPath [ "..",".."])
48 , collapseFilePath (joinPath [ "parent","foo","baz","..","bar"]) @?= (joinPath [ "parent","foo","bar"])
49 , collapseFilePath (joinPath [ "parent","foo","baz","..","..","bar"]) @?= (joinPath [ "parent","bar"])
50 , collapseFilePath (joinPath [ "parent","foo",".."]) @?= (joinPath [ "parent"])
51 , collapseFilePath (joinPath [ "","parent","foo","..","..","bar"]) @?= (joinPath [ "","bar"])
52 , collapseFilePath (joinPath [ "",".","parent","foo"]) @?= (joinPath [ "","parent","foo"])]