summaryrefslogtreecommitdiff
path: root/tests/lbaselib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-22 14:19:19 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-22 14:19:19 +0100
commiteb9ad22e7538a25ef565e93c842eef48dba2469e (patch)
treec6ac06713b5e5b45cf0f5d0c3010163f2e6e5309 /tests/lbaselib.js
parentb31cc0420e77d34465e4cf7d7ab75df7755b44d6 (diff)
downloadfengari-eb9ad22e7538a25ef565e93c842eef48dba2469e.tar.gz
fengari-eb9ad22e7538a25ef565e93c842eef48dba2469e.tar.bz2
fengari-eb9ad22e7538a25ef565e93c842eef48dba2469e.zip
lua_rawlen, rawlen
Diffstat (limited to 'tests/lbaselib.js')
-rw-r--r--tests/lbaselib.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/lbaselib.js b/tests/lbaselib.js
index a7b14d9..21d18aa 100644
--- a/tests/lbaselib.js
+++ b/tests/lbaselib.js
@@ -517,5 +517,39 @@ test('assert', function (t) {
lapi.lua_tostring(L, -1).endsWith("this doesn't makes sense"),
"Error is on the stack"
);
+});
+
+
+test('rawlen', function (t) {
+ let luaCode = `
+ return rawlen({1, 2, 3}), rawlen('hello')
+ `, L;
+
+ t.plan(3);
+
+ t.doesNotThrow(function () {
+
+ let bc = toByteCode(luaCode).dataView;
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+ lapi.lua_load(L, bc, "test-rawlen");
+
+ lapi.lua_call(L, 0, -1);
+
+ }, "JS Lua program ran without error");
+
+ t.strictEqual(
+ lapi.lua_tonumber(L, -2),
+ 3,
+ "Correct element(s) on the stack"
+ );
+
+ t.strictEqual(
+ lapi.lua_tonumber(L, -1),
+ 5,
+ "Correct element(s) on the stack"
+ );
}); \ No newline at end of file