summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-17 15:08:28 +0100
committerBenoit Giannangeli <giann@users.noreply.github.com>2017-03-20 07:49:26 +0100
commit54a15b81c50a56c6cecbe99d597b95094427e3c6 (patch)
treec9420cb341d612c67f713820e9dbd0947c95c6a1 /tests
parent335621808b4343645a55682a50caa89c0b703795 (diff)
downloadfengari-54a15b81c50a56c6cecbe99d597b95094427e3c6.tar.gz
fengari-54a15b81c50a56c6cecbe99d597b95094427e3c6.tar.bz2
fengari-54a15b81c50a56c6cecbe99d597b95094427e3c6.zip
string.packsize
Diffstat (limited to 'tests')
-rw-r--r--tests/lstrlib.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/lstrlib.js b/tests/lstrlib.js
index 23cd786..4185f04 100644
--- a/tests/lstrlib.js
+++ b/tests/lstrlib.js
@@ -459,4 +459,38 @@ test('string.dump', function (t) {
"hello1212.5",
"Correct element(s) on the stack"
);
+});
+
+
+test('string.pack/unpack/packsize', function (t) {
+ let luaCode = `
+ local s1, n, s2 = "hello", 2, "you"
+ local packed = string.pack("zjz", s1, n, s2)
+ local us1, un, us2 = string.unpack("zjz", packed)
+ return s1 == us1 and n == un and s2 == us2
+ `, L;
+
+ t.plan(3);
+
+ t.doesNotThrow(function () {
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lauxlib.luaL_loadstring(L, luaCode);
+
+ }, "Lua program loaded without error");
+
+ t.doesNotThrow(function () {
+
+ lapi.lua_call(L, 0, -1);
+
+ }, "Lua program ran without error");
+
+ t.strictEqual(
+ lapi.lua_tostring(L, -1),
+ "FFFFFFF",
+ "Correct element(s) on the stack"
+ );
}); \ No newline at end of file