aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/load.js33
-rw-r--r--tests/loadfile-test.lua1
2 files changed, 34 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
diff --git a/tests/loadfile-test.lua b/tests/loadfile-test.lua
new file mode 100644
index 0000000..838d20b
--- /dev/null
+++ b/tests/loadfile-test.lua
@@ -0,0 +1 @@
+return "hello world" \ No newline at end of file