diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-05-03 15:53:15 +0200 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-05-03 15:53:55 +0200 |
commit | ee05d5644a8ae872c9b8c8b437651b3f34d88591 (patch) | |
tree | dcd4dc972b59b8b0cec3cdaa4740fa7b44078c19 /tests/loadlib.js | |
parent | 278fd3edb6ead6cd65c2293f823887d19e4fbc8e (diff) | |
download | fengari-ee05d5644a8ae872c9b8c8b437651b3f34d88591.tar.gz fengari-ee05d5644a8ae872c9b8c8b437651b3f34d88591.tar.bz2 fengari-ee05d5644a8ae872c9b8c8b437651b3f34d88591.zip |
package.loadlib
Diffstat (limited to 'tests/loadlib.js')
-rw-r--r-- | tests/loadlib.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/loadlib.js b/tests/loadlib.js index 933991c..b840bf5 100644 --- a/tests/loadlib.js +++ b/tests/loadlib.js @@ -66,3 +66,35 @@ test('require a file', function (t) { ); }); + + +test('package.loadlib', function (t) { + let luaCode = ` + return package.loadlib('./tests/lib-hello.js.mod', 'hello')() + `, L; + + t.plan(3); + + t.doesNotThrow(function () { + + L = lauxlib.luaL_newstate(); + + lauxlib.luaL_openlibs(L); + + lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + + }, "Lua program loaded without error"); + + t.doesNotThrow(function () { + + lua.lua_call(L, 0, -1); + + }, "Lua program ran without error"); + + t.strictEqual( + lua.lua_tojsstring(L, -1), + "hello from js lib", + "Correct element(s) on the stack" + ); + +}); |