aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lexparse.js3
-rw-r--r--tests/lua.js28
-rw-r--r--tests/lvm.js3
3 files changed, 30 insertions, 4 deletions
diff --git a/tests/lexparse.js b/tests/lexparse.js
index 96c8fca..68b6667 100644
--- a/tests/lexparse.js
+++ b/tests/lexparse.js
@@ -10,7 +10,6 @@ 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 Table = require("../src/lobject.js").Table;
// Roughly the same tests as test/lvm.js to cover all opcodes
@@ -203,7 +202,7 @@ test('NEWTABLE', function (t) {
}, "Lua program ran without error");
t.ok(
- L.stack[lapi.index2addr_(L, -1)] instanceof Table,
+ L.stack[lapi.index2addr_(L, -1)].ttistable(),
"Program output is correct"
);
});
diff --git a/tests/lua.js b/tests/lua.js
index 30a9c98..28fa9fd 100644
--- a/tests/lua.js
+++ b/tests/lua.js
@@ -8,6 +8,34 @@ const lua = require('../src/lua.js');
const linit = require('../src/linit.js');
+test('locals.lua', function (t) {
+ let luaCode = `
+ _soft = true
+ require = function(lib) return _G[lib] end -- NYI
+ return dofile("tests/lua-tests/locals.lua")
+ `, L;
+
+ t.plan(1);
+
+ t.doesNotThrow(function () {
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+
+ }, "Lua program loaded without error");
+
+ // t.doesNotThrow(function () {
+
+ lapi.lua_call(L, 0, -1);
+
+ // }, "Lua program ran without error");
+
+});
+
+
test('constructs.lua', function (t) {
let luaCode = `
_soft = true
diff --git a/tests/lvm.js b/tests/lvm.js
index 0f91d81..fe463eb 100644
--- a/tests/lvm.js
+++ b/tests/lvm.js
@@ -6,7 +6,6 @@ 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 Table = require("../src/lobject.js").Table;
const getState = require("./tests.js").getState;
@@ -120,7 +119,7 @@ test('NEWTABLE', function (t) {
}, "Program executed without errors");
t.ok(
- L.stack[L.top - 1] instanceof Table,
+ L.stack[L.top - 1].ttistable(),
"Program output is correct"
);
});