From 19005492cf3b3597492e4fab9a2893dbdba1d42a Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 1 Mar 2017 15:17:47 +0100 Subject: [Parsing tests] Multiple return --- tests/lexparse.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) 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 -- cgit v1.2.3-70-g09d2