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 committed Aug 10, 2019
1 parent af6f3c9 commit 28e0d74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/luerl_return_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
-include_lib("common_test/include/ct.hrl").

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

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

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

simple_return(Config) ->
Expand All @@ -39,6 +39,9 @@ simple_return(Config) ->
fun_return(Config) ->
run_and_check(Config, "fun_return_multi.lua", [7, <<"str 1">>, 5.5, 11.0]).

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 28e0d74

Please sign in to comment.