aboutsummaryrefslogtreecommitdiff
path: root/tests/lvm.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-06 09:15:30 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-06 09:15:30 +0100
commit0926e6a6d00ee13e594e87ec8fc06f8e754eb145 (patch)
tree5b958d5ddfbd82892f8c6a0aa1f78747c4de66a0 /tests/lvm.js
parent55db79dace02d22a7e0a6462cbf0b2b52f411639 (diff)
downloadfengari-0926e6a6d00ee13e594e87ec8fc06f8e754eb145.tar.gz
fengari-0926e6a6d00ee13e594e87ec8fc06f8e754eb145.tar.bz2
fengari-0926e6a6d00ee13e594e87ec8fc06f8e754eb145.zip
Multiple return
Diffstat (limited to 'tests/lvm.js')
-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"
+ );
+});