summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-11 09:38:36 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-05-11 09:38:36 +0200
commit27de87bca51c4353a2a726afc20a38b36442e31e (patch)
tree32fea18f9a8183cbc0a00a9ce6fa3e5745b547e5
parent762c1e3594a8c2eac03dd2a1a005d8712ce9635f (diff)
downloadfengari-27de87bca51c4353a2a726afc20a38b36442e31e.tar.gz
fengari-27de87bca51c4353a2a726afc20a38b36442e31e.tar.bz2
fengari-27de87bca51c4353a2a726afc20a38b36442e31e.zip
ltests.js
-rw-r--r--tests/test-suite/ltests.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test-suite/ltests.js b/tests/test-suite/ltests.js
new file mode 100644
index 0000000..b4b575b
--- /dev/null
+++ b/tests/test-suite/ltests.js
@@ -0,0 +1,34 @@
+"use strict";
+
+global.WEB = false;
+
+const lua = require('../../src/lua.js');
+const lauxlib = require('../../src/lauxlib.js');
+
+
+const tpanic = function(L) {
+ console.error(`PANIC: unprotected error in call to Lua API (${lua.lua_tojsstring(L, -1)})\n`);
+ return process.exit(1); /* do not return to Lua */
+};
+
+const newuserdata = function(L) {
+ lua.lua_newuserdata(L, lauxlib.luaL_checkinteger(L, 1));
+ return 1;
+};
+
+const tests_funcs = {
+ "newuserdata": newuserdata
+};
+
+const luaB_opentests = function(L) {
+ lua.lua_atpanic(L, tpanic);
+ lauxlib.luaL_newlib(L, tests_funcs);
+ return 1;
+};
+
+const luaopen_tests = function(L) {
+ lauxlib.luaL_requiref(L, lua.to_luastring("T"), luaB_opentests, 1);
+ lua.lua_pop(L, 1); /* remove lib */
+};
+
+module.exports.luaopen_tests = luaopen_tests;