From 5a0db9d250115470589d23cd8ad4b28982cabe06 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Thu, 2 Mar 2017 08:18:58 +0100 Subject: [Parsing tests] LE, JMP, LT, EQ --- tests/lexparse.js | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) (limited to 'tests') diff --git a/tests/lexparse.js b/tests/lexparse.js index 36dbf97..2b0cc46 100644 --- a/tests/lexparse.js +++ b/tests/lexparse.js @@ -286,4 +286,91 @@ test('VARARG', function (t) { [1, 2, 3], "Program output is correct" ); +}); + + +test('LE, JMP', function (t) { + let luaCode = ` + local a, b = 1, 1 + + return a >= b + `, L; + + t.plan(2); + + t.doesNotThrow(function () { + + L = lauxlib.luaL_newstate(); + + linit.luaL_openlibs(L); + + lapi.lua_load(L, null, luaCode, "test", "text"); + + lapi.lua_call(L, 0, -1); + + }, "JS Lua program ran without error"); + + t.strictEqual( + lapi.lua_toboolean(L, -1), + true, + "Program output is correct" + ); +}); + + +test('LT', function (t) { + let luaCode = ` + local a, b = 1, 1 + + return a > b + `, L; + + t.plan(2); + + t.doesNotThrow(function () { + + L = lauxlib.luaL_newstate(); + + linit.luaL_openlibs(L); + + lapi.lua_load(L, null, luaCode, "test", "text"); + + lapi.lua_call(L, 0, -1); + + }, "JS Lua program ran without error"); + + t.strictEqual( + lapi.lua_toboolean(L, -1), + false, + "Program output is correct" + ); +}); + + +test('EQ', function (t) { + let luaCode = ` + local a, b = 1, 1 + + return a == b + `, L; + + t.plan(2); + + t.doesNotThrow(function () { + + L = lauxlib.luaL_newstate(); + + linit.luaL_openlibs(L); + + lapi.lua_load(L, null, luaCode, "test", "text"); + + lapi.lua_call(L, 0, -1); + + }, "JS Lua program ran without error"); + + t.strictEqual( + lapi.lua_toboolean(L, -1), + true, + "Program output is correct" + ); }); \ No newline at end of file -- cgit v1.2.3-70-g09d2