summaryrefslogtreecommitdiff
path: root/tests/load.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-21 15:29:53 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-23 08:28:07 +0100
commit9e08fa3a4b9f8848bb4eac3e745079282099a3d8 (patch)
tree64be88a45075fe93bbd8c03c3244d3a83fad7491 /tests/load.js
parentc4b23126f0cb803ec944c5d7877bbf669f582374 (diff)
downloadfengari-9e08fa3a4b9f8848bb4eac3e745079282099a3d8.tar.gz
fengari-9e08fa3a4b9f8848bb4eac3e745079282099a3d8.tar.bz2
fengari-9e08fa3a4b9f8848bb4eac3e745079282099a3d8.zip
loadfile
Diffstat (limited to 'tests/load.js')
-rw-r--r--tests/load.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/load.js b/tests/load.js
index 86c3904..c7ea3f9 100644
--- a/tests/load.js
+++ b/tests/load.js
@@ -114,4 +114,37 @@ test('luaL_loadbuffer', function (t) {
"Correct element(s) on the stack"
);
+});
+
+// TODO: test stdin
+test('loadfile', function (t) {
+ let luaCode = `
+ local f = loadfile("tests/loadfile-test.lua")
+ return f()
+ `, L;
+
+ t.plan(3);
+
+ 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_tostring(L, -1),
+ "hello world",
+ "Correct element(s) on the stack"
+ );
+
}); \ No newline at end of file