From b9cb6c4fe614e16debddeed202f5ededc40719bf Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sat, 7 Jul 2018 11:55:12 +1000 Subject: src/lundump.js: Fix reading empty string constants Closes https://github.com/fengari-lua/fengari-interop/issues/42 --- test/load.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/load.test.js b/test/load.test.js index 3c03eec..d778155 100644 --- a/test/load.test.js +++ b/test/load.test.js @@ -43,6 +43,24 @@ test('load', () => { }); +test('undump empty string', () => { + let L = lauxlib.luaL_newstate(); + if (!L) throw Error("failed to create lua state"); + + let luaCode = ` + assert(load(string.dump(function() + local str = "" + return #str -- something that inspects the string + end)))() + `; + { + lualib.luaL_openlibs(L); + expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK); + lua.lua_call(L, 0, 0); + } +}); + + test('luaL_loadbuffer', () => { let L = lauxlib.luaL_newstate(); if (!L) throw Error("failed to create lua state"); -- cgit v1.2.3-70-g09d2