aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-02 09:54:45 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-02 11:02:43 +0100
commit490ee0d109671b6f7e9d3d56e8122f41647fed4c (patch)
tree4300c4e89e678859a1777ca1c3dd5ee8d16c3b37 /tests
parent61168b0ab774e7be6deb1573fbcc9b1a53a37f4e (diff)
downloadfengari-490ee0d109671b6f7e9d3d56e8122f41647fed4c.tar.gz
fengari-490ee0d109671b6f7e9d3d56e8122f41647fed4c.tar.bz2
fengari-490ee0d109671b6f7e9d3d56e8122f41647fed4c.zip
[Parsing tests] FORPREP, FORLOOP
Diffstat (limited to 'tests')
-rw-r--r--tests/lexparse.js66
-rw-r--r--tests/lvm.js1
2 files changed, 67 insertions, 0 deletions
diff --git a/tests/lexparse.js b/tests/lexparse.js
index 7ef5fe3..7a12985 100644
--- a/tests/lexparse.js
+++ b/tests/lexparse.js
@@ -467,4 +467,70 @@ test('TEST (false)', function (t) {
"goodbye",
"Program output is correct"
);
+});
+
+
+test('FORPREP, FORLOOP (int)', function (t) {
+ let luaCode = `
+ local total = 0
+
+ for i = 0, 10 do
+ total = total + i
+ end
+
+ return total
+ `, 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_tointeger(L, -1),
+ 55,
+ "Program output is correct"
+ );
+});
+
+
+test('FORPREP, FORLOOP (float)', function (t) {
+ let luaCode = `
+ local total = 0
+
+ for i = 0.5, 10.5 do
+ total = total + i
+ end
+
+ return total
+ `, 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_tonumber(L, -1),
+ 60.5,
+ "Program output is correct"
+ );
}); \ No newline at end of file
diff --git a/tests/lvm.js b/tests/lvm.js
index f9fb347..f5948eb 100644
--- a/tests/lvm.js
+++ b/tests/lvm.js
@@ -445,6 +445,7 @@ test('FORPREP, FORLOOP (int)', function (t) {
);
});
+
test('FORPREP, FORLOOP (float)', function (t) {
let luaCode = `
local total = 0