git.iko.soy/typeable/pandoc
on 1.15.0.5 help sign in
61 lines 2.9 kB history raw
1module Tests.Shared (tests) where
3import Text.Pandoc.Definition
4import Text.Pandoc.Shared
5import Test.Framework
6import Tests.Helpers
7import Tests.Arbitrary()
8import Test.Framework.Providers.HUnit
9import Test.HUnit ( assertBool, (@?=) )
10import Text.Pandoc.Builder
11import Data.Monoid
12import System.FilePath (joinPath)
14tests :: [Test]
15tests = [ testGroup "normalize"
16 [ property "p_normalize_blocks_rt" p_normalize_blocks_rt
17 , property "p_normalize_inlines_rt" p_normalize_inlines_rt
18 , property "p_normalize_no_trailing_spaces"
19 p_normalize_no_trailing_spaces
20 ]
21 , testGroup "compactify'DL"
22 [ testCase "compactify'DL with empty def" $
23 assertBool "compactify'DL"
24 (let x = [(str "word", [para (str "def"), mempty])]
25 in compactify'DL x == x)
26 ]
27 , testGroup "collapseFilePath" testCollapse
28 ]
30p_normalize_blocks_rt :: [Block] -> Bool
31p_normalize_blocks_rt bs =
32 normalizeBlocks bs == normalizeBlocks (normalizeBlocks bs)
34p_normalize_inlines_rt :: [Inline] -> Bool
35p_normalize_inlines_rt ils =
36 normalizeInlines ils == normalizeInlines (normalizeInlines ils)
38p_normalize_no_trailing_spaces :: [Inline] -> Bool
39p_normalize_no_trailing_spaces ils = null ils' || last ils' /= Space
40 where ils' = normalizeInlines $ ils ++ [Space]
42testCollapse :: [Test]
43testCollapse = map (testCase "collapse")
44 [ (collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""]))
45 , (collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"]))
46 , (collapseFilePath (joinPath [ ".",".","..","foo"]) @?= (joinPath [ joinPath ["..", "foo"]]))
47 , (collapseFilePath (joinPath [ "..","foo"]) @?= (joinPath [ "..","foo"]))
48 , (collapseFilePath (joinPath [ "","bar","..","baz"]) @?= (joinPath [ "","baz"]))
49 , (collapseFilePath (joinPath [ "","..","baz"]) @?= (joinPath [ "","..","baz"]))
50 , (collapseFilePath (joinPath [ ".","foo","..",".","bar","..",".",".","baz"]) @?= (joinPath [ "baz"]))
51 , (collapseFilePath (joinPath [ ".",""]) @?= (joinPath [ ""]))
52 , (collapseFilePath (joinPath [ ".",".",""]) @?= (joinPath [ ""]))
53 , (collapseFilePath (joinPath [ "..",""]) @?= (joinPath [ ".."]))
54 , (collapseFilePath (joinPath [ "..",".",""]) @?= (joinPath [ ".."]))
55 , (collapseFilePath (joinPath [ ".","..",""]) @?= (joinPath [ ".."]))
56 , (collapseFilePath (joinPath [ "..","..",""]) @?= (joinPath [ "..",".."]))
57 , (collapseFilePath (joinPath [ "parent","foo","baz","..","bar"]) @?= (joinPath [ "parent","foo","bar"]))
58 , (collapseFilePath (joinPath [ "parent","foo","baz","..","..","bar"]) @?= (joinPath [ "parent","bar"]))
59 , (collapseFilePath (joinPath [ "parent","foo",".."]) @?= (joinPath [ "parent"]))
60 , (collapseFilePath (joinPath [ "","parent","foo","..","..","bar"]) @?= (joinPath [ "","bar"]))
61 , (collapseFilePath (joinPath [ "",".","parent","foo"]) @?= (joinPath [ "","parent","foo"]))]