summaryrefslogtreecommitdiff
path: root/tests/lexparse.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-01 13:58:39 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-01 13:58:39 +0100
commit69a7af7a8af1e737fe6afe47998b90c8fd778998 (patch)
tree41e8e7fae91044ea90eeb003a66d76add378dd08 /tests/lexparse.js
parentfcbf535dc7f14ce00d307bc3874d22f0d6cce9e5 (diff)
downloadfengari-69a7af7a8af1e737fe6afe47998b90c8fd778998.tar.gz
fengari-69a7af7a8af1e737fe6afe47998b90c8fd778998.tar.bz2
fengari-69a7af7a8af1e737fe6afe47998b90c8fd778998.zip
[Parsing tests] Binary op
Diffstat (limited to 'tests/lexparse.js')
-rw-r--r--tests/lexparse.js30
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