diff options
Diffstat (limited to 'pandoc-lua-engine/test/Tests/Lua')
| -rw-r--r-- | pandoc-lua-engine/test/Tests/Lua/Module.hs | 41 | ||||
| -rw-r--r-- | pandoc-lua-engine/test/Tests/Lua/Writer.hs | 41 |
2 files changed, 82 insertions, 0 deletions
diff --git a/pandoc-lua-engine/test/Tests/Lua/Module.hs b/pandoc-lua-engine/test/Tests/Lua/Module.hs new file mode 100644 index 000000000..fd3fc8998 --- /dev/null +++ b/pandoc-lua-engine/test/Tests/Lua/Module.hs @@ -0,0 +1,41 @@ +{- | +Module : Tests.Lua.Module +Copyright : © 2019-2022 Albert Krewinkel +License : GNU GPL, version 2 or above + +Maintainer : Albert Krewinkel <albert@zeitkraut.de> +Stability : alpha +Portability : portable + +Lua module tests +-} +module Tests.Lua.Module (tests) where + +import System.FilePath ((</>)) +import Test.Tasty (TestName, TestTree) +import Test.Tasty.Lua (testLuaFile) + +import Tests.Lua (runLuaTest) + +tests :: [TestTree] +tests = + [ testPandocLua "pandoc" + ("lua" </> "module" </> "pandoc.lua") + , testPandocLua "pandoc.List" + ("lua" </> "module" </> "pandoc-list.lua") + , testPandocLua "pandoc.mediabag" + ("lua" </> "module" </> "pandoc-mediabag.lua") + , testPandocLua "pandoc.path" + ("lua" </> "module" </> "pandoc-path.lua") + , testPandocLua "pandoc.template" + ("lua" </> "module" </> "pandoc-template.lua") + , testPandocLua "pandoc.types" + ("lua" </> "module" </> "pandoc-types.lua") + , testPandocLua "pandoc.utils" + ("lua" </> "module" </> "pandoc-utils.lua") + , testPandocLua "globals" + ("lua" </> "module" </> "globals.lua") + ] + +testPandocLua :: TestName -> FilePath -> TestTree +testPandocLua = testLuaFile runLuaTest diff --git a/pandoc-lua-engine/test/Tests/Lua/Writer.hs b/pandoc-lua-engine/test/Tests/Lua/Writer.hs new file mode 100644 index 000000000..4086b9768 --- /dev/null +++ b/pandoc-lua-engine/test/Tests/Lua/Writer.hs @@ -0,0 +1,41 @@ +{- | +Module : Tests.Lua.Writer +Copyright : © 2019-2022 Albert Krewinkel +License : GNU GPL, version 2 or above + +Maintainer : Albert Krewinkel <albert@zeitkraut.de> +Stability : alpha +Portability : portable + +Tests for custom Lua writers. +-} +module Tests.Lua.Writer (tests) where + +import Data.Default (Default (def)) +import Text.Pandoc.Class (runIOorExplode, readFileStrict) +import Text.Pandoc.Lua (writeCustom) +import Text.Pandoc.Readers (readNative) +import Test.Tasty (TestTree) +import Test.Tasty.Golden (goldenVsString) + +import qualified Data.ByteString.Lazy as BL +import qualified Text.Pandoc.UTF8 as UTF8 + +tests :: [TestTree] +tests = + [ goldenVsString "default testsuite" + "writer.custom" + (runIOorExplode $ do + source <- UTF8.toText <$> readFileStrict "testsuite.native" + doc <- readNative def source + txt <- writeCustom "sample.lua" def doc + pure $ BL.fromStrict (UTF8.fromText txt)) + + , goldenVsString "tables testsuite" + "tables.custom" + (runIOorExplode $ do + source <- UTF8.toText <$> readFileStrict "tables.native" + doc <- readNative def source + txt <- writeCustom "sample.lua" def doc + pure $ BL.fromStrict (UTF8.fromText txt)) + ] |
