From 7ad7432bcf5e0666b719c768c3c0041fbb574feb Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Thu, 2 Mar 2017 09:33:31 +0100 Subject: [Parsing tests] TESTSET --- tests/lexparse.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'tests') diff --git a/tests/lexparse.js b/tests/lexparse.js index 2b0cc46..2470e5d 100644 --- a/tests/lexparse.js +++ b/tests/lexparse.js @@ -373,4 +373,64 @@ test('EQ', function (t) { true, "Program output is correct" ); +}); + + +test('TESTSET (and)', function (t) { + let luaCode = ` + local a = true + local b = "hello" + + return a and 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_tostring(L, -1), + "hello", + "Program output is correct" + ); +}); + + +test('TESTSET (or)', function (t) { + let luaCode = ` + local a = false + local b = "hello" + + return a or 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_tostring(L, -1), + "hello", + "Program output is correct" + ); }); \ No newline at end of file -- cgit v1.2.3-54-g00ecf