summaryrefslogtreecommitdiff
path: root/tests/lvm.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-08 07:38:03 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-08 08:23:00 +0100
commita2031547aafbb07f6284cd10704435db23d9db60 (patch)
tree75677f2714f10cb6e7e298542af9d650e235c6d1 /tests/lvm.js
parent364326b97450564d41d37cdc7b2c4fbb8049c62f (diff)
downloadfengari-a2031547aafbb07f6284cd10704435db23d9db60.tar.gz
fengari-a2031547aafbb07f6284cd10704435db23d9db60.tar.bz2
fengari-a2031547aafbb07f6284cd10704435db23d9db60.zip
callstatus, OP_LE, OP_JMP, tests use L.top
Diffstat (limited to 'tests/lvm.js')
-rw-r--r--tests/lvm.js29
1 files changed, 11 insertions, 18 deletions
diff --git a/tests/lvm.js b/tests/lvm.js
index c93b1ed..f826091 100644
--- a/tests/lvm.js
+++ b/tests/lvm.js
@@ -61,7 +61,7 @@ test('LOADK, RETURN', function (t) {
}, "Program executed without errors");
t.strictEqual(
- vm.L.stack[vm.L.stack.length - 1].value,
+ vm.L.stack[vm.L.top - 1].value,
"hello world",
"Program output is correct"
);
@@ -85,7 +85,7 @@ test('MOV', function (t) {
}, "Program executed without errors");
t.strictEqual(
- vm.L.stack[vm.L.stack.length - 1].value,
+ vm.L.stack[vm.L.top - 1].value,
"hello world",
"Program output is correct"
);
@@ -132,7 +132,7 @@ test('Unary op, LOADBOOL', function (t) {
}, "Program executed without errors");
t.deepEqual(
- vm.L.stack.slice(vm.L.stack.length - 3).map(function (e) { return e.value; }),
+ vm.L.stack.slice(vm.L.top - 3, vm.L.top).map(function (e) { return e.value; }),
[-5, true, -6],
"Program output is correct"
);
@@ -155,7 +155,7 @@ test('NEWTABLE', function (t) {
}, "Program executed without errors");
t.ok(
- vm.L.stack[vm.L.stack.length - 1] instanceof Table,
+ vm.L.stack[vm.L.top - 1] instanceof Table,
"Program output is correct"
);
});
@@ -182,7 +182,7 @@ test('CALL', function (t) {
}, "Program executed without errors");
t.strictEqual(
- vm.L.stack[vm.L.stack.length - 1].value,
+ vm.L.stack[vm.L.top - 1].value,
3,
"Program output is correct"
);
@@ -214,7 +214,7 @@ test('Multiple return', function (t) {
}, "Program executed without errors");
t.deepEqual(
- vm.L.stack.slice(vm.L.stack.length - 3).map(function (e) { return e.value; }),
+ vm.L.stack.slice(vm.L.top - 3, vm.L.top).map(function (e) { return e.value; }),
[3, -1, 2],
"Program output is correct"
);
@@ -266,25 +266,18 @@ test('VARARG', function (t) {
}, "Program executed without errors");
t.deepEqual(
- vm.L.stack.slice(vm.L.stack.length - 3).map(function (e) { return e.value; }),
+ vm.L.stack.slice(vm.L.top - 3, vm.L.top).map(function (e) { return e.value; }),
[1, 2, 3],
"Program output is correct"
);
});
-test('GETUPVAL, SETUPVAL', function (t) {
+test('LE, JMP', function (t) {
let luaCode = `
- local a = 1
+ local a, b = 1, 2
- local f = function ()
- a = a + 1
- return a
- end
-
- f()
-
- return a
+ return a >= b
`, vm;
t.plan(2);
@@ -298,7 +291,7 @@ test('GETUPVAL, SETUPVAL', function (t) {
t.strictEqual(
vm.L.stack[vm.L.top - 1].value,
- 2,
+ false,
"Program output is correct"
);
}); \ No newline at end of file