aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-04-14 11:48:23 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-04-14 11:55:09 +0200
commit3d667b50989e31d18af0c235e28b68055adf62ff (patch)
tree4dbc97a2f0606334e5a8848767e295c3282a2662 /tests
parentd8b080f555dbb9e90dd6d4908b6263910f80528f (diff)
downloadfengari-3d667b50989e31d18af0c235e28b68055adf62ff.tar.gz
fengari-3d667b50989e31d18af0c235e28b68055adf62ff.tar.bz2
fengari-3d667b50989e31d18af0c235e28b68055adf62ff.zip
debug.gethook
Diffstat (limited to 'tests')
-rw-r--r--tests/ldblib.js56
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"