From 4f0c9181f38355cb74393f6f6cbba56b8bd52e18 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 18 Jun 2017 23:51:31 +1000 Subject: tests/tests.js: throw errors if unable to load code --- tests/tests.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/tests.js') diff --git a/tests/tests.js b/tests/tests.js index 4170f67..75e5e19 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -24,8 +24,11 @@ const toByteCode = function (luaCode) { const getState = function(luaCode) { let L = lauxlib.luaL_newstate(); + if (!L) + throw Error("unable to create lua_State"); - lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + if (lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)) !== lua.LUA_OK) + return Error(lua.lua_tojsstring(L, -1)); return L; }; -- cgit v1.2.3-54-g00ecf