Skip to content

Commit

Permalink
Merge pull request #188 from rvirding/test-table-indexed-table
Browse files Browse the repository at this point in the history
test to use table as indexing a table
  • Loading branch information
davydog187 authored Sep 28, 2024
2 parents c9458ed + e0adc7c commit f158251
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 f158251

Please sign in to comment.