Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors raise inside Elixir functions should propagate back to Luerl #56

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions test/lua_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,42 @@
end)
""")
end

test "functions that raise errors still update state" do
assert {[2], _} =
Lua.eval!("""
global = 1

pcall(function()
global = 2
error("bang")
end)

return global
""")
end

test "functions that raise errors from Elixir still update state" do

Check failure on line 302 in test/lua_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test eval!/1 functions that raise errors from Elixir still update state (LuaTest)
lua =
Lua.set!(Lua.new(), [:foo], fn [callback], lua ->
Lua.call_function!(lua, callback, [])
end)

assert {[2], _lua} =
Lua.eval!(lua, """
global = 1

pcall(function()
foo(function()
global = 2

error("whoopsie")
end)
end)

return global
""")
end
end

describe "load_chunk!/2" do
Expand Down
Loading