From 6258925c955a31ac0c520ffabdbaf138910e48c1 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 3 May 2017 15:58:45 +0200 Subject: package.searchpath --- tests/loadlib.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/loadlib.js b/tests/loadlib.js index b840bf5..ee87b4a 100644 --- a/tests/loadlib.js +++ b/tests/loadlib.js @@ -98,3 +98,35 @@ test('package.loadlib', function (t) { ); }); + + +test('package.searchpath', function (t) { + let luaCode = ` + return package.searchpath('module-hello', './?.lua;./tests/?.lua') + `, 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), + "./tests/module-hello.lua", + "Correct element(s) on the stack" + ); + +}); -- cgit v1.2.3-70-g09d2