summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-24 11:38:23 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-24 11:40:35 +0100
commit2f9fe378bc341921e1ae259a2fec049663100738 (patch)
tree64f5f5a5cbc40630c894f5700502d3f757eef1f1 /tests
parent2ccf4ee80dbbf3e9af8ff006fcc18798e668a413 (diff)
downloadfengari-2f9fe378bc341921e1ae259a2fec049663100738.tar.gz
fengari-2f9fe378bc341921e1ae259a2fec049663100738.tar.bz2
fengari-2f9fe378bc341921e1ae259a2fec049663100738.zip
table.move
Diffstat (limited to 'tests')
-rw-r--r--tests/ltablib.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ltablib.js b/tests/ltablib.js
index 9a18ff6..990b1f8 100644
--- a/tests/ltablib.js
+++ b/tests/ltablib.js
@@ -184,4 +184,37 @@ test('table.remove', function (t) {
[1, 2, 3, 4, null, null],
"Correct element(s) on the stack"
);
+});
+
+
+test('table.move', function (t) {
+ let luaCode = `
+ local t1 = {3, 4, 5}
+ local t2 = {1, 2, nil, nil, nil, 6}
+ return table.move(t1, 1, #t1, 3, t2)
+ `, 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, 5, 6],
+ "Correct element(s) on the stack"
+ );
}); \ No newline at end of file