From 58fcb1d7f55424de904fd6ae53954b46d82aae8c Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Tue, 11 Apr 2017 13:58:15 +0200 Subject: debug.upvalueid --- tests/ldblib.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests') diff --git a/tests/ldblib.js b/tests/ldblib.js index 579912d..475c031 100644 --- a/tests/ldblib.js +++ b/tests/ldblib.js @@ -53,3 +53,39 @@ test('debug.getlocal', function (t) { ); }); + +test('debug.upvalueid', function (t) { + let luaCode = ` + local upvalue = "upvalue" + + local l = function() + return upvalue + end + + return debug.upvalueid(l, 1) + `, L; + + t.plan(3); + + 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.ok( + lapi.lua_touserdata(L, -1), + "Correct element(s) on the stack" + ); + +}); -- cgit v1.2.3-70-g09d2