summaryrefslogtreecommitdiff
path: root/tests/test-suite/ltests.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-25 15:45:37 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-05-25 15:49:11 +0200
commit99a08b82556f29d3b12e80f5990aac6fc76a5fe3 (patch)
tree78c8804b175af61d8654bf1b9a2f195981f20043 /tests/test-suite/ltests.js
parent106a349f6a33c1ccbe2e0aa5dcf9b7a1b3771eac (diff)
downloadfengari-99a08b82556f29d3b12e80f5990aac6fc76a5fe3.tar.gz
fengari-99a08b82556f29d3b12e80f5990aac6fc76a5fe3.tar.bz2
fengari-99a08b82556f29d3b12e80f5990aac6fc76a5fe3.zip
ltests.js: makeCfunc
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,