aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-23 08:33:41 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-23 08:45:34 +0100
commit99564913987698cdfc2528a93b5157030e637ced (patch)
tree49963f4e7358367cb3c6a4a5784cb1dd6c97de33 /tests
parent9e08fa3a4b9f8848bb4eac3e745079282099a3d8 (diff)
downloadfengari-99564913987698cdfc2528a93b5157030e637ced.tar.gz
fengari-99564913987698cdfc2528a93b5157030e637ced.tar.bz2
fengari-99564913987698cdfc2528a93b5157030e637ced.zip
dofile
Diffstat (limited to 'tests')
-rw-r--r--tests/ldebug.js14
-rw-r--r--tests/load.js32
2 files changed, 39 insertions, 7 deletions
diff --git a/tests/ldebug.js b/tests/ldebug.js
index 472c66b..0261305 100644
--- a/tests/ldebug.js
+++ b/tests/ldebug.js
@@ -40,7 +40,7 @@ test('luaG_typeerror', function (t) {
t.ok(
lapi.lua_tostring(L, -1).endsWith("attempt to get length of a boolean value (local 'a')"),
"Correct error was thrown"
- )
+ );
});
@@ -69,7 +69,7 @@ test('luaG_typeerror', function (t) {
t.ok(
lapi.lua_tostring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
"Correct error was thrown"
- )
+ );
});
@@ -98,7 +98,7 @@ test('luaG_typeerror', function (t) {
t.ok(
lapi.lua_tostring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
"Correct error was thrown"
- )
+ );
});
@@ -127,7 +127,7 @@ test('luaG_typeerror', function (t) {
t.ok(
lapi.lua_tostring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
"Correct error was thrown"
- )
+ );
});
@@ -155,7 +155,7 @@ test('luaG_concaterror', function (t) {
t.ok(
lapi.lua_tostring(L, -1).endsWith("attempt to concatenate a table value"),
"Correct error was thrown"
- )
+ );
});
@@ -183,7 +183,7 @@ test('luaG_opinterror', function (t) {
t.ok(
lapi.lua_tostring(L, -1).endsWith("attempt to perform arithmetic on a string value"),
"Correct error was thrown"
- )
+ );
});
@@ -211,5 +211,5 @@ test('luaG_tointerror', function (t) {
t.ok(
lapi.lua_tostring(L, -1).endsWith("number has no integer representation"),
"Correct error was thrown"
- )
+ );
}); \ No newline at end of file
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