diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-04-14 11:48:23 +0200 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-04-14 11:55:09 +0200 |
commit | 3d667b50989e31d18af0c235e28b68055adf62ff (patch) | |
tree | 4dbc97a2f0606334e5a8848767e295c3282a2662 /tests/ldblib.js | |
parent | d8b080f555dbb9e90dd6d4908b6263910f80528f (diff) | |
download | fengari-3d667b50989e31d18af0c235e28b68055adf62ff.tar.gz fengari-3d667b50989e31d18af0c235e28b68055adf62ff.tar.bz2 fengari-3d667b50989e31d18af0c235e28b68055adf62ff.zip |
debug.gethook
Diffstat (limited to 'tests/ldblib.js')
-rw-r--r-- | tests/ldblib.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/ldblib.js b/tests/ldblib.js index 8c3ad7f..6587228 100644 --- a/tests/ldblib.js +++ b/tests/ldblib.js @@ -51,6 +51,62 @@ test('debug.sethook', function (t) { }); +test('debug.gethook', function (t) { + let luaCode = ` + local result = "" + + debug.sethook(function (event) + result = result .. event .. " " + end, "crl", 1) + + local l = function() end + + l() + l() + l() + + return debug.gethook() + `, L; + + t.plan(5); + + 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.deepEqual( + lapi.lua_typename(L, lapi.lua_type(L, -3)), + lua.to_luastring("function"), + "Correct element(s) on the stack" + ); + + t.deepEqual( + lapi.lua_tojsstring(L, -2), + "crl", + "Correct element(s) on the stack" + ); + + t.deepEqual( + lapi.lua_tointeger(L, -1), + 1, + "Correct element(s) on the stack" + ); + +}); + + test('debug.getlocal', function (t) { let luaCode = ` local alocal = "alocal" |