aboutsummaryrefslogtreecommitdiff
path: root/tests/test-suite/ltests.js
blob: b4b575b0ed66f191524e21589440f0f01e7db185 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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;