aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-23 09:59:38 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-23 09:59:38 +0100
commitcd46ac257c623b4966ebf9f86523feff65746c38 (patch)
tree310e985e47d2731558095a3c58e4a2eb8cb2ff28 /tests
parent99564913987698cdfc2528a93b5157030e637ced (diff)
downloadfengari-cd46ac257c623b4966ebf9f86523feff65746c38.tar.gz
fengari-cd46ac257c623b4966ebf9f86523feff65746c38.tar.bz2
fengari-cd46ac257c623b4966ebf9f86523feff65746c38.zip
Handle binary in luaL_loadfilex
Diffstat (limited to 'tests')
-rw-r--r--tests/load.js33
-rw-r--r--tests/loadfile-test.bcbin0 -> 142 bytes
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/load.js b/tests/load.js
index ef37309..143549a 100644
--- a/tests/load.js
+++ b/tests/load.js
@@ -150,6 +150,39 @@ test('loadfile', function (t) {
});
+test('loadfile (binary)', function (t) {
+ let luaCode = `
+ local f = loadfile("tests/loadfile-test.bc")
+ return f()
+ `, L;
+
+ t.plan(3);
+
+ t.doesNotThrow(function () {
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lauxlib.luaL_loadstring(L, luaCode);
+
+ }, "Lua program loaded without error");
+
+ t.doesNotThrow(function () {
+
+ lapi.lua_call(L, 0, -1);
+
+ }, "Lua program ran without error");
+
+ t.strictEqual(
+ lapi.lua_tostring(L, -1),
+ "hello world",
+ "Correct element(s) on the stack"
+ );
+
+});
+
+
test('dofile', function (t) {
let luaCode = `
return dofile("tests/loadfile-test.lua")
diff --git a/tests/loadfile-test.bc b/tests/loadfile-test.bc
new file mode 100644
index 0000000..502b0ce
--- /dev/null
+++ b/tests/loadfile-test.bc
Binary files differ