diff options
Diffstat (limited to 'test/Tests/Lua.hs')
| -rw-r--r-- | test/Tests/Lua.hs | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs index 4040c38ac..c585182e4 100644 --- a/test/Tests/Lua.hs +++ b/test/Tests/Lua.hs @@ -11,7 +11,7 @@ Unit and integration tests for pandoc's Lua subsystem. -} -module Tests.Lua ( tests ) where +module Tests.Lua ( runLuaTest, tests ) where import Prelude import Control.Monad (when) @@ -128,29 +128,13 @@ tests = map (localOption (QuickCheckTests 20)) (doc $ divWith ("", [], kv_before) (para "nil")) (doc $ divWith ("", [], kv_after) (para "nil")) - , testCase "Test module pandoc.utils" $ - assertFilterConversion "pandoc.utils doesn't work as expected." - "test-pandoc-utils.lua" - (doc $ para "doesn't matter") - (doc $ mconcat [ plain (str "blocks_to_inlines: OK") - , plain (str "hierarchicalize: OK") - , plain (str "normalize_date: OK") - , plain (str "pipe: OK") - , plain (str "failing pipe: OK") - , plain (str "read: OK") - , plain (str "failing read: OK") - , plain (str "sha1: OK") - , plain (str "stringify: OK") - , plain (str "to_roman_numeral: OK") - ]) - , testCase "Script filename is set" $ assertFilterConversion "unexpected script name" "script-name.lua" (doc $ para "ignored") (doc $ para (str $ "lua" </> "script-name.lua")) - , testCase "Pandoc version is set" . runLua' $ do + , testCase "Pandoc version is set" . runLuaTest $ do Lua.getglobal' "table.concat" Lua.getglobal "PANDOC_VERSION" Lua.push ("." :: String) -- separator @@ -158,13 +142,13 @@ tests = map (localOption (QuickCheckTests 20)) Lua.liftIO . assertEqual "pandoc version is wrong" pandocVersion =<< Lua.peek Lua.stackTop - , testCase "Pandoc types version is set" . runLua' $ do + , 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.peek Lua.stackTop - , testCase "Allow singleton inline in constructors" . runLua' $ do + , testCase "Allow singleton inline in constructors" . runLuaTest $ do Lua.liftIO . assertEqual "Not the exptected Emph" (Emph [Str "test"]) =<< Lua.callFunc "pandoc.Emph" (Str "test") Lua.liftIO . assertEqual "Unexpected element" (Para [Str "test"]) @@ -178,19 +162,19 @@ tests = map (localOption (QuickCheckTests 20)) Lua.peek Lua.stackTop ) - , testCase "Elements with Attr have `attr` accessor" . runLua' $ do + , testCase "Elements with Attr have `attr` accessor" . runLuaTest $ do Lua.push (Div ("hi", ["moin"], []) [Para [Str "ignored"]]) Lua.getfield Lua.stackTop "attr" Lua.liftIO . assertEqual "no accessor" (("hi", ["moin"], []) :: Attr) =<< Lua.peek Lua.stackTop - , testCase "module `pandoc.system` is present" . runLua' $ do + , testCase "module `pandoc.system` is present" . runLuaTest $ do Lua.getglobal' "pandoc.system" ty <- Lua.ltype Lua.stackTop Lua.liftIO $ assertEqual "module should be a table" Lua.TypeTable ty - , testCase "informative error messages" . runLua' $ do + , testCase "informative error messages" . runLuaTest $ do Lua.pushboolean True err <- Lua.peekEither Lua.stackTop case (err :: Either String Pandoc) of @@ -212,7 +196,7 @@ roundtripEqual :: (Eq a, Lua.Peekable a, Lua.Pushable a) => a -> IO Bool roundtripEqual x = (x ==) <$> roundtripped where roundtripped :: (Lua.Peekable a, Lua.Pushable a) => IO a - roundtripped = runLua' $ do + roundtripped = runLuaTest $ do oldSize <- Lua.gettop Lua.push x size <- Lua.gettop @@ -223,8 +207,8 @@ roundtripEqual x = (x ==) <$> roundtripped Left e -> error (show e) Right y -> return y -runLua' :: Lua.Lua a -> IO a -runLua' op = runIOorExplode $ do +runLuaTest :: Lua.Lua a -> IO a +runLuaTest op = runIOorExplode $ do setUserDataDir (Just "../data") res <- runLua op case res of |
