pandoc/tests/Tests/Shared.hs
John MacFarlane 8165014df6 Removed --normalize option and normalization functions from Shared.
* Removed normalize, normalizeInlines, normalizeBlocks
  from Text.Pandoc.Shared.  These shouldn't now be necessary,
  since normalization is handled automatically by the Builder
  monoid instance.

* Remove `--normalize` command-line option.

* Don't use normalize in tests.

* A few revisions to readers so they work well without normalize.
2017-01-25 17:07:41 +01:00

40 lines
2.1 KiB
Haskell

module Tests.Shared (tests) where
import Text.Pandoc.Shared
import Test.Framework
import Text.Pandoc.Arbitrary()
import Test.Framework.Providers.HUnit
import Test.HUnit ( assertBool, (@?=) )
import Text.Pandoc.Builder
import System.FilePath.Posix (joinPath)
tests :: [Test]
tests = [ testGroup "compactify'DL"
[ testCase "compactify'DL with empty def" $
assertBool "compactify'DL"
(let x = [(str "word", [para (str "def"), mempty])]
in compactify'DL x == x)
]
, testGroup "collapseFilePath" testCollapse
]
testCollapse :: [Test]
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"]))]