From b31cc0420e77d34465e4cf7d7ab75df7755b44d6 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 22 Feb 2017 13:54:30 +0100 Subject: assert --- tests/lbaselib.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/lbaselib.js') 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 -- cgit v1.2.3-54-g00ecf