Skip to content

Commit

Permalink
test to use table as indexing a table
Browse files Browse the repository at this point in the history
  • Loading branch information
f3c0 authored and davydog187 committed Sep 28, 2024
1 parent c9458ed commit e0adc7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/luerl_return_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
-include_lib("common_test/include/ct.hrl").

-export([all/0, groups/0]).
-export([simple_return/1, fun_return/1, variable_args/1, check_unicode/1]).

-export([simple_return/1, fun_return/1, variable_args/1, check_unicode/1, table_tests/1]).

all() ->
[
Expand All @@ -26,7 +27,7 @@ all() ->

groups() ->
[
{return, [parallel], [simple_return, fun_return, variable_args, check_unicode]}
{return, [parallel], [simple_return, fun_return, variable_args, check_unicode, table_tests]}
].

simple_return(Config) ->
Expand Down Expand Up @@ -55,6 +56,10 @@ check_unicode_call_fun(Input, Length, LuaFun, St) ->
{[Input, Input, true, Length, Length], _} =
luerl:call_function([LuaFun], [Input], St).

table_tests(Config) ->
run_and_check(Config, "table_indexed_table.lua", [111, 222, 333]).


run_tests(Config, Tests) ->
[run_and_check(Config, Script, Expected) || {Script, Expected} <- Tests].

Expand Down
9 changes: 9 additions & 0 deletions test/luerl_return_SUITE_data/table_indexed_table.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tk1 = { a = 1 }
tk2 = { b = 2 }

t = {}
t[tk1] = 111
t[tk2] = 222
t[t] = 333

return t[tk1], t[tk2], t[t]

0 comments on commit e0adc7c

Please sign in to comment.