aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-15 08:52:34 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-15 08:52:34 +0100
commit8388f1d2eb85bfc5fdbe1cfeb62e85a7d88403b5 (patch)
treecded0074e7375415123d8a5b0c2a29494abab746 /tests
parent1a158cc176055a50df492dfa39c1b93e9e5b478a (diff)
downloadfengari-8388f1d2eb85bfc5fdbe1cfeb62e85a7d88403b5.tar.gz
fengari-8388f1d2eb85bfc5fdbe1cfeb62e85a7d88403b5.tar.bz2
fengari-8388f1d2eb85bfc5fdbe1cfeb62e85a7d88403b5.zip
string.byte
Diffstat (limited to 'tests')
-rw-r--r--tests/lstrlib.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/lstrlib.js b/tests/lstrlib.js
index d4e8493..b15eecf 100644
--- a/tests/lstrlib.js
+++ b/tests/lstrlib.js
@@ -177,4 +177,47 @@ test('string.reverse', function (t) {
"hello",
"Correct element(s) on the stack"
);
+});
+
+
+test('string.byte', function (t) {
+ let luaCode = `
+ return string.byte("hello", 2, 4)
+ `, L;
+
+ t.plan(5);
+
+ 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_tointeger(L, -3),
+ 101,
+ "Correct element(s) on the stack"
+ );
+
+ t.strictEqual(
+ lapi.lua_tointeger(L, -2),
+ 108,
+ "Correct element(s) on the stack"
+ );
+
+ t.strictEqual(
+ lapi.lua_tointeger(L, -1),
+ 108,
+ "Correct element(s) on the stack"
+ );
}); \ No newline at end of file