diff options
Diffstat (limited to 'tests/lapi.js')
-rw-r--r-- | tests/lapi.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/lapi.js b/tests/lapi.js index ff76920..419e5c4 100644 --- a/tests/lapi.js +++ b/tests/lapi.js @@ -408,4 +408,34 @@ test('lua_load and lua_call it', function (t) { "JS > Lua > JS \o/", "Correct element(s) on the stack" ); +}); + + +test('lua script reads js upvalues', function (t) { + let luaCode = ` + return js .. " world" + `, L; + + t.plan(2); + + t.doesNotThrow(function () { + + let bc = toByteCode(luaCode).dataView; + + L = lauxlib.luaL_newstate(); + + lapi.lua_load(L, bc, "test-lua_load") + + lapi.lua_pushstring(L, "hello"); + lapi.lua_setglobal(L, "js"); + + lapi.lua_call(L, 0, 1); + + }, "JS 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 |