aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-06 08:55:53 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-06 08:55:53 +0100
commit55db79dace02d22a7e0a6462cbf0b2b52f411639 (patch)
tree5ab9ac88f7ce7eff09d736a5adf470bbba8b4079 /tests
parentdfe6b5f2c1bde6900f81f1bb6ddc49724baa0471 (diff)
downloadfengari-55db79dace02d22a7e0a6462cbf0b2b52f411639.tar.gz
fengari-55db79dace02d22a7e0a6462cbf0b2b52f411639.tar.bz2
fengari-55db79dace02d22a7e0a6462cbf0b2b52f411639.zip
postcall and precall
In the tests, we just look at the last n elements of the stack to check our results. This is because the executed script itself doesn't expect any result, so we did not put results at L.top.
Diffstat (limited to 'tests')
-rw-r--r--tests/lvm.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/lvm.js b/tests/lvm.js
index d328b6b..729a66d 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.top].value,
+ vm.L.stack[vm.L.stack.length - 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.top].value,
+ vm.L.stack[vm.L.stack.length - 1].value,
"hello world",
"Program output is correct"
);
@@ -108,7 +108,7 @@ test('Binary op', function (t) {
}, "Program executed without errors");
t.deepEqual(
- vm.L.stack.slice(vm.L.top, vm.L.top + 12).map(function (e) { return e.value; }),
+ vm.L.stack.slice(vm.L.stack.length - 12).map(function (e) { return e.value; }),
[15, -5, 50, 0.5, 5, 9765625.0, 0, 0, 15, 15, 5120, 0],
"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.top - 3, vm.L.top).map(function (e) { return e.value; }),
+ vm.L.stack.slice(vm.L.stack.length - 3).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.top] instanceof Table,
+ vm.L.stack[vm.L.stack.length - 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.top].value,
+ vm.L.stack[vm.L.stack.length - 1].value,
3,
"Program output is correct"
);