diff options
Diffstat (limited to 'tests/lexparse.js')
-rw-r--r-- | tests/lexparse.js | 30 |
1 files changed, 30 insertions, 0 deletions
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 |