From 3a77114269b53fc57ff00342af18e71f97dcf590 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Thu, 16 Feb 2017 07:35:26 +0100 Subject: luaL_newstate, lua_pushnil, lua_gettop, luaL_typename --- tests/lapi.js | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'tests') 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 -- cgit v1.2.3-70-g09d2