aboutsummaryrefslogtreecommitdiff
path: root/tests/load.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/load.js')
-rw-r--r--tests/load.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/load.js b/tests/load.js
index c7ea3f9..ef37309 100644
--- a/tests/load.js
+++ b/tests/load.js
@@ -147,4 +147,36 @@ test('loadfile', function (t) {
"Correct element(s) on the stack"
);
+});
+
+
+test('dofile', function (t) {
+ let luaCode = `
+ return dofile("tests/loadfile-test.lua")
+ `, 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