summaryrefslogtreecommitdiff
path: root/tests/lvm.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-02-05 09:12:54 +0100
committerBenoit Giannangeli <giann008@gmail.com>2017-02-05 09:12:54 +0100
commit86a09b63a6a316ee0855ce1d5307ea89f0b6f1ec (patch)
tree9f94608831b94a8a287c3e5edbe1e74d397bb241 /tests/lvm.js
parent18b89ee8e1059a21f8d5e3a52c2e256b7dea79cb (diff)
downloadfengari-86a09b63a6a316ee0855ce1d5307ea89f0b6f1ec.tar.gz
fengari-86a09b63a6a316ee0855ce1d5307ea89f0b6f1ec.tar.bz2
fengari-86a09b63a6a316ee0855ce1d5307ea89f0b6f1ec.zip
Fixed bad use of L.top
Diffstat (limited to 'tests/lvm.js')
-rw-r--r--tests/lvm.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/lvm.js b/tests/lvm.js
index 1b4d8c3..54c40ae 100644
--- a/tests/lvm.js
+++ b/tests/lvm.js
@@ -1,3 +1,4 @@
+/*jshint esversion: 6 */
"use strict";
const test = require('tape');
@@ -60,7 +61,7 @@ test('LOADK, RETURN', function (t) {
}, "Program executed without errors");
t.strictEqual(
- vm.L.stack[0].value,
+ vm.L.stack[vm.L.top - 1].value,
"hello world",
"Program output is correct"
);
@@ -84,7 +85,7 @@ test('MOV', function (t) {
}, "Program executed without errors");
t.strictEqual(
- vm.L.stack[0].value,
+ vm.L.stack[vm.L.top - 1].value,
"hello world",
"Program output is correct"
);
@@ -107,7 +108,7 @@ test('Binary op', function (t) {
}, "Program executed without errors");
t.deepEqual(
- vm.L.stack.slice(0, 12).map(function (e) { return e.value; }),
+ vm.L.stack.slice(vm.L.top - 12 - 1, vm.L.top - 1).map(function (e) { return e.value; }),
[15, -5, 50, 0.5, 5, 9765625.0, 0, 0, 15, 15, 5120, 0],
"Program output is correct"
);
@@ -131,7 +132,7 @@ test('Unary op, LOADBOOL', function (t) {
}, "Program executed without errors");
t.deepEqual(
- vm.L.stack.slice(0, 3).map(function (e) { return e.value; }),
+ vm.L.stack.slice(vm.L.top - 3 - 1, vm.L.top - 1).map(function (e) { return e.value; }),
[-5, true, -6],
"Program output is correct"
);
@@ -154,7 +155,7 @@ test('NEWTABLE', function (t) {
}, "Program executed without errors");
t.ok(
- vm.L.stack[0] instanceof Table,
+ vm.L.stack[vm.L.top - 1] instanceof Table,
"Program output is correct"
);
});
@@ -171,12 +172,18 @@ test('CALL', function (t) {
return c
`, vm;
- t.plan(0);
+ t.plan(2);
t.comment("Running following code: \n" + luaCode);
- // t.doesNotThrow(function () {
+ t.doesNotThrow(function () {
vm = getVM(luaCode);
vm.execute();
- // }, "Program executed without errors");
+ }, "Program executed without errors");
+
+ t.strictEqual(
+ vm.L.stack[vm.L.top - 1].value,
+ 3,
+ "Program output is correct"
+ );
}); \ No newline at end of file