From 43474e4c411709e3c1ab1b1d13283d2bc4789d1d Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 15 Feb 2017 17:52:46 +0100 Subject: lapi tests --- .gdb_history | 4 ++++ .gitignore | 3 ++- tests/C/lua_pushnil.c | 21 +++++++++++++++++++++ tests/lapi.js | 32 ++++++++++++++++++++++++++++++++ tests/tests.js | 2 +- 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 .gdb_history create mode 100644 tests/C/lua_pushnil.c create mode 100644 tests/lapi.js diff --git a/.gdb_history b/.gdb_history new file mode 100644 index 0000000..a3bbc49 --- /dev/null +++ b/.gdb_history @@ -0,0 +1,4 @@ +b 13 +r +dashboard -layout source +s diff --git a/.gitignore b/.gitignore index 9b97118..5b3a064 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ jspm_packages # JSDoc help -luac.out \ No newline at end of file +*.out +*.dSYM \ No newline at end of file diff --git a/tests/C/lua_pushnil.c b/tests/C/lua_pushnil.c new file mode 100644 index 0000000..bb31246 --- /dev/null +++ b/tests/C/lua_pushnil.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include +#include + +int main(void) { + + lua_State *L = luaL_newstate(); + + luaL_openlibs(L); + + lua_pushnil(L); + + printf("L->top(%d): %s\n", lua_gettop(L), luaL_typename(L, lua_gettop(L))); + + lua_close(L); + + return 0; + +} \ No newline at end of file diff --git a/tests/lapi.js b/tests/lapi.js new file mode 100644 index 0000000..2f493c9 --- /dev/null +++ b/tests/lapi.js @@ -0,0 +1,32 @@ +/*jshint esversion: 6 */ +"use strict"; + +const test = require('tape'); +const beautify = require('js-beautify').js_beautify; + +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 CT = require('../src/lua.js').constant_types; + +test('lua_pushnil', function (t) { + let L; + + t.plan(3); + + t.doesNotThrow(function () { + L = getState(`return "dummy"`); + }, "New Lua State initiliazed"); + + // t.doesNotThrow(function () { + lapi.lua_pushnil(L); + // }, "Pushed nil on the stack"); + + t.strictEqual( + L.stack[L.top - 1].type, + CT.LUA_TNIL, + "nil is on the stack" + ); +}); \ No newline at end of file diff --git a/tests/tests.js b/tests/tests.js index 97ca6b4..9994ad5 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -29,7 +29,7 @@ const toByteCode = function (luaCode) { }; }; -const getState = function (luaCode) { +const getState = function(luaCode) { var bc = toByteCode(luaCode), dv = bc.dataView, bcl = bc.bclist; -- cgit v1.2.3-70-g09d2