diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-04-14 07:50:36 +0200 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-04-14 07:56:46 +0200 |
commit | b711f32eee2e0c696cb0e621f54e38c398c7090a (patch) | |
tree | 5c99b4510570789dd9d72cd4c0de357edeaaae23 /tests | |
parent | 127ca3042ce2be23bd0b07570154c81ac3fda432 (diff) | |
download | fengari-b711f32eee2e0c696cb0e621f54e38c398c7090a.tar.gz fengari-b711f32eee2e0c696cb0e621f54e38c398c7090a.tar.bz2 fengari-b711f32eee2e0c696cb0e621f54e38c398c7090a.zip |
debug.getuservalue, debug.setuservalue, debug.setlocal
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ldblib.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/ldblib.js b/tests/ldblib.js index a770c76..30a3eb6 100644 --- a/tests/ldblib.js +++ b/tests/ldblib.js @@ -54,6 +54,72 @@ test('debug.getlocal', function (t) { }); +test('debug.setlocal', function (t) { + let luaCode = ` + local alocal = "alocal" + local another = "another" + + local l = function() + local infunction = "infunction" + local anotherin = "anotherin" + + debug.setlocal(2, 1, 1) + debug.setlocal(2, 2, 2) + debug.setlocal(1, 1, 3) + debug.setlocal(1, 2, 4) + + return infunction, anotherin + end + + local a, b = l() + + return alocal, another, a, b + `, L; + + t.plan(6); + + t.doesNotThrow(function () { + + L = lauxlib.luaL_newstate(); + + linit.luaL_openlibs(L); + + lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + + }, "Lua program loaded without error"); + + t.doesNotThrow(function () { + + lapi.lua_call(L, 0, -1); + + }, "Lua program ran without error"); + + t.strictEqual( + lapi.lua_tointeger(L, -4), + 1, + "Correct element(s) on the stack" + ); + + t.strictEqual( + lapi.lua_tointeger(L, -3), + 2, + "Correct element(s) on the stack" + ); + + t.strictEqual( + lapi.lua_tointeger(L, -2), + 3, + "Correct element(s) on the stack" + ); + + t.strictEqual( + lapi.lua_tointeger(L, -1), + 4, + "Correct element(s) on the stack" + ); + +}); + test('debug.upvalueid', function (t) { let luaCode = ` local upvalue = "upvalue" |