summaryrefslogtreecommitdiff
path: root/tests/lbaselib.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lbaselib.js')
-rw-r--r--tests/lbaselib.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/lbaselib.js b/tests/lbaselib.js
index 6dc6bfb..a7b14d9 100644
--- a/tests/lbaselib.js
+++ b/tests/lbaselib.js
@@ -489,4 +489,33 @@ test('tonumber', function (t) {
2,
"Correct element(s) on the stack"
);
+});
+
+
+test('assert', function (t) {
+ let luaCode = `
+ assert(1 < 0, "this doesn't makes sense")
+ `, L;
+
+ t.plan(2);
+
+ t.doesNotThrow(function () {
+
+ let bc = toByteCode(luaCode).dataView;
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lapi.lua_load(L, bc, "test-assert");
+
+ lapi.lua_pcall(L, 0, -1, 0);
+
+ }, "JS Lua program ran without error");
+
+ t.ok(
+ lapi.lua_tostring(L, -1).endsWith("this doesn't makes sense"),
+ "Error is on the stack"
+ );
+
}); \ No newline at end of file