From 69a7af7a8af1e737fe6afe47998b90c8fd778998 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 1 Mar 2017 13:58:39 +0100 Subject: [Parsing tests] Binary op --- tests/lexparse.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests/lexparse.js') diff --git a/tests/lexparse.js b/tests/lexparse.js index 10c4845..2604e72 100644 --- a/tests/lexparse.js +++ b/tests/lexparse.js @@ -67,4 +67,34 @@ test('MOVE', function (t) { "Correct element(s) on the stack" ); +}); + + +test('Binary op', function (t) { + let luaCode = ` + local a = 5 + local b = 10 + return a + b, a - b, a * b, a / b, a % b, a^b, a // b, a & b, a | b, a ~ b, a << b, 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.deepEqual( + L.stack.slice(L.top - 12, L.top).map(e => e.value), + [15, -5, 50, 0.5, 5, 9765625.0, 0, 0, 15, 15, 5120, 0], + "Program output is correct" + ); + }); \ No newline at end of file -- cgit v1.2.3-54-g00ecf