Skip to content

Commit

Permalink
Pull in Luerl 1.2.3, allow for passing through of tref values (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
davydog187 authored Oct 3, 2024
1 parent 2d4fb75 commit eb5a7f2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
"ex_doc": {:hex, :ex_doc, "0.32.1", "21e40f939515373bcdc9cffe65f3b3543f05015ac6c3d01d991874129d173420", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.1", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "5142c9db521f106d61ff33250f779807ed2a88620e472ac95dc7d59c380113da"},
"luerl": {:hex, :luerl, "1.2.2", "a1a61be5bbebdb65d81b4153005d1fb6798b83f9e0a526647c4ffb1730b76356", [:rebar3], [], "hexpm", "a93d4bab56927a52064b7597b92c60e5b89fea0be479612775fab5e81cef0f15"},
"luerl": {:hex, :luerl, "1.2.3", "df25f41944e57a7c4d9ef09d238bc3e850276c46039cfc12b8bb42eccf36fcb1", [:rebar3], [], "hexpm", "1b4b9d0ca5d7d280d1d2787a6a5ee9f5a212641b62bff91556baa53805df3aed"},
"makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.5", "e0ff5a7c708dda34311f7522a8758e23bfcd7d8d8068dc312b5eb41c6fd76eba", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "94d2e986428585a21516d7d7149781480013c56e30c6a233534bedf38867a59a"},
Expand Down
27 changes: 27 additions & 0 deletions test/lua_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ defmodule LuaTest do
assert [{1, 1}, {2, 2}] = Lua.decode!(lua, ref)
end

test "it can re-encode table refs" do
lua = Lua.new()

assert {{:tref, _} = tref, lua} = Lua.encode!(lua, %{a: 1})
assert {^tref, _lua} = Lua.encode!(lua, tref)
end

test "it raises for values that cannot be encoded" do
error = "Lua runtime error: Failed to encode {:foo, :bar}"

Expand Down Expand Up @@ -646,6 +653,16 @@ defmodule LuaTest do
end
end

defmodule GlobalVar do
use Lua.API, scope: "gv"

deflua get(name), state do
table = Lua.get!(state, [name])

{[table], state}
end
end

setup do
{:ok, lua: Lua.new()}
end
Expand Down Expand Up @@ -702,6 +719,16 @@ defmodule LuaTest do

assert {["bananas"], _lua} = Lua.eval!(lua, "return foo")
end

test "it can handle tref values", %{lua: lua} do
lua = Lua.load_api(lua, GlobalVar)

assert {[[{"a", 1}]], _lua} =
Lua.eval!(lua, """
foo = { a = 1 }
return gv.get("foo")
""")
end
end

describe "examples" do
Expand Down

0 comments on commit eb5a7f2

Please sign in to comment.