summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lapi.js109
-rw-r--r--tests/lbaselib.js133
-rw-r--r--tests/lcorolib.js37
-rw-r--r--tests/ldblib.js61
-rw-r--r--tests/ldebug.js49
-rw-r--r--tests/lexparse.js214
-rw-r--r--tests/lmathlib.js109
-rw-r--r--tests/load.js25
-rw-r--r--tests/loslib.js5
-rw-r--r--tests/lstrlib.js147
-rw-r--r--tests/ltablib.js53
-rw-r--r--tests/ltm.js105
-rw-r--r--tests/lutf8lib.js25
-rw-r--r--tests/lvm.js100
-rw-r--r--tests/manual-tests/debug-cli.js3
-rwxr-xr-xtests/manual-tests/lua-cli.js61
16 files changed, 611 insertions, 625 deletions
diff --git a/tests/lapi.js b/tests/lapi.js
index 68e8f7e..1e3624f 100644
--- a/tests/lapi.js
+++ b/tests/lapi.js
@@ -9,7 +9,6 @@ const toByteCode = tests.toByteCode;
const VM = require("../src/lvm.js");
const ldo = require("../src/ldo.js");
-const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
@@ -23,7 +22,7 @@ test('luaL_newstate, lua_pushnil, luaL_typename', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushnil(L);
+ lua.lua_pushnil(L);
}, "JS Lua program ran without error");
@@ -44,7 +43,7 @@ test('lua_pushnumber', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushnumber(L, 10.5);
+ lua.lua_pushnumber(L, 10.5);
}, "JS Lua program ran without error");
@@ -55,7 +54,7 @@ test('lua_pushnumber', function (t) {
);
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
10.5,
"top is correct"
);
@@ -71,7 +70,7 @@ test('lua_pushinteger', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushinteger(L, 10);
+ lua.lua_pushinteger(L, 10);
}, "JS Lua program ran without error");
@@ -82,7 +81,7 @@ test('lua_pushinteger', function (t) {
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
10,
"top is correct"
);
@@ -98,7 +97,7 @@ test('lua_pushliteral', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushliteral(L, "hello");
+ lua.lua_pushliteral(L, "hello");
}, "JS Lua program ran without error");
@@ -109,7 +108,7 @@ test('lua_pushliteral', function (t) {
);
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"top is correct"
);
@@ -125,7 +124,7 @@ test('lua_pushboolean', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushboolean(L, true);
+ lua.lua_pushboolean(L, true);
}, "JS Lua program ran without error");
@@ -136,7 +135,7 @@ test('lua_pushboolean', function (t) {
);
t.strictEqual(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
true,
"top is correct"
);
@@ -152,9 +151,9 @@ test('lua_pushvalue', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushliteral(L, "hello");
+ lua.lua_pushliteral(L, "hello");
- lapi.lua_pushvalue(L, -1);
+ lua.lua_pushvalue(L, -1);
}, "JS Lua program ran without error");
@@ -171,13 +170,13 @@ test('lua_pushvalue', function (t) {
);
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"hello",
"Correct element(s) on the stack"
);
@@ -197,8 +196,8 @@ test('lua_pushjsclosure', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushliteral(L, "a value associated to the C closure");
- lapi.lua_pushjsclosure(L, fn, 1);
+ lua.lua_pushliteral(L, "a value associated to the C closure");
+ lua.lua_pushjsclosure(L, fn, 1);
}, "JS Lua program ran without error");
@@ -223,7 +222,7 @@ test('lua_pushjsfunction', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushjsfunction(L, fn);
+ lua.lua_pushjsfunction(L, fn);
}, "JS Lua program ran without error");
@@ -243,20 +242,20 @@ test('lua_call (calling a light JS function)', function (t) {
t.doesNotThrow(function () {
let fn = function(L) {
- lapi.lua_pushliteral(L, "hello");
+ lua.lua_pushliteral(L, "hello");
return 1;
};
L = lauxlib.luaL_newstate();
- lapi.lua_pushjsfunction(L, fn);
+ lua.lua_pushjsfunction(L, fn);
- lapi.lua_call(L, 0, 1);
+ lua.lua_call(L, 0, 1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"top is correct"
);
@@ -271,21 +270,21 @@ test('lua_call (calling a JS closure)', function (t) {
t.doesNotThrow(function () {
let fn = function(L) {
- lapi.lua_pushstring(L, lapi.lua_tostring(L, lua.lua_upvalueindex(1)));
+ lua.lua_pushstring(L, lua.lua_tostring(L, lua.lua_upvalueindex(1)));
return 1;
};
L = lauxlib.luaL_newstate();
- lapi.lua_pushliteral(L, "upvalue hello !");
- lapi.lua_pushjsclosure(L, fn, 1);
+ lua.lua_pushliteral(L, "upvalue hello !");
+ lua.lua_pushjsclosure(L, fn, 1);
- lapi.lua_call(L, 0, 1);
+ lua.lua_call(L, 0, 1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"upvalue hello !",
"top is correct"
);
@@ -300,20 +299,20 @@ test('lua_pcall (calling a light JS function)', function (t) {
t.doesNotThrow(function () {
let fn = function(L) {
- lapi.lua_pushliteral(L, "hello");
+ lua.lua_pushliteral(L, "hello");
return 1;
};
L = lauxlib.luaL_newstate();
- lapi.lua_pushjsfunction(L, fn);
+ lua.lua_pushjsfunction(L, fn);
- lapi.lua_pcall(L, 0, 1, 0);
+ lua.lua_pcall(L, 0, 1, 0);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"top is correct"
);
@@ -333,9 +332,9 @@ test('lua_pcall that breaks', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushjsfunction(L, fn);
+ lua.lua_pushjsfunction(L, fn);
- lapi.lua_pcall(L, 0, 1, 0);
+ lua.lua_pcall(L, 0, 1, 0);
}, "JS Lua program ran without error");
@@ -352,15 +351,15 @@ test('lua_pop', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushliteral(L, "hello");
- lapi.lua_pushliteral(L, "world");
+ lua.lua_pushliteral(L, "hello");
+ lua.lua_pushliteral(L, "world");
- lapi.lua_pop(L, 1);
+ lua.lua_pop(L, 1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Correct element(s) on the stack"
);
@@ -381,14 +380,14 @@ test('lua_load and lua_call it', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_load(L, null, bc, lua.to_luastring("test-lua_load"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-lua_load"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, 1);
+ lua.lua_call(L, 0, 1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"JS > Lua > JS \o/",
"Correct element(s) on the stack"
);
@@ -408,17 +407,17 @@ test('lua script reads js upvalues', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_load(L, null, bc, lua.to_luastring("test-lua_load"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-lua_load"), lua.to_luastring("binary"));
- lapi.lua_pushliteral(L, "hello");
- lapi.lua_setglobal(L, lua.to_luastring("js"));
+ lua.lua_pushliteral(L, "hello");
+ lua.lua_setglobal(L, lua.to_luastring("js"));
- lapi.lua_call(L, 0, 1);
+ lua.lua_call(L, 0, 1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -433,12 +432,12 @@ test('lua_createtable', function (t) {
t.doesNotThrow(function () {
L = lauxlib.luaL_newstate();
- lapi.lua_createtable(L, 3, 3);
+ lua.lua_createtable(L, 3, 3);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_istable(L, -1),
+ lua.lua_istable(L, -1),
"Correct element(s) on the stack"
);
});
@@ -452,12 +451,12 @@ test('lua_newtable', function (t) {
t.doesNotThrow(function () {
L = lauxlib.luaL_newstate();
- lapi.lua_newtable(L);
+ lua.lua_newtable(L);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_istable(L, -1),
+ lua.lua_istable(L, -1),
"Correct element(s) on the stack"
);
});
@@ -471,20 +470,20 @@ test('lua_settable, lua_gettable', function (t) {
t.doesNotThrow(function () {
L = lauxlib.luaL_newstate();
- lapi.lua_newtable(L);
+ lua.lua_newtable(L);
- lapi.lua_pushliteral(L, "key");
- lapi.lua_pushliteral(L, "value");
+ lua.lua_pushliteral(L, "key");
+ lua.lua_pushliteral(L, "value");
- lapi.lua_settable(L, -3);
+ lua.lua_settable(L, -3);
- lapi.lua_pushliteral(L, "key");
- lapi.lua_gettable(L, -2);
+ lua.lua_pushliteral(L, "key");
+ lua.lua_gettable(L, -2);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"value",
"Correct element(s) on the stack"
);
diff --git a/tests/lbaselib.js b/tests/lbaselib.js
index 646f900..abde72c 100644
--- a/tests/lbaselib.js
+++ b/tests/lbaselib.js
@@ -9,7 +9,6 @@ const toByteCode = tests.toByteCode;
const VM = require("../src/lvm.js");
const ldo = require("../src/ldo.js");
-const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
@@ -29,9 +28,9 @@ test('print', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-print"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-print"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
});
@@ -63,20 +62,20 @@ test('setmetatable, getmetatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-setmetatable-getmetatable"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-setmetatable-getmetatable"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"hello",
"Correct element(s) on the stack"
);
t.ok(
- lapi.lua_istable(L, -1),
+ lua.lua_istable(L, -1),
"Correct element(s) on the stack"
);
});
@@ -108,19 +107,19 @@ test('rawequal', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-rawequal"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-rawequal"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.notOk(
- lapi.lua_toboolean(L, -2),
+ lua.lua_toboolean(L, -2),
"Correct element(s) on the stack"
);
t.ok(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
"Correct element(s) on the stack"
);
});
@@ -154,32 +153,32 @@ test('rawset, rawget', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-rawequal"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-rawequal"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -4),
+ lua.lua_tojsstring(L, -4),
"hello",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -3),
+ lua.lua_tojsstring(L, -3),
"hello",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"bye",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"bye",
"Correct element(s) on the stack"
);
@@ -201,38 +200,38 @@ test('type', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-type"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-type"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -5),
+ lua.lua_tojsstring(L, -5),
"number",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -4),
+ lua.lua_tojsstring(L, -4),
"boolean",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -3),
+ lua.lua_tojsstring(L, -3),
"string",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"table",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"nil",
"Correct element(s) on the stack"
);
@@ -254,9 +253,9 @@ test('error', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-error"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-error"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
});
@@ -277,14 +276,14 @@ test('error, protected', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-error"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-error"), lua.to_luastring("binary"));
- lapi.lua_pcall(L, 0, -1, 0);
+ lua.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tojsstring(L, -1).endsWith("you fucked up"),
+ lua.lua_tojsstring(L, -1).endsWith("you fucked up"),
"Error is on the stack"
);
});
@@ -309,14 +308,14 @@ test('pcall', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-pcall"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-pcall"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tojsstring(L, -1).endsWith("you fucked up"),
+ lua.lua_tojsstring(L, -1).endsWith("you fucked up"),
"Error is on the stack"
);
});
@@ -345,21 +344,21 @@ test('xpcall', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-pcall"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-pcall"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
- console.log(lapi.lua_tojsstring(L, -1));
+ console.log(lua.lua_tojsstring(L, -1));
t.ok(
- lapi.lua_tojsstring(L, -1).startsWith("Something's wrong:"),
+ lua.lua_tojsstring(L, -1).startsWith("Something's wrong:"),
"msgh was called and modified the error"
);
t.ok(
- lapi.lua_tojsstring(L, -1).endsWith("you fucked up"),
+ lua.lua_tojsstring(L, -1).endsWith("you fucked up"),
"msgh was called and modified the error"
);
});
@@ -387,14 +386,14 @@ test('ipairs', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-ipairs"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-ipairs"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
15,
"Correct element(s) on the stack"
);
@@ -416,26 +415,26 @@ test('select', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-select"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-select"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.deepEqual(
- [...lapi.lua_topointer(L, -3).entries()].map(e => e[1].value),
+ [...lua.lua_topointer(L, -3).entries()].map(e => e[1].value),
[3],
"Correct element(s) on the stack"
);
t.deepEqual(
- [...lapi.lua_topointer(L, -2).entries()].map(e => e[1].value).sort(),
+ [...lua.lua_topointer(L, -2).entries()].map(e => e[1].value).sort(),
[2, 3],
"Correct element(s) on the stack"
);
t.deepEqual(
- [...lapi.lua_topointer(L, -1).entries()].map(e => e[1].value).sort(),
+ [...lua.lua_topointer(L, -1).entries()].map(e => e[1].value).sort(),
[2, 3],
"Correct element(s) on the stack"
);
@@ -457,32 +456,32 @@ test('tonumber', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-tonumber"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-tonumber"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -4),
+ lua.lua_tonumber(L, -4),
123,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -3),
+ lua.lua_tonumber(L, -3),
12.3,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -2),
+ lua.lua_tonumber(L, -2),
395,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
2,
"Correct element(s) on the stack"
);
@@ -504,14 +503,14 @@ test('assert', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-assert"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-assert"), lua.to_luastring("binary"));
- lapi.lua_pcall(L, 0, -1, 0);
+ lua.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tojsstring(L, -1).endsWith("this doesn't makes sense"),
+ lua.lua_tojsstring(L, -1).endsWith("this doesn't makes sense"),
"Error is on the stack"
);
});
@@ -532,20 +531,20 @@ test('rawlen', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-rawlen"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-rawlen"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -2),
+ lua.lua_tonumber(L, -2),
3,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
5,
"Correct element(s) on the stack"
);
@@ -579,14 +578,14 @@ test('next', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-next"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-next"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
10,
"Correct element(s) on the stack"
);
@@ -620,14 +619,14 @@ test('pairs', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-pairs"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-pairs"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
10,
"Correct element(s) on the stack"
);
@@ -670,14 +669,14 @@ test('pairs with __pairs', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-pairs"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-pairs"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
26,
"Correct element(s) on the stack"
);
diff --git a/tests/lcorolib.js b/tests/lcorolib.js
index 3a778d4..29f9b34 100644
--- a/tests/lcorolib.js
+++ b/tests/lcorolib.js
@@ -9,7 +9,6 @@ const toByteCode = tests.toByteCode;
const VM = require("../src/lvm.js");
const ldo = require("../src/ldo.js");
-const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
@@ -39,14 +38,14 @@ test('coroutine.create, coroutine.yield, coroutine.resume', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-coroutine"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-coroutine"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
625,
"Correct element(s) on the stack"
);
@@ -82,20 +81,20 @@ test('coroutine.status', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-coroutine.status"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-coroutine.status"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"suspended",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"dead",
"Correct element(s) on the stack"
);
@@ -123,19 +122,19 @@ test('coroutine.isyieldable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-coroutine.isyieldable"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-coroutine.isyieldable"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_toboolean(L, -2),
+ lua.lua_toboolean(L, -2),
"Correct element(s) on the stack"
);
t.notOk(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
"Correct element(s) on the stack"
);
});
@@ -164,19 +163,19 @@ test('coroutine.running', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-coroutine.running"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-coroutine.running"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tothread(L, -2) instanceof lstate.lua_State,
+ lua.lua_tothread(L, -2) instanceof lstate.lua_State,
"Correct element(s) on the stack"
);
t.notOk(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
"Correct element(s) on the stack"
);
});
@@ -205,14 +204,14 @@ test('coroutine.wrap', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-coroutine.wrap"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-coroutine.wrap"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
625,
"Correct element(s) on the stack"
);
diff --git a/tests/ldblib.js b/tests/ldblib.js
index 8913642..06ad4b3 100644
--- a/tests/ldblib.js
+++ b/tests/ldblib.js
@@ -2,7 +2,6 @@
const test = require('tape');
-const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
@@ -38,12 +37,12 @@ test('debug.sethook', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"return count line count line count line count return count line count line count return count line count line count return count line ",
"Correct element(s) on the stack"
);
@@ -82,24 +81,24 @@ test('debug.gethook', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.deepEqual(
- lapi.lua_typename(L, lapi.lua_type(L, -3)),
+ lua.lua_typename(L, lua.lua_type(L, -3)),
lua.to_luastring("function"),
"Correct element(s) on the stack"
);
t.deepEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"crl",
"Correct element(s) on the stack"
);
t.deepEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
1,
"Correct element(s) on the stack"
);
@@ -142,12 +141,12 @@ test('debug.getlocal', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"alocal alocalanother anotherinfunction infunctionanotherin anotherin",
"Correct element(s) on the stack"
);
@@ -190,30 +189,30 @@ test('debug.setlocal', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -4),
+ lua.lua_tointeger(L, -4),
1,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -3),
+ lua.lua_tointeger(L, -3),
2,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -2),
+ lua.lua_tointeger(L, -2),
3,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
4,
"Correct element(s) on the stack"
);
@@ -245,12 +244,12 @@ test('debug.upvalueid', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.ok(
- lapi.lua_touserdata(L, -1),
+ lua.lua_touserdata(L, -1),
"Correct element(s) on the stack"
);
@@ -289,12 +288,12 @@ test('debug.upvaluejoin', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"upvalue2",
"Correct element(s) on the stack"
);
@@ -335,12 +334,12 @@ test('debug.traceback (with a global)', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
`stack traceback:
\t...[string "traceback-test"]9: in function 'rec'
\t...[string "traceback-test"]7: in function 'rec'
@@ -394,12 +393,12 @@ test('debug.traceback (with a upvalue)', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
`stack traceback:
\t...[string "traceback-test"]10: in upvalue 'rec'
\t...[string "traceback-test"]8: in upvalue 'rec'
@@ -448,54 +447,54 @@ test('debug.getinfo', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -8),
+ lua.lua_tojsstring(L, -8),
`[string "getinfo-test"]`,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -7),
+ lua.lua_tointeger(L, -7),
0,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -6),
+ lua.lua_tojsstring(L, -6),
`Lua`,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -5),
+ lua.lua_tointeger(L, -5),
2,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -4),
+ lua.lua_tojsstring(L, -4),
`[string "getinfo-test"]`,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -3),
+ lua.lua_tointeger(L, -3),
1,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
`Lua`,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
0,
"Correct element(s) on the stack"
);
diff --git a/tests/ldebug.js b/tests/ldebug.js
index 0256465..751c9c2 100644
--- a/tests/ldebug.js
+++ b/tests/ldebug.js
@@ -9,7 +9,6 @@ const toByteCode = tests.toByteCode;
const lvm = require("../src/lvm.js");
const ldo = require("../src/ldo.js");
-const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
@@ -30,15 +29,15 @@ test('luaG_typeerror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
- lapi.lua_pcall(L, 0, -1, 0);
+ lua.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tojsstring(L, -1).endsWith("attempt to get length of a boolean value (local 'a')"),
+ lua.lua_tojsstring(L, -1).endsWith("attempt to get length of a boolean value (local 'a')"),
"Correct error was thrown"
);
});
@@ -49,7 +48,7 @@ test('luaG_typeerror', function (t) {
local a = true
return a.yo
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -60,14 +59,14 @@ test('luaG_typeerror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
- lapi.lua_pcall(L, 0, -1, 0);
+ lua.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
+ lua.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
"Correct error was thrown"
);
});
@@ -89,14 +88,14 @@ test('luaG_typeerror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
- lapi.lua_pcall(L, 0, -1, 0);
+ lua.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
+ lua.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
"Correct error was thrown"
);
});
@@ -107,7 +106,7 @@ test('luaG_typeerror', function (t) {
local a = true
a.yo = 1
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -118,14 +117,14 @@ test('luaG_typeerror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
- lapi.lua_pcall(L, 0, -1, 0);
+ lua.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
+ lua.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
"Correct error was thrown"
);
});
@@ -135,7 +134,7 @@ test('luaG_concaterror', function (t) {
let luaCode = `
return {} .. 'hello'
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -146,14 +145,14 @@ test('luaG_concaterror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
- lapi.lua_pcall(L, 0, -1, 0);
+ lua.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tojsstring(L, -1).endsWith("attempt to concatenate a table value"),
+ lua.lua_tojsstring(L, -1).endsWith("attempt to concatenate a table value"),
"Correct error was thrown"
);
});
@@ -174,14 +173,14 @@ test('luaG_opinterror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
- lapi.lua_pcall(L, 0, -1, 0);
+ lua.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tojsstring(L, -1).endsWith("attempt to perform arithmetic on a string value"),
+ lua.lua_tojsstring(L, -1).endsWith("attempt to perform arithmetic on a string value"),
"Correct error was thrown"
);
});
@@ -202,14 +201,14 @@ test('luaG_tointerror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
- lapi.lua_pcall(L, 0, -1, 0);
+ lua.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tojsstring(L, -1).endsWith("number has no integer representation"),
+ lua.lua_tojsstring(L, -1).endsWith("number has no integer representation"),
"Correct error was thrown"
);
});
diff --git a/tests/lexparse.js b/tests/lexparse.js
index 68b6667..ddb2dbf 100644
--- a/tests/lexparse.js
+++ b/tests/lexparse.js
@@ -32,19 +32,19 @@ test('LOADK, RETURN', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -72,19 +72,19 @@ test('MOVE', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -112,14 +112,14 @@ test('Binary op', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
@@ -152,14 +152,14 @@ test('Unary op, LOADBOOL', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
@@ -190,14 +190,14 @@ test('NEWTABLE', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
@@ -232,19 +232,19 @@ test('CALL', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
3,
"Program output is correct"
);
@@ -278,14 +278,14 @@ test('Multiple return', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
@@ -319,19 +319,19 @@ test('TAILCALL', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
3,
"Program output is correct"
);
@@ -360,14 +360,14 @@ test('VARARG', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
@@ -399,19 +399,19 @@ test('LE, JMP', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
true,
"Program output is correct"
);
@@ -438,19 +438,19 @@ test('LT', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
false,
"Program output is correct"
);
@@ -477,19 +477,19 @@ test('EQ', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
true,
"Program output is correct"
);
@@ -517,19 +517,19 @@ test('TESTSET (and)', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -557,19 +557,19 @@ test('TESTSET (or)', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -601,19 +601,19 @@ test('TEST (false)', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"goodbye",
"Program output is correct"
);
@@ -644,19 +644,19 @@ test('FORPREP, FORLOOP (int)', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
55,
"Program output is correct"
);
@@ -687,19 +687,19 @@ test('FORPREP, FORLOOP (float)', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
60.5,
"Program output is correct"
);
@@ -729,25 +729,25 @@ test('SETTABLE, GETTABLE', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_topointer(L, -1).get(1).jsstring(),
+ lua.lua_topointer(L, -1).get(1).jsstring(),
"hello",
"Program output is correct"
);
t.strictEqual(
- lapi.lua_topointer(L, -1).get('116|119|111|').jsstring(),
+ lua.lua_topointer(L, -1).get('116|119|111|').jsstring(),
"world",
"Program output is correct"
);
@@ -780,19 +780,19 @@ test('SETUPVAL, GETUPVAL', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"world",
"Program output is correct"
);
@@ -822,25 +822,25 @@ test('SETTABUP, GETTABUP', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_topointer(L, -1).get(1).jsstring(),
+ lua.lua_topointer(L, -1).get(1).jsstring(),
"hello",
"Program output is correct"
);
t.strictEqual(
- lapi.lua_topointer(L, -1).get('116|119|111|').jsstring(),
+ lua.lua_topointer(L, -1).get('116|119|111|').jsstring(),
"world",
"Program output is correct"
);
@@ -872,19 +872,19 @@ test('SELF', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -911,19 +911,19 @@ test('SETLIST', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.deepEqual(
- [...lapi.lua_topointer(L, -1).entries()].map(e => e[1].value).sort(),
+ [...lua.lua_topointer(L, -1).entries()].map(e => e[1].value).sort(),
[1, 2, 3, 4, 5, 6, 7, 8, 9],
"Program output is correct"
);
@@ -954,19 +954,19 @@ test('Variable SETLIST', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.deepEqual(
- [...lapi.lua_topointer(L, -1).entries()].map(e => e[1].value).sort(),
+ [...lua.lua_topointer(L, -1).entries()].map(e => e[1].value).sort(),
[1, 2, 3, 4, 5, 6, 7, 8, 9],
"Program output is correct"
);
@@ -992,19 +992,19 @@ test('Long SETLIST', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.deepEqual(
- [...lapi.lua_topointer(L, -1).entries()].map(e => e[1].value).reverse(),
+ [...lua.lua_topointer(L, -1).entries()].map(e => e[1].value).reverse(),
[1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],
"Program output is correct"
);
@@ -1047,19 +1047,19 @@ test('TFORCALL, TFORLOOP', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
6,
"Program output is correct"
);
@@ -1088,31 +1088,31 @@ test('LEN', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
5,
"Program output is correct"
);
t.strictEqual(
- lapi.lua_tonumber(L, -2),
+ lua.lua_tonumber(L, -2),
3,
"Program output is correct"
);
t.strictEqual(
- lapi.lua_tonumber(L, -3),
+ lua.lua_tonumber(L, -3),
0,
"Program output is correct"
);
@@ -1137,19 +1137,19 @@ test('CONCAT', function (t) {
luaCode = null;
return code ? lua.to_luastring(code) : null;
};
-
- lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
+
+ lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello 2 you",
"Program output is correct"
);
diff --git a/tests/lmathlib.js b/tests/lmathlib.js
index 30c33d8..d39e762 100644
--- a/tests/lmathlib.js
+++ b/tests/lmathlib.js
@@ -9,7 +9,6 @@ const toByteCode = tests.toByteCode;
const VM = require("../src/lvm.js");
const ldo = require("../src/ldo.js");
-const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
@@ -32,50 +31,50 @@ test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan',
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -7),
+ lua.lua_tointeger(L, -7),
10,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -6),
+ lua.lua_tonumber(L, -6),
10.5,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -5),
+ lua.lua_tonumber(L, -5),
-0.8390715290764524,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -4),
+ lua.lua_tonumber(L, -4),
0.6483608274590866,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -3),
+ lua.lua_tonumber(L, -3),
1.5707963267948966,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -2),
+ lua.lua_tonumber(L, -2),
1.0471975511965979,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
1.4711276743037347,
"Correct element(s) on the stack"
);
@@ -97,20 +96,20 @@ test('math.ceil, math.floor', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -2),
+ lua.lua_tointeger(L, -2),
11,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
10,
"Correct element(s) on the stack"
);
@@ -133,20 +132,20 @@ test('math.deg, math.rad', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -2),
+ lua.lua_tonumber(L, -2),
572.9577951308232,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
0.17453292519943295,
"Correct element(s) on the stack"
);
@@ -169,26 +168,26 @@ test('math.log', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -3),
+ lua.lua_tonumber(L, -3),
2.302585092994046,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -2),
+ lua.lua_tonumber(L, -2),
3.321928094887362,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
1,
"Correct element(s) on the stack"
);
@@ -211,14 +210,14 @@ test('math.exp', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
22026.465794806718,
"Correct element(s) on the stack"
);
@@ -241,20 +240,20 @@ test('math.min, math.max', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -2),
+ lua.lua_tonumber(L, -2),
23,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
5,
"Correct element(s) on the stack"
);
@@ -277,19 +276,19 @@ test('math.random', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.ok(
- 0 <= lapi.lua_tonumber(L, -2) <= 1,
+ 0 <= lua.lua_tonumber(L, -2) <= 1,
"Correct element(s) on the stack"
);
t.ok(
- 10 <= lapi.lua_tonumber(L, -1) <= 15,
+ 10 <= lua.lua_tonumber(L, -1) <= 15,
"Correct element(s) on the stack"
);
@@ -311,14 +310,14 @@ test('math.sqrt', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
3.1622776601683795,
"Correct element(s) on the stack"
);
@@ -341,14 +340,14 @@ test('math.tointeger', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
10,
"Correct element(s) on the stack"
);
@@ -371,26 +370,26 @@ test('math.type', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -3),
+ lua.lua_tojsstring(L, -3),
"integer",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"float",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
null,
"Correct element(s) on the stack"
);
@@ -413,14 +412,14 @@ test('math.ult', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
true,
"Correct element(s) on the stack"
);
@@ -443,14 +442,14 @@ test('math.fmod', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
2,
"Correct element(s) on the stack"
);
@@ -473,20 +472,20 @@ test('math.modf', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tonumber(L, -2),
+ lua.lua_tonumber(L, -2),
3,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
0.3999999999999999,
"Correct element(s) on the stack"
);
diff --git a/tests/load.js b/tests/load.js
index 913fb01..2b346aa 100644
--- a/tests/load.js
+++ b/tests/load.js
@@ -7,7 +7,6 @@ const toByteCode = tests.toByteCode;
const VM = require("../src/lvm.js");
const ldo = require("../src/ldo.js");
-const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
@@ -33,12 +32,12 @@ test('luaL_loadstring', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -66,12 +65,12 @@ test('load', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"js running lua running lua",
"Correct element(s) on the stack"
);
@@ -101,12 +100,12 @@ test('luaL_loadbuffer', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -134,12 +133,12 @@ test('loadfile', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -167,12 +166,12 @@ test('loadfile (binary)', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -199,12 +198,12 @@ test('dofile', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
diff --git a/tests/loslib.js b/tests/loslib.js
index 1bb217f..00ee019 100644
--- a/tests/loslib.js
+++ b/tests/loslib.js
@@ -2,7 +2,6 @@
const test = require('tape');
-const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
@@ -26,12 +25,12 @@ test('os.time', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.ok(
- lapi.lua_isinteger(L, -1),
+ lua.lua_isinteger(L, -1),
"Correct element(s) on the stack"
);
diff --git a/tests/lstrlib.js b/tests/lstrlib.js
index 0fa9115..f4c7ba4 100644
--- a/tests/lstrlib.js
+++ b/tests/lstrlib.js
@@ -7,7 +7,6 @@ const tests = require("./tests.js");
const toByteCode = tests.toByteCode;
const lua = require("../src/lua.js");
-const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const linit = require('../src/linit.js');
@@ -32,18 +31,18 @@ test('string.len', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -2),
+ lua.lua_tointeger(L, -2),
5,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
5,
"Correct element(s) on the stack"
);
@@ -70,12 +69,12 @@ test('string.char', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Correct element(s) on the stack"
);
@@ -101,18 +100,18 @@ test('string.upper, string.lower', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"HELLO",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Correct element(s) on the stack"
);
@@ -138,12 +137,12 @@ test('string.rep', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello, hello, hello",
"Correct element(s) on the stack"
);
@@ -169,12 +168,12 @@ test('string.reverse', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Correct element(s) on the stack"
);
@@ -200,24 +199,24 @@ test('string.byte', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -3),
+ lua.lua_tointeger(L, -3),
101,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -2),
+ lua.lua_tointeger(L, -2),
108,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
108,
"Correct element(s) on the stack"
);
@@ -243,12 +242,12 @@ test('string.format', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"%10 0000000023",
"Correct element(s) on the stack"
);
@@ -274,12 +273,12 @@ test('string.format', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"FFFFFFF",
"Correct element(s) on the stack"
);
@@ -305,12 +304,12 @@ test('string.format', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
'"a string with \\"quotes\\" and \\\n new line"',
"Correct element(s) on the stack"
);
@@ -346,72 +345,72 @@ test('string.sub', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -11),
+ lua.lua_tojsstring(L, -11),
"234",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -10),
+ lua.lua_tojsstring(L, -10),
"789",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -9),
+ lua.lua_tojsstring(L, -9),
"",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -8),
+ lua.lua_tojsstring(L, -8),
"7",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -7),
+ lua.lua_tojsstring(L, -7),
"",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -6),
+ lua.lua_tojsstring(L, -6),
"123456789",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -5),
+ lua.lua_tojsstring(L, -5),
"123456789",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -4),
+ lua.lua_tojsstring(L, -4),
"",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -3),
+ lua.lua_tojsstring(L, -3),
"9",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"6789",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"456",
"Correct element(s) on the stack"
);
@@ -445,18 +444,18 @@ test('string.dump', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
- let dv = lapi.lua_todataview(L, -1);
+ let dv = lua.lua_todataview(L, -1);
- lapi.lua_load(L, null, dv, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, dv, lua.to_luastring("test"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello1212.5",
"Correct element(s) on the stack"
);
@@ -485,18 +484,18 @@ test('string.pack/unpack/packsize', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -2),
+ lua.lua_tointeger(L, -2),
16,
"Correct element(s) on the stack"
);
t.ok(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
"Correct element(s) on the stack"
);
});
@@ -521,18 +520,18 @@ test('string.find without pattern', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -2),
+ lua.lua_tointeger(L, -2),
6,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
9,
"Correct element(s) on the stack"
);
@@ -558,18 +557,18 @@ test('string.match', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"foo",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"123",
"Correct element(s) on the stack"
);
@@ -595,30 +594,30 @@ test('string.find', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -4),
+ lua.lua_tointeger(L, -4),
1,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -3),
+ lua.lua_tointeger(L, -3),
8,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"foo",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"123",
"Correct element(s) on the stack"
);
@@ -651,30 +650,30 @@ test('string.gmatch', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -4),
+ lua.lua_tojsstring(L, -4),
"hello",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -3),
+ lua.lua_tojsstring(L, -3),
"world",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"from",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"Lua",
"Correct element(s) on the stack"
);
@@ -700,18 +699,18 @@ test('string.gsub', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"hello hello world world",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
2,
"Correct element(s) on the stack"
);
@@ -737,18 +736,18 @@ test('string.gsub (number)', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"hello hello world",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
1,
"Correct element(s) on the stack"
);
@@ -774,18 +773,18 @@ test('string.gsub (pattern)', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"world hello Lua from",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
2,
"Correct element(s) on the stack"
);
@@ -813,18 +812,18 @@ test('string.gsub (function)', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"4+5 = 9",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
1,
"Correct element(s) on the stack"
);
@@ -852,18 +851,18 @@ test('string.gsub (table)', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"lua-5.3.tar.gz",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
2,
"Correct element(s) on the stack"
);
diff --git a/tests/ltablib.js b/tests/ltablib.js
index f7de2bf..946742b 100644
--- a/tests/ltablib.js
+++ b/tests/ltablib.js
@@ -9,7 +9,6 @@ const toByteCode = tests.toByteCode;
const VM = require("../src/lvm.js");
const ldo = require("../src/ldo.js");
-const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
@@ -41,14 +40,14 @@ test('table.concat', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-table.concat"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-table.concat"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"3,4,5",
"Correct element(s) on the stack"
);
@@ -70,14 +69,14 @@ test('table.pack', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-table.pack"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-table.pack"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.deepEqual(
- [...lapi.lua_topointer(L, -1).entries()]
+ [...lua.lua_topointer(L, -1).entries()]
.filter(e => typeof e[0] === 'number') // Filter out the 'n' field
.map(e => e[1].value).reverse(),
[1, 2, 3],
@@ -101,26 +100,26 @@ test('table.unpack', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-table.unpack"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-table.unpack"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -3),
+ lua.lua_tointeger(L, -3),
2,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -2),
+ lua.lua_tointeger(L, -2),
3,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
4,
"Correct element(s) on the stack"
);
@@ -145,14 +144,14 @@ test('table.insert', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-table.insert"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-table.insert"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.deepEqual(
- [...lapi.lua_topointer(L, -1).entries()]
+ [...lua.lua_topointer(L, -1).entries()]
.filter(e => typeof e[0] === 'number')
.map(e => e[1].value).sort(),
[1, 2, 3, 4, 5],
@@ -179,14 +178,14 @@ test('table.remove', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-table.remove"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-table.remove"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.deepEqual(
- [...lapi.lua_topointer(L, -1).entries()]
+ [...lua.lua_topointer(L, -1).entries()]
.filter(e => typeof e[0] === 'number')
.map(e => e[1].value).sort(),
[1, 2, 3, 4, null, null],
@@ -212,14 +211,14 @@ test('table.move', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-table.move"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-table.move"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.deepEqual(
- [...lapi.lua_topointer(L, -1).entries()]
+ [...lua.lua_topointer(L, -1).entries()]
.filter(e => typeof e[0] === 'number')
.map(e => e[1].value).sort(),
[1, 2, 3, 4, 5, 6],
@@ -245,14 +244,14 @@ test('table.sort (<)', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-table.sort"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-table.sort"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.deepEqual(
- inttable2array(lapi.lua_topointer(L, -1)),
+ inttable2array(lua.lua_topointer(L, -1)),
[1, 2, 3, 4, 5],
"Correct element(s) on the stack"
);
@@ -278,14 +277,14 @@ test('table.sort with cmp function', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test-table.sort"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test-table.sort"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.deepEqual(
- inttable2array(lapi.lua_topointer(L, -1)),
+ inttable2array(lua.lua_topointer(L, -1)),
[5, 4, 3, 2, 1],
"Correct element(s) on the stack"
);
diff --git a/tests/ltm.js b/tests/ltm.js
index 92be806..64f52aa 100644
--- a/tests/ltm.js
+++ b/tests/ltm.js
@@ -5,7 +5,6 @@ const beautify = require('js-beautify').js_beautify;
const lua = require("../src/lua.js");
const VM = require("../src/lvm.js");
-const lapi = require("../src/lapi.js");
const linit = require("../src/linit.js");
const lauxlib = require("../src/lauxlib.js");
const OC = require('../src/lopcodes.js');
@@ -32,17 +31,17 @@ test('__index, __newindex: with actual table', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
- lapi.lua_call(L, 0, -1);
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.ok(
- lapi.lua_isnil(L, -1),
+ lua.lua_isnil(L, -1),
"Program output is correct"
);
t.strictEqual(
- lapi.lua_tointeger(L, -2),
+ lua.lua_tointeger(L, -2),
1,
"Program output is correct"
);
@@ -66,11 +65,11 @@ test('__newindex: with non table', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.throws(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed with expected error");
});
@@ -101,16 +100,16 @@ test('__index function in metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"__index",
"Program output is correct"
);
@@ -145,15 +144,15 @@ test('__newindex function in metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.ok(
- lapi.lua_isnil(L, -1),
+ lua.lua_isnil(L, -1),
"Program output is correct"
);
});
@@ -187,15 +186,15 @@ test('__index table in metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -232,21 +231,21 @@ test('__newindex table in metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"world",
"Program output is correct"
);
t.ok(
- lapi.lua_isnil(L, -2),
+ lua.lua_isnil(L, -2),
"Program output is correct"
);
});
@@ -288,15 +287,15 @@ test('__index table with own metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -343,21 +342,21 @@ test('__newindex table with own metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
t.ok(
- lapi.lua_isnil(L, -2),
+ lua.lua_isnil(L, -2),
"Program output is correct"
);
});
@@ -446,11 +445,11 @@ test('binary __xxx functions in metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.deepEqual(
@@ -500,15 +499,15 @@ test('__eq', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.ok(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
"Program output is correct"
);
});
@@ -540,15 +539,15 @@ test('__lt', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.ok(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
"Program output is correct"
);
});
@@ -580,15 +579,15 @@ test('__le', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.ok(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
"Program output is correct"
);
});
@@ -620,15 +619,15 @@ test('__le that uses __lt', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.ok(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
"Program output is correct"
);
});
@@ -664,21 +663,21 @@ test('__unm, __bnot', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"world",
"Program output is correct"
);
t.strictEqual(
- lapi.lua_tojsstring(L, -2),
+ lua.lua_tojsstring(L, -2),
"hello",
"Program output is correct"
);
@@ -711,15 +710,15 @@ test('__len', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -752,15 +751,15 @@ test('__concat', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -793,11 +792,11 @@ test('__call', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.deepEqual(
diff --git a/tests/lutf8lib.js b/tests/lutf8lib.js
index e32409b..4df498c 100644
--- a/tests/lutf8lib.js
+++ b/tests/lutf8lib.js
@@ -4,7 +4,6 @@ const test = require('tape');
const tests = require("./tests.js");
const lua = require("../src/lua.js");
-const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const linit = require('../src/linit.js');
@@ -27,12 +26,12 @@ test('utf8.offset', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
7,
"Correct element(s) on the stack"
);
@@ -59,24 +58,24 @@ test('utf8.codepoint', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -3),
+ lua.lua_tointeger(L, -3),
176,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -2),
+ lua.lua_tointeger(L, -2),
32,
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
860,
"Correct element(s) on the stack"
);
@@ -103,12 +102,12 @@ test('utf8.char', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"( ͡° ͜ʖ ͡° )",
"Correct element(s) on the stack"
);
@@ -135,12 +134,12 @@ test('utf8.len', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
12,
"Correct element(s) on the stack"
);
@@ -172,12 +171,12 @@ test('utf8.codes', function (t) {
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"[1,40] [2,32] [3,865] [5,176] [7,32] [8,860] [10,662] [12,32] [13,865] [15,176] [17,32] [18,41] ",
"Correct element(s) on the stack"
);
diff --git a/tests/lvm.js b/tests/lvm.js
index fe463eb..52736fe 100644
--- a/tests/lvm.js
+++ b/tests/lvm.js
@@ -5,7 +5,7 @@ const beautify = require('js-beautify').js_beautify;
const lua_State = require("../src/lstate.js").lua_State;
const VM = require("../src/lvm.js");
-const lapi = require("../src/lapi.js");
+const lua = require("../src/lua.js");
const getState = require("./tests.js").getState;
@@ -21,11 +21,11 @@ test('LOADK, RETURN', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello world",
"Program output is correct"
);
@@ -45,11 +45,11 @@ test('MOVE', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello world",
"Program output is correct"
);
@@ -68,7 +68,7 @@ test('Binary op', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.deepEqual(
@@ -92,7 +92,7 @@ test('Unary op, LOADBOOL', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.deepEqual(
@@ -115,7 +115,7 @@ test('NEWTABLE', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.ok(
@@ -142,11 +142,11 @@ test('CALL', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
3,
"Program output is correct"
);
@@ -174,7 +174,7 @@ test('Multiple return', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.deepEqual(
@@ -200,11 +200,11 @@ test('TAILCALL', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
3,
"Program output is correct"
);
@@ -226,7 +226,7 @@ test('VARARG', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.deepEqual(
@@ -250,11 +250,11 @@ test('LE, JMP', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
true,
"Program output is correct"
);
@@ -274,11 +274,11 @@ test('LT', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
false,
"Program output is correct"
);
@@ -298,11 +298,11 @@ test('EQ', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_toboolean(L, -1),
+ lua.lua_toboolean(L, -1),
true,
"Program output is correct"
);
@@ -323,11 +323,11 @@ test('TESTSET (and)', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -348,11 +348,11 @@ test('TESTSET (or)', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -377,11 +377,11 @@ test('TEST (true)', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -406,11 +406,11 @@ test('TEST (false)', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"goodbye",
"Program output is correct"
);
@@ -434,11 +434,11 @@ test('FORPREP, FORLOOP (int)', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
55,
"Program output is correct"
);
@@ -462,11 +462,11 @@ test('FORPREP, FORLOOP (float)', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tonumber(L, -1),
+ lua.lua_tonumber(L, -1),
60.5,
"Program output is correct"
);
@@ -489,7 +489,7 @@ test('SETTABLE, GETTABLE', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
console.log(L.stack[L.top - 1]);
@@ -527,11 +527,11 @@ test('SETUPVAL, GETUPVAL', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"world",
"Program output is correct"
);
@@ -554,7 +554,7 @@ test('SETTABUP, GETTABUP', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.deepEqual(
@@ -589,11 +589,11 @@ test('SELF', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -613,7 +613,7 @@ test('SETLIST', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.deepEqual(
@@ -641,7 +641,7 @@ test('Variable SETLIST', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.deepEqual(
@@ -665,7 +665,7 @@ test('Long SETLIST', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.deepEqual(
@@ -689,7 +689,7 @@ test('Long SETLIST', function (t) {
//
// // t.doesNotThrow(function () {
// L = getState(luaCode);
-// lapi.lua_call(L, 0, -1);
+// lua.lua_call(L, 0, -1);
// // }, "Program executed without errors");
//
// t.deepEqual(
@@ -729,11 +729,11 @@ test('TFORCALL, TFORLOOP', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
6,
"Program output is correct"
);
@@ -755,23 +755,23 @@ test('LEN', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tointeger(L, -1),
+ lua.lua_tointeger(L, -1),
5,
"Program output is correct"
);
t.strictEqual(
- lapi.lua_tointeger(L, -2),
+ lua.lua_tointeger(L, -2),
3,
"Program output is correct"
);
t.strictEqual(
- lapi.lua_tointeger(L, -3),
+ lua.lua_tointeger(L, -3),
0,
"Program output is correct"
);
@@ -789,11 +789,11 @@ test('CONCAT', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tojsstring(L, -1),
+ lua.lua_tojsstring(L, -1),
"hello 2 you",
"Program output is correct"
);
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 */
}
};