From db136649e45a63edb8bc511e756249a9e6ca9ea7 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 3 Mar 2017 15:25:07 +0100 Subject: luaL_loadbuffer binary test --- tests/load.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests/load.js') 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 -- cgit v1.2.3-54-g00ecf