aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-17 09:45:49 +0100
committerBenoit Giannangeli <giann@users.noreply.github.com>2017-03-17 10:36:57 +0100
commit18631188532881934261e72321d9839ad42d1b06 (patch)
treea426425e76be16eee6eb4fafec411f147bb4d472 /tests
parent0cbdb3527041d016097aa3384af9c5908af2cce6 (diff)
downloadfengari-18631188532881934261e72321d9839ad42d1b06.tar.gz
fengari-18631188532881934261e72321d9839ad42d1b06.tar.bz2
fengari-18631188532881934261e72321d9839ad42d1b06.zip
lua_todataview to use string as binary representation
Diffstat (limited to 'tests')
-rw-r--r--tests/lstrlib.js35
1 files changed, 16 insertions, 19 deletions
diff --git a/tests/lstrlib.js b/tests/lstrlib.js
index aec8e2a..a7693a1 100644
--- a/tests/lstrlib.js
+++ b/tests/lstrlib.js
@@ -418,17 +418,15 @@ test('string.sub', function (t) {
test('string.dump', function (t) {
- let luaCodeToDump = `
- local todump = function(p1, p2, p3)
- local s = "hello"
- local i = 12
- local f = 12.5
- local b = true
-
- return p1 + p2 + p3
- end`,
- luaCode = `
- ${luaCodeToDump}
+ let luaCode = `
+ local todump = function()
+ local s = "hello"
+ local i = 12
+ local f = 12.5
+ local b = true
+
+ return s .. i .. f
+ end
return string.dump(todump)
`, L, bytes = [];
@@ -436,11 +434,6 @@ test('string.dump', function (t) {
t.plan(3);
t.doesNotThrow(function () {
-
- let bc = toByteCode(luaCodeToDump).dataView;
- for (let i = 0; i < bc.byteLength; i++)
- bytes.push(bc.getUint8(i, true));
-
L = lauxlib.luaL_newstate();
linit.luaL_openlibs(L);
@@ -453,11 +446,15 @@ test('string.dump', function (t) {
lapi.lua_call(L, 0, -1);
+ let dv = lapi.lua_todataview(L, -1);
+
+ lapi.lua_load(L, null, dv, "test", "binary");
+
}, "Lua program ran without error");
- t.deepEqual(
- L.stack[L.top -1].value,
- bytes,
+ t.strictEqual(
+ lapi.lua_tostring(L, -1),
+ "hello1212.5",
"Correct element(s) on the stack"
);
}); \ No newline at end of file