git.iko.soy/typeable/pandoc
on master help sign in
Added tests of latex tokenizer.
79c3f57John MacFarlane
test/Tests/Readers/LaTeX.hs+18−1
@@ -3,7 +3,11 @@ module Tests.Readers.LaTeX (tests) where
3
3
4import Data.Text (Text)
4import Data.Text (Text)
5import qualified Data.Text as T
5import qualified Data.Text as T
6+import qualified Text.Pandoc.UTF8 as UTF8
7+import Text.Pandoc.Readers.LaTeX (tokenize, untokenize)
6import Test.Tasty
8import Test.Tasty
9+import Test.Tasty.HUnit
10+import Test.Tasty.QuickCheck
7import Tests.Helpers
11import Tests.Helpers
8import Text.Pandoc
12import Text.Pandoc
9import Text.Pandoc.Arbitrary ()
13import Text.Pandoc.Arbitrary ()
@@ -22,8 +26,21 @@ simpleTable' :: [Alignment] -> [[Blocks]] -> Blocks
22simpleTable' aligns = table "" (zip aligns (repeat 0.0))
26simpleTable' aligns = table "" (zip aligns (repeat 0.0))
23 (map (const mempty) aligns)
27 (map (const mempty) aligns)
24
28
29+tokUntokRt :: String -> Bool
30+tokUntokRt s = untokenize (tokenize "random" t) == t
31+ where t = T.pack s
32+
25tests :: [TestTree]
33tests :: [TestTree]
26−tests = [ testGroup "basic"
34+tests = [ testGroup "tokenization"
35+ [ testCase "tokenizer round trip on test case" $ do
36+ orig <- T.pack <$> UTF8.readFile "../test/latex-reader.latex"
37+ let new = untokenize $ tokenize "../test/latex-reader.latex"
38+ orig
39+ assertEqual "untokenize . tokenize is identity" orig new
40+ , testProperty "untokenize . tokenize is identity" tokUntokRt
41+ ]
42+
43+ , testGroup "basic"
27 [ "simple" =:
44 [ "simple" =:
28 "word" =?> para "word"
45 "word" =?> para "word"
29 , "space" =:
46 , "space" =: