summaryrefslogtreecommitdiff
path: root/tests/manual-tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual-tests')
-rw-r--r--tests/manual-tests/debug-cli.js3
-rwxr-xr-xtests/manual-tests/lua-cli.js61
2 files changed, 31 insertions, 33 deletions
diff --git a/tests/manual-tests/debug-cli.js b/tests/manual-tests/debug-cli.js
index 18dee7f..e6e5198 100644
--- a/tests/manual-tests/debug-cli.js
+++ b/tests/manual-tests/debug-cli.js
@@ -1,6 +1,5 @@
"use strict";
-const lapi = require("../../src/lapi.js");
const lauxlib = require("../../src/lauxlib.js");
const lua = require('../../src/lua.js');
const linit = require('../../src/linit.js');
@@ -16,4 +15,4 @@ linit.luaL_openlibs(L);
lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
-lapi.lua_call(L, 0, -1);
+lua.lua_call(L, 0, -1);
diff --git a/tests/manual-tests/lua-cli.js b/tests/manual-tests/lua-cli.js
index 008f39a..468395f 100755
--- a/tests/manual-tests/lua-cli.js
+++ b/tests/manual-tests/lua-cli.js
@@ -2,7 +2,6 @@
"use strict";
const lua = require('../../src/lua.js');
-const lapi = require('../../src/lapi.js');
const lauxlib = require('../../src/lauxlib.js');
const linit = require('../../src/linit.js');
const fs = require('fs');
@@ -14,14 +13,14 @@ const _PROMPT2 = lua.to_luastring("_PROMPT2");
const report = function(L, status) {
if (status !== lua.LUA_OK) {
- lauxlib.lua_writestringerror(`${lapi.lua_tojsstring(L, -1)}\n`);
- lapi.lua_pop(L, 1);
+ lauxlib.lua_writestringerror(`${lua.lua_tojsstring(L, -1)}\n`);
+ lua.lua_pop(L, 1);
}
return status;
};
const docall = function(L, narg, nres) {
- let status = lapi.lua_pcall(L, narg, nres, 0);
+ let status = lua.lua_pcall(L, narg, nres, 0);
return status;
};
@@ -42,11 +41,11 @@ const dostring = function(L, s, name) {
};
const dolibrary = function(L, name) {
- lapi.lua_getglobal(L, lua.to_luastring("require"));
- lapi.lua_pushliteral(L, name);
+ lua.lua_getglobal(L, lua.to_luastring("require"));
+ lua.lua_pushliteral(L, name);
let status = docall(L, 1, 1); /* call 'require(name)' */
if (status === lua.LUA_OK)
- lapi.lua_setglobal(L, lua.to_luastring(name)); /* global[name] = require return */
+ lua.lua_setglobal(L, lua.to_luastring(name)); /* global[name] = require return */
return report(L, status);
};
@@ -137,20 +136,20 @@ if (has_v)
if (has_E) {
/* signal for libraries to ignore env. vars. */
- lapi.lua_pushboolean(L, 1);
- lapi.lua_setfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring("LUA_NOENV"));
+ lua.lua_pushboolean(L, 1);
+ lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring("LUA_NOENV"));
}
/* open standard libraries */
linit.luaL_openlibs(L);
/* create table 'arg' */
-lapi.lua_createtable(L, process.argv.length - (script + 1), script + 1);
+lua.lua_createtable(L, process.argv.length - (script + 1), script + 1);
for (let i = 0; i < process.argv.length; i++) {
- lapi.lua_pushliteral(L, process.argv[i]);
- lapi.lua_seti(L, -2, i - script); /* TODO: rawseti */
+ lua.lua_pushliteral(L, process.argv[i]);
+ lua.lua_seti(L, -2, i - script); /* TODO: rawseti */
}
-lapi.lua_setglobal(L, lua.to_luastring("arg"));
+lua.lua_setglobal(L, lua.to_luastring("arg"));
if (!has_E) {
/* run LUA_INIT */
@@ -193,14 +192,14 @@ for (let i = 1; i < script; i++) {
}
const pushargs = function(L) {
- if (lapi.lua_getglobal(L, lua.to_luastring("arg")) !== lua.LUA_TTABLE)
+ if (lua.lua_getglobal(L, lua.to_luastring("arg")) !== lua.LUA_TTABLE)
lauxlib.luaL_error(L, lua.to_luastring("'arg' is not a table"));
let n = lauxlib.luaL_len(L, -1);
lauxlib.luaL_checkstack(L, n+3, lua.to_luastring("too many arguments to script"));
let i;
for (i=1; i<=n; i++)
- lapi.lua_rawgeti(L, -i, i);
- lapi.lua_remove(L, -i);
+ lua.lua_rawgeti(L, -i, i);
+ lua.lua_remove(L, -i);
return n;
};
@@ -221,11 +220,11 @@ const handle_script = function(L, argv) {
const doREPL = function(L) {
for (;;) {
- lapi.lua_getglobal(L, _PROMPT);
+ lua.lua_getglobal(L, _PROMPT);
let input = readlineSync.prompt({
- prompt: lapi.lua_tojsstring(L, -1) || '> '
+ prompt: lua.lua_tojsstring(L, -1) || '> '
});
- lapi.lua_pop(L, 1);
+ lua.lua_pop(L, 1);
if (input.length === 0)
continue;
@@ -236,20 +235,20 @@ const doREPL = function(L) {
status = lauxlib.luaL_loadbuffer(L, buffer, buffer.length, stdin);
}
if (status !== lua.LUA_OK) {
- lapi.lua_pop(L, 1);
+ lua.lua_pop(L, 1);
let buffer = lua.to_luastring(input);
if (lauxlib.luaL_loadbuffer(L, buffer, buffer.length, stdin) === lua.LUA_OK) {
status = lua.LUA_OK;
}
}
- while (status === lua.LUA_ERRSYNTAX && lapi.lua_tojsstring(L, -1).endsWith("<eof>")) {
+ while (status === lua.LUA_ERRSYNTAX && lua.lua_tojsstring(L, -1).endsWith("<eof>")) {
/* continuation */
- lapi.lua_pop(L, 1);
- lapi.lua_getglobal(L, _PROMPT2);
+ lua.lua_pop(L, 1);
+ lua.lua_getglobal(L, _PROMPT2);
input += "\n" + readlineSync.prompt({
- prompt: lapi.lua_tojsstring(L, -1) || '>> '
+ prompt: lua.lua_tojsstring(L, -1) || '>> '
});
- lapi.lua_pop(L, 1);
+ lua.lua_pop(L, 1);
let buffer = lua.to_luastring(input);
status = lauxlib.luaL_loadbuffer(L, buffer, buffer.length, stdin);
}
@@ -257,18 +256,18 @@ const doREPL = function(L) {
status = docall(L, 0, lua.LUA_MULTRET);
}
if (status === lua.LUA_OK) {
- let n = lapi.lua_gettop(L);
+ let n = lua.lua_gettop(L);
if (n > 0) { /* any result to be printed? */
- lapi.lua_getglobal(L, lua.to_luastring("print"));
- lapi.lua_insert(L, 1);
- if (lapi.lua_pcall(L, n, 0, 0) != lua.LUA_OK) {
- lauxlib.lua_writestringerror(`error calling 'print' (${lapi.lua_tojsstring(L, -1)})\n`);
+ lua.lua_getglobal(L, lua.to_luastring("print"));
+ lua.lua_insert(L, 1);
+ if (lua.lua_pcall(L, n, 0, 0) != lua.LUA_OK) {
+ lauxlib.lua_writestringerror(`error calling 'print' (${lua.lua_tojsstring(L, -1)})\n`);
}
}
} else {
report(L, status);
}
- lapi.lua_settop(L, 0); /* remove eventual returns */
+ lua.lua_settop(L, 0); /* remove eventual returns */
}
};