aboutsummaryrefslogtreecommitdiff
path: root/tests/test-suite/ltests.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-suite/ltests.js')
-rw-r--r--tests/test-suite/ltests.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/test-suite/ltests.js b/tests/test-suite/ltests.js
index 225e8f7..b6ffc4f 100644
--- a/tests/test-suite/ltests.js
+++ b/tests/test-suite/ltests.js
@@ -492,12 +492,22 @@ const sethook = function(L) {
return 0;
};
+const Cfunc = function(L) {
+ return runJS(L, L, { script: lua.lua_tostring(L, lua.lua_upvalueindex(1)), offset: 0 });
+};
+
const Cfunck = function(L, status, ctx) {
pushcode(L, status);
- lua.lua_setglobal(L, "status");
+ lua.lua_setglobal(L, lua.to_luastring("status", true));
lua.lua_pushinteger(L, ctx);
- lua.lua_setglobal(L, "ctx");
- return runJS(L, L, lua.lua_tostring(L, ctx));
+ lua.lua_setglobal(L, lua.to_luastring("ctx", true));
+ return runJS(L, L, { script: lua.lua_tostring(L, ctx), offset: 0 });
+};
+
+const makeCfunc = function(L) {
+ lauxlib.luaL_checkstring(L, 1);
+ lua.lua_pushcclosure(L, Cfunc, lua.lua_gettop(L));
+ return 1;
};
const coresume = function(L) {
@@ -520,6 +530,7 @@ const tests_funcs = {
"closestate": closestate,
"doremote": doremote,
"loadlib": loadlib,
+ "makeCfunc": makeCfunc,
"newstate": newstate,
"newuserdata": newuserdata,
"resume": coresume,