summaryrefslogtreecommitdiff
path: root/tests/lexparse.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lexparse.js')
-rw-r--r--tests/lexparse.js34
1 files changed, 31 insertions, 3 deletions
diff --git a/tests/lexparse.js b/tests/lexparse.js
index 1a1a7b3..1132ef1 100644
--- a/tests/lexparse.js
+++ b/tests/lexparse.js
@@ -9,6 +9,7 @@ const toByteCode = tests.toByteCode;
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
@@ -108,9 +109,9 @@ test('Unary op, LOADBOOL', function (t) {
return -a, not b, ~a
`, L;
- t.plan(1);
+ t.plan(2);
- // t.doesNotThrow(function () {
+ t.doesNotThrow(function () {
L = lauxlib.luaL_newstate();
@@ -120,7 +121,7 @@ test('Unary op, LOADBOOL', function (t) {
lapi.lua_call(L, 0, -1);
- // }, "JS Lua program ran without error");
+ }, "JS Lua program ran without error");
t.deepEqual(
L.stack.slice(L.top - 3, L.top).map(e => e.value),
@@ -128,3 +129,30 @@ test('Unary op, LOADBOOL', function (t) {
"Program output is correct"
);
});
+
+
+test('NEWTABLE', function (t) {
+ let luaCode = `
+ local a = {}
+ return a
+ `, L;
+
+ t.plan(2);
+
+ t.doesNotThrow(function () {
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lapi.lua_load(L, null, luaCode, "test", "text");
+
+ lapi.lua_call(L, 0, -1);
+
+ }, "JS Lua program ran without error");
+
+ t.ok(
+ L.stack[lapi.index2addr_(L, -1)] instanceof Table,
+ "Program output is correct"
+ );
+}); \ No newline at end of file