Skip to content

Commit

Permalink
Test safety of failing __index meta method
Browse files Browse the repository at this point in the history
  • Loading branch information
tarleb committed Jul 24, 2017
1 parent 64abcb0 commit e9c7c14
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/Foreign/LuaTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,16 @@ tests = testGroup "lua integration tests"
assertEqual "alternative failed" (Right True) =<<
runLuaEither (throwLuaError "test" <|> return True)

, testCase "Control.Applicative.empty implementation throws an exception" $
, testCase "Applicative.empty implementation throws an exception" $
assertBool "empty doesn't throw" . isLeft =<< runLuaEither empty

, testCase "catching error of a failing meta method" $
assertBool "compuation was expected to fail" . isLeft =<<
let comp = do
pushLuaExpr "setmetatable({}, {__index = error})"
getfield (-1) "foo" :: Lua ()
in runLuaEither comp

, testCase "calling a function that errors throws exception" $
let msg = "error message"
luaCode = "return error('" ++ msg ++ "')"
Expand Down

0 comments on commit e9c7c14

Please sign in to comment.