aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-24 08:13:38 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-24 08:13:38 +0100
commitbd3ffd7282de8236cd4eb2ff2e21bbc10791bfeb (patch)
tree2de6c6153d1cce350402053e364236cecb1c9725 /tests
parent8b9545c6b2a158d44e18dcaa1147cc1206eabfd3 (diff)
downloadfengari-bd3ffd7282de8236cd4eb2ff2e21bbc10791bfeb.tar.gz
fengari-bd3ffd7282de8236cd4eb2ff2e21bbc10791bfeb.tar.bz2
fengari-bd3ffd7282de8236cd4eb2ff2e21bbc10791bfeb.zip
table.pack
Diffstat (limited to 'tests')
-rw-r--r--tests/ltablib.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/ltablib.js b/tests/ltablib.js
index 22a6797..28b9ce0 100644
--- a/tests/ltablib.js
+++ b/tests/ltablib.js
@@ -44,4 +44,35 @@ test('table.concat', function (t) {
"3,4,5",
"Correct element(s) on the stack"
);
+});
+
+
+test('table.pack', function (t) {
+ let luaCode = `
+ return table.pack(1, 2, 3)
+ `, 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.pack");
+
+ 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') // Filter out the 'n' field
+ .map(e => e[1].value).reverse(),
+ [1, 2, 3],
+ "Correct element(s) on the stack"
+ );
}); \ No newline at end of file