From 0926e6a6d00ee13e594e87ec8fc06f8e754eb145 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Mon, 6 Feb 2017 09:15:30 +0100 Subject: Multiple return --- tests/lvm.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tests/lvm.js b/tests/lvm.js index 729a66d..0a71bf8 100644 --- a/tests/lvm.js +++ b/tests/lvm.js @@ -186,4 +186,36 @@ test('CALL', function (t) { 3, "Program output is correct" ); -}); \ No newline at end of file +}); + + +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 + `, vm; + + t.plan(2); + + t.comment("Running following code: \n" + luaCode); + + t.doesNotThrow(function () { + vm = getVM(luaCode); + vm.execute(); + }, "Program executed without errors"); + + t.deepEqual( + vm.L.stack.slice(vm.L.stack.length - 3).map(function (e) { return e.value; }), + [3, -1, 2], + "Program output is correct" + ); +}); -- cgit v1.2.3-70-g09d2