summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2018-01-12 21:26:34 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2018-01-12 21:28:27 +0100
commit6528082401100cd8ef26c8dc3e953b960a997827 (patch)
tree3ab3cd0658d9f8ecef55ac5ebe684717c3c14763 /test
parentf130109b90d4f369a6d8d03c7a520e95db2e0d1f (diff)
Lua filters: improve error messages
Provide more context about the task which caused an error.
Diffstat (limited to 'test')
-rw-r--r--test/Tests/Lua.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs
index bbce2ac42..9df5e79cd 100644
--- a/test/Tests/Lua.hs
+++ b/test/Tests/Lua.hs
@@ -123,6 +123,16 @@ tests = map (localOption (QuickCheckTests 20))
Lua.getglobal "PANDOC_API_VERSION"
Lua.liftIO . assertEqual "pandoc-types version is wrong" versionNums
=<< Lua.peek Lua.stackTop
+
+ , testCase "informative error messages" . runPandocLua' $ do
+ Lua.pushboolean True
+ err <- Lua.peekEither Lua.stackTop :: Lua.Lua (Either String Pandoc)
+ case err of
+ Left msg -> do
+ let expectedMsg = "Could not get Pandoc value: "
+ ++ "expected table but got boolean."
+ Lua.liftIO $ assertEqual "unexpected error message" expectedMsg msg
+ Right _ -> error "Getting a Pandoc element from a bool should fail."
]
assertFilterConversion :: String -> FilePath -> Pandoc -> Pandoc -> Assertion