diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-03-01 15:17:47 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-03-01 15:17:47 +0100 |
commit | 19005492cf3b3597492e4fab9a2893dbdba1d42a (patch) | |
tree | e92a951f8dfbda214aafbe91e52b85c7ac114737 /tests/lexparse.js | |
parent | 6d3c16cb0b7a859ff45e62ed83252f667d3b74d5 (diff) | |
download | fengari-19005492cf3b3597492e4fab9a2893dbdba1d42a.tar.gz fengari-19005492cf3b3597492e4fab9a2893dbdba1d42a.tar.bz2 fengari-19005492cf3b3597492e4fab9a2893dbdba1d42a.zip |
[Parsing tests] Multiple return
Diffstat (limited to 'tests/lexparse.js')
-rw-r--r-- | tests/lexparse.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/lexparse.js b/tests/lexparse.js index 98f55bb..1271a36 100644 --- a/tests/lexparse.js +++ b/tests/lexparse.js @@ -188,4 +188,40 @@ test('CALL', function (t) { 3, "Program output is correct" ); +}); + +test('Multiple return', function (t) { + let luaCode = ` + local f = function (a, b) + return a + b, a - b, a * b + end + + local c + local d + local e + + c, d, e = f(1,2) + + return c, d, e + `, L; + + t.plan(2); + + t.doesNotThrow(function () { + + L = lauxlib.luaL_newstate(); + + linit.luaL_openlibs(L); + + lapi.lua_load(L, null, luaCode, "test", "text"); + + lapi.lua_call(L, 0, -1); + + }, "JS Lua program ran without error"); + + t.deepEqual( + L.stack.slice(L.top - 3, L.top).map(e => e.value), + [3, -1, 2], + "Program output is correct" + ); });
\ No newline at end of file |