summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-16 07:35:26 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-16 07:37:18 +0100
commit3a77114269b53fc57ff00342af18e71f97dcf590 (patch)
treee33feba1afb32d02c1684294362ac74b9e27007f /tests
parent9d6afeba223c22163928557c69a102877223d3bd (diff)
downloadfengari-3a77114269b53fc57ff00342af18e71f97dcf590.tar.gz
fengari-3a77114269b53fc57ff00342af18e71f97dcf590.tar.bz2
fengari-3a77114269b53fc57ff00342af18e71f97dcf590.zip
luaL_newstate, lua_pushnil, lua_gettop, luaL_typename
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