aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lapi.js36
1 files changed, 22 insertions, 14 deletions
diff --git a/tests/lapi.js b/tests/lapi.js
index b79c519..39477b2 100644
--- a/tests/lapi.js
+++ b/tests/lapi.js
@@ -1,31 +1,39 @@
/*jshint esversion: 6 */
"use strict";
-const test = require('tape');
-const beautify = require('js-beautify').js_beautify;
+const test = require('tape');
+const beautify = require('js-beautify').js_beautify;
-const getState = require("./tests.js").getState;
+const getState = require("./tests.js").getState;
-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 CT = require('../src/lua.js').constant_types;
+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 CT = require('../src/lua.js').constant_types;
-test('luaL_newstate, lua_pushnil', function (t) {
+test('luaL_newstate, lua_pushnil, lua_gettop, luaL_typename', function (t) {
let L;
- t.plan(2);
+ t.plan(3);
t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate()
+
+ L = lauxlib.luaL_newstate();
lapi.lua_pushnil(L);
+
}, "JS Lua program ran without error");
t.strictEqual(
- L.stack[L.top - 1].type,
- CT.LUA_TNIL,
- "nil is on the stack"
+ lapi.lua_gettop(L),
+ 1,
+ "top is correct"
+ );
+
+ t.strictEqual(
+ lauxlib.luaL_typename(L, lapi.lua_gettop(L)),
+ "nil",
+ "Correct element(s) on the stack"
);
}); \ No newline at end of file