diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2022-03-08 09:53:57 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2022-03-08 09:53:57 -0800 |
| commit | 82d9f5eb8ba60bca5760ac84357ed056c0cf4853 (patch) | |
| tree | 08b1da7947fc1948dc1a61a47d9d3a5a7c1293d6 | |
| parent | 0adfc6e58e36141a826ea4201ee976675b2dc991 (diff) | |
Add tests for idempotency of makeSections.
See #7950.
| -rw-r--r-- | test/Tests/Shared.hs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/Tests/Shared.hs b/test/Tests/Shared.hs index 797d9fe75..439196145 100644 --- a/test/Tests/Shared.hs +++ b/test/Tests/Shared.hs @@ -15,6 +15,7 @@ module Tests.Shared (tests) where import System.FilePath.Posix (joinPath) import Test.Tasty import Text.Pandoc.Arbitrary () +import Test.Tasty.QuickCheck (testProperty) import Text.Pandoc.Builder import Text.Pandoc.Shared import Test.Tasty.HUnit @@ -33,7 +34,21 @@ tests = [ testGroup "compactifyDL" , testGroup "collapseFilePath" testCollapse , testGroup "toLegacyTable" testLegacyTable , testGroup "table of contents" testTOC - ] + , testGroup "makeSections" + [ testProperty "makeSections is idempotent" makeSectionsIsIdempotent + , testCase "makeSections is idempotent for test case" $ + let d = header 1 "H1" <> header 2 "H2" <> header 3 "H3" <> + header 2 "H2a" <> header 4 "H4" <> header 1 "H1a" + d' = makeSections False Nothing $ toList d + in assertBool "makeSections is idempotent for test case" + (makeSections False Nothing d' == d') + ] + ] + +makeSectionsIsIdempotent :: [Block] -> Bool +makeSectionsIsIdempotent d = + let d' = makeSections False Nothing d + in d' == makeSections False Nothing d' givesTOC :: String -> (Blocks, Blocks) -> TestTree givesTOC desc (blocks, toc) = test (toTableOfContents def) desc (toList blocks, head . toList $ toc) |
