summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-03 15:25:07 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-03 15:25:07 +0100
commitdb136649e45a63edb8bc511e756249a9e6ca9ea7 (patch)
treedcc1c873af32ade27d488bbb13c8eb77ba247b8e
parentd2097b98de99a24186be2af08de1645d72adce28 (diff)
downloadfengari-db136649e45a63edb8bc511e756249a9e6ca9ea7.tar.gz
fengari-db136649e45a63edb8bc511e756249a9e6ca9ea7.tar.bz2
fengari-db136649e45a63edb8bc511e756249a9e6ca9ea7.zip
luaL_loadbuffer binary test
-rw-r--r--src/lapi.js1
-rw-r--r--tests/load.js35
2 files changed, 35 insertions, 1 deletions
diff --git a/src/lapi.js b/src/lapi.js
index a11dbca..dae533d 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -678,7 +678,6 @@ const lua_rawequal = function(L, index1, index2) {
** 'load' and 'call' functions (run Lua code)
*/
-// TODO: reader is ignored because we don't implement ZIO
const lua_load = function(L, reader, data, chunckname, mode) {
let z = new llex.MBuffer(L, data, reader);
if (!chunckname) chunckname = "?";
diff --git a/tests/load.js b/tests/load.js
index 0f524f3..86c3904 100644
--- a/tests/load.js
+++ b/tests/load.js
@@ -79,4 +79,39 @@ test('load', function (t) {
"Correct element(s) on the stack"
);
+});
+
+
+test('luaL_loadbuffer', function (t) {
+ let luaCode = `
+ local a = "hello world"
+ return a
+ `, L;
+
+ t.plan(3);
+
+ t.doesNotThrow(function () {
+
+ let bc = toByteCode(luaCode).dataView;
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lauxlib.luaL_loadbuffer(L, bc, null, "test");
+
+ }, "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"
+ );
+
}); \ No newline at end of file