aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-04-14 08:59:00 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-04-14 11:06:19 +0200
commit43c97cbc2904d2bac87c61515bbc16c38a091548 (patch)
tree31dee0450518dc6a6aebd913e450bcd8ed4131b2 /tests
parentfd613ef1da5e3eeb10d13351ccf217e33b30b1dd (diff)
downloadfengari-43c97cbc2904d2bac87c61515bbc16c38a091548.tar.gz
fengari-43c97cbc2904d2bac87c61515bbc16c38a091548.tar.bz2
fengari-43c97cbc2904d2bac87c61515bbc16c38a091548.zip
hooks
Diffstat (limited to 'tests')
-rw-r--r--tests/ldblib.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/ldblib.js b/tests/ldblib.js
index 7dd35c3..8d00952 100644
--- a/tests/ldblib.js
+++ b/tests/ldblib.js
@@ -7,6 +7,50 @@ const lauxlib = require("../src/lauxlib.js");
const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
+test('debug.sethook', function (t) {
+ let luaCode = `
+ result = ""
+
+ debug.sethook(function (event)
+ result = result .. event .. " "
+ end, "crl", 1)
+
+ local l = function() end
+
+ l()
+ l()
+ l()
+
+ return result
+ `, 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.strictEqual(
+ lapi.lua_tojsstring(L, -1),
+ "return count line count line count line count return count line count line count return count line count line count return count line count line ",
+ "Correct element(s) on the stack"
+ );
+
+});
+
+
test('debug.getlocal', function (t) {
let luaCode = `
local alocal = "alocal"