aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lvm.js34
1 files changed, 33 insertions, 1 deletions
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"
+ );
+});