diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2019-05-19 15:26:00 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2019-05-29 10:07:43 +0200 |
commit | 505f5bf5d951a5c4342f7acce9bea5f260dc9d78 (patch) | |
tree | 3b201baedf4003cdb17fa58c444bbb158faf213d /test/Tests/Lua.hs | |
parent | d07ed83d705df491bba7b295bd5e80629d971685 (diff) | |
download | pandoc-505f5bf5d951a5c4342f7acce9bea5f260dc9d78.tar.gz |
Lua: add Version type to simplify comparisons
Version specifiers like `PANDOC_VERSION` and `PANDOC_API_VERSION` are
turned into `Version` objects. The objects simplify version-appropriate
comparisons while maintaining backward-compatibility.
A function `pandoc.types.Version` is added as part of the newly
introduced module `pandoc.types`, allowing users to create version
objects in scripts.
Diffstat (limited to 'test/Tests/Lua.hs')
-rw-r--r-- | test/Tests/Lua.hs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs index c585182e4..7a1261eb2 100644 --- a/test/Tests/Lua.hs +++ b/test/Tests/Lua.hs @@ -15,7 +15,6 @@ module Tests.Lua ( runLuaTest, tests ) where import Prelude import Control.Monad (when) -import Data.Version (Version (versionBranch)) import System.FilePath ((</>)) import Test.Tasty (TestTree, localOption) import Test.Tasty.HUnit (Assertion, assertEqual, testCase) @@ -34,6 +33,7 @@ import Text.Pandoc.Options (def) import Text.Pandoc.Shared (pandocVersion) import qualified Foreign.Lua as Lua +import qualified Data.ByteString.Char8 as BS tests :: [TestTree] tests = map (localOption (QuickCheckTests 20)) @@ -135,17 +135,14 @@ tests = map (localOption (QuickCheckTests 20)) (doc $ para (str $ "lua" </> "script-name.lua")) , testCase "Pandoc version is set" . runLuaTest $ do - Lua.getglobal' "table.concat" Lua.getglobal "PANDOC_VERSION" - Lua.push ("." :: String) -- separator - Lua.call 2 1 - Lua.liftIO . assertEqual "pandoc version is wrong" pandocVersion - =<< Lua.peek Lua.stackTop + Lua.liftIO . + assertEqual "pandoc version is wrong" (BS.pack pandocVersion) + =<< Lua.tostring' Lua.stackTop , testCase "Pandoc types version is set" . runLuaTest $ do - let versionNums = versionBranch pandocTypesVersion Lua.getglobal "PANDOC_API_VERSION" - Lua.liftIO . assertEqual "pandoc-types version is wrong" versionNums + Lua.liftIO . assertEqual "pandoc-types version is wrong" pandocTypesVersion =<< Lua.peek Lua.stackTop , testCase "Allow singleton inline in constructors" . runLuaTest $ do |