@@ -3,7 +3,11 @@ module Tests.Readers.LaTeX (tests) where
33
44import Data.Text (Text)
55import qualified Data.Text as T
6+import qualified Text.Pandoc.UTF8 as UTF8
7+import Text.Pandoc.Readers.LaTeX (tokenize, untokenize)
68import Test.Tasty
9+import Test.Tasty.HUnit
10+import Test.Tasty.QuickCheck
711import Tests.Helpers
812import Text.Pandoc
913import Text.Pandoc.Arbitrary ()
@@ -22,8 +26,21 @@ simpleTable' :: [Alignment] -> [[Blocks]] -> Blocks
2226simpleTable' aligns = table "" (zip aligns (repeat 0.0))
2327 (map (const mempty) aligns)
2428
29+tokUntokRt :: String -> Bool
30+tokUntokRt s = untokenize (tokenize "random" t) == t
31+ where t = T.pack s
32+
2533tests :: [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"
2744 [ "simple" =:
2845 "word" =?> para "word"
2946 , "space" =: