diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-17 12:25:28 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-17 13:25:56 +0100 |
commit | cdf8cf1806ca793c47095b69382b2dd733899af7 (patch) | |
tree | d101b270e2d07488efa1b3c33f9bf70f70c5ed5d /tests | |
parent | a8e82fc01f2558550289f76f55c917039296ec11 (diff) | |
download | fengari-cdf8cf1806ca793c47095b69382b2dd733899af7.tar.gz fengari-cdf8cf1806ca793c47095b69382b2dd733899af7.tar.bz2 fengari-cdf8cf1806ca793c47095b69382b2dd733899af7.zip |
lua can read globals set by js
Diffstat (limited to 'tests')
-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 |