summaryrefslogtreecommitdiff
path: root/tests/ldblib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-04-14 08:18:27 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-04-14 08:18:27 +0200
commitfd613ef1da5e3eeb10d13351ccf217e33b30b1dd (patch)
tree6e6621056f7fb61c68450c7e12e751857cb54d05 /tests/ldblib.js
parentb711f32eee2e0c696cb0e621f54e38c398c7090a (diff)
downloadfengari-fd613ef1da5e3eeb10d13351ccf217e33b30b1dd.tar.gz
fengari-fd613ef1da5e3eeb10d13351ccf217e33b30b1dd.tar.bz2
fengari-fd613ef1da5e3eeb10d13351ccf217e33b30b1dd.zip
debug.upvaluejoin
Diffstat (limited to 'tests/ldblib.js')
-rw-r--r--tests/ldblib.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/ldblib.js b/tests/ldblib.js
index 30a3eb6..7dd35c3 100644
--- a/tests/ldblib.js
+++ b/tests/ldblib.js
@@ -157,6 +157,51 @@ test('debug.upvalueid', function (t) {
});
+test('debug.upvaluejoin', function (t) {
+ let luaCode = `
+ local upvalue1 = "upvalue1"
+ local upvalue2 = "upvalue2"
+
+ local l1 = function()
+ return upvalue1
+ end
+
+ local l2 = function()
+ return upvalue2
+ end
+
+ debug.upvaluejoin(l1, 1, l2, 1)
+
+ return l1()
+ `, 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),
+ "upvalue2",
+ "Correct element(s) on the stack"
+ );
+
+});
+
+
test('debug.traceback (with a global)', function (t) {
let luaCode = `
local trace