From 78b48979b8dbd367043c39fb21007ab4f54cd0a4 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 17 Feb 2017 14:13:10 +0100 Subject: lua_settable, lua_gettable --- tests/lapi.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/lapi.js') diff --git a/tests/lapi.js b/tests/lapi.js index 561841f..298328c 100644 --- a/tests/lapi.js +++ b/tests/lapi.js @@ -476,4 +476,32 @@ test('lua_newtable', function (t) { lapi.lua_istable(L, -1), "Correct element(s) on the stack" ); +}); + + +test('lua_settable, lua_gettable', function (t) { + let L; + + t.plan(2); + + t.doesNotThrow(function () { + L = lauxlib.luaL_newstate(); + + lapi.lua_newtable(L); + + lapi.lua_pushstring(L, "key"); + lapi.lua_pushstring(L, "value"); + + lapi.lua_settable(L, -3); + + lapi.lua_pushstring(L, "key"); + lapi.lua_gettable(L, -2); + + }, "JS Lua program ran without error"); + + t.strictEqual( + lapi.lua_tostring(L, -1), + "value", + "Correct element(s) on the stack" + ); }); \ No newline at end of file -- cgit v1.2.3-54-g00ecf