diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-24 11:14:25 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-24 11:14:25 +0100 |
commit | 2ccf4ee80dbbf3e9af8ff006fcc18798e668a413 (patch) | |
tree | 1e56eed9cf006b12af8449ea20a28b1909cd4681 /tests/ltablib.js | |
parent | cc578361f82c892fc5cce7d2ce9757ca237e87bf (diff) | |
download | fengari-2ccf4ee80dbbf3e9af8ff006fcc18798e668a413.tar.gz fengari-2ccf4ee80dbbf3e9af8ff006fcc18798e668a413.tar.bz2 fengari-2ccf4ee80dbbf3e9af8ff006fcc18798e668a413.zip |
table.remove
Diffstat (limited to 'tests/ltablib.js')
-rw-r--r-- | tests/ltablib.js | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/ltablib.js b/tests/ltablib.js index 1a04e4c..9a18ff6 100644 --- a/tests/ltablib.js +++ b/tests/ltablib.js @@ -145,9 +145,43 @@ test('table.insert', function (t) { t.deepEqual( [...lapi.lua_topointer(L, -1).entries()] - .filter(e => typeof e[0] === 'number') // Filter out the 'n' field + .filter(e => typeof e[0] === 'number') .map(e => e[1].value).sort(), [1, 2, 3, 4, 5], "Correct element(s) on the stack" ); +}); + + +test('table.remove', function (t) { + let luaCode = ` + local t = {1, 2, 3, 3, 4, 4} + table.remove(t) + table.remove(t, 3) + return t + `, L; + + t.plan(2); + + t.doesNotThrow(function () { + + let bc = toByteCode(luaCode).dataView; + + L = lauxlib.luaL_newstate(); + + linit.luaL_openlibs(L); + + lapi.lua_load(L, bc, "test-table.insert"); + + lapi.lua_call(L, 0, -1); + + }, "JS Lua program ran without error"); + + t.deepEqual( + [...lapi.lua_topointer(L, -1).entries()] + .filter(e => typeof e[0] === 'number') + .map(e => e[1].value).sort(), + [1, 2, 3, 4, null, null], + "Correct element(s) on the stack" + ); });
\ No newline at end of file |