From 20846070c7809ac30a0aed3dbd4d04716e1ef1be Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 8 Feb 2017 09:14:35 +0100 Subject: OP_LT, OP_EQ, fixed bad sBx --- tests/lvm.js | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/lvm.js b/tests/lvm.js index f826091..e2454eb 100644 --- a/tests/lvm.js +++ b/tests/lvm.js @@ -275,7 +275,7 @@ test('VARARG', function (t) { test('LE, JMP', function (t) { let luaCode = ` - local a, b = 1, 2 + local a, b = 1, 1 return a >= b `, vm; @@ -289,9 +289,57 @@ test('LE, JMP', function (t) { vm.execute(); }, "Program executed without errors"); + t.strictEqual( + vm.L.stack[vm.L.top - 1].value, + true, + "Program output is correct" + ); +}); + + +test('LT', function (t) { + let luaCode = ` + local a, b = 1, 1 + + return a > b + `, vm; + + t.plan(2); + + t.comment("Running following code: \n" + luaCode); + + t.doesNotThrow(function () { + vm = getVM(luaCode); + vm.execute(); + }, "Program executed without errors"); + t.strictEqual( vm.L.stack[vm.L.top - 1].value, false, "Program output is correct" ); +}); + + +test('EQ', function (t) { + let luaCode = ` + local a, b = 1, 1 + + return a == b + `, vm; + + t.plan(2); + + t.comment("Running following code: \n" + luaCode); + + t.doesNotThrow(function () { + vm = getVM(luaCode); + vm.execute(); + }, "Program executed without errors"); + + t.strictEqual( + vm.L.stack[vm.L.top - 1].value, + true, + "Program output is correct" + ); }); \ No newline at end of file -- cgit v1.2.3-70-g09d2