summaryrefslogtreecommitdiff
path: root/src/tests/hs_throw_error_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/hs_throw_error_tests.c')
-rw-r--r--src/tests/hs_throw_error_tests.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tests/hs_throw_error_tests.c b/src/tests/hs_throw_error_tests.c
index 1c5af6a..ebb05b4 100644
--- a/src/tests/hs_throw_error_tests.c
+++ b/src/tests/hs_throw_error_tests.c
@@ -1,11 +1,11 @@
#include "hs_tests.h"
-const char *err_string = "";
+char err_string[32] = "";
int set_err_string(lua_State *L)
{
if (lua_isstring(L, -1))
- err_string = lua_tostring(L, -1);
+ strcpy(err_string, lua_tostring(L, -1));
return 0;
}
@@ -18,8 +18,9 @@ int throw_const_error(lua_State *L)
TEST(hs_throw_error_constant)
{
- lua_pushcfunction(L, throw_const_error);
+ lua_pushcfunction(L, set_err_string);
int pos = lua_gettop(L);
+ lua_pushcfunction(L, throw_const_error);
int result = lua_pcall(L, 0, 0, pos);
mu_assert_equal(result, LUA_ERRRUN);
mu_assert_str_not_equal(err_string, "");
@@ -36,8 +37,9 @@ int throw_number_error(lua_State *L)
TEST(hs_throw_error_format)
{
- lua_pushcfunction(L, throw_number_error);
+ lua_pushcfunction(L, set_err_string);
int pos = lua_gettop(L);
+ lua_pushcfunction(L, throw_number_error);
int result = lua_pcall(L, 0, 0, pos);
mu_assert_equal(result, LUA_ERRRUN);
mu_assert_str_not_equal(err_string, "");