summaryrefslogtreecommitdiff
path: root/src/tests/hs_parse_args_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/hs_parse_args_tests.c')
-rw-r--r--src/tests/hs_parse_args_tests.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/tests/hs_parse_args_tests.c b/src/tests/hs_parse_args_tests.c
index a6aa475..300a519 100644
--- a/src/tests/hs_parse_args_tests.c
+++ b/src/tests/hs_parse_args_tests.c
@@ -48,7 +48,8 @@ static int testfunc(lua_State *L) { return 0; }
lua_pop(L, 1);
#define CHECK_FAIL_FUNC(name) \
- lua_pushcfunction(L, name ## _testfunc); lua_getglobal(L, "print"); \
+ lua_pushcfunction(L, name ## _testfunc); \
+ luaL_loadstring(L, "print('hello, world!')"); \
mu_assert("incorrectly succeeded in parsing function!", \
lua_pcall(L, 1, 0, 0) != 0); \
lua_pop(L, 1);
@@ -191,7 +192,7 @@ PARSE_TYPECHECK_TEST(parse_func_typecheck, int, hs_func)
CHECK_FAIL_TABLE(parse_func_typecheck);
lua_pushcfunction(L, parse_func_typecheck_testfunc);
- lua_getglobal(L, "print");
+ luaL_loadstring(L, "print('hello, world!')");
mu_assert("typecheck for function failed!",
lua_pcall(L, 1, 0, 0) == 0);
@@ -199,7 +200,7 @@ PARSE_TYPECHECK_TEST(parse_func_typecheck, int, hs_func)
lua_pushvalue(L, -1);
mu_assert("typecheck for C function failed!",
lua_pcall(L, 1, 0, 0) == 0);
-
+
CHECK_FAIL_USER(parse_func_typecheck);
CHECK_FAIL_LIGHT(parse_func_typecheck);
CHECK_FAIL_NIL(parse_func_typecheck);
@@ -318,7 +319,7 @@ PARSE_TYPECHECK_TEST(parse_any_typecheck, int, hs_any)
lua_pcall(L, 1, 0, 0) == 0);
lua_pushcfunction(L, parse_func_typecheck_testfunc);
- lua_getglobal(L, "test");
+ luaL_loadstring(L, "print('hello, world!')");
mu_assert("typecheck for function failed!",
lua_pcall(L, 1, 0, 0) == 0);
@@ -429,7 +430,7 @@ int should_fail(lua_State *L)
TEST(fail_parse_noncfunc)
{
lua_pushcfunction(L, should_fail);
- lua_getglobal(L, "print");
+ luaL_loadstring(L, "print('hello, world!')");
mu_assert("incorrectly parsed non-C function!",
lua_pcall(L, 1, 0, 0) != 0);
return 0;
@@ -548,7 +549,8 @@ TEST(parse_readme_example)
lua_pushstring(L, "c: c: c:");
void *userdata = lua_newuserdata(L, sizeof(char));
- bool b; int i; int table_index; float f; char *str; void *user;
+ bool b; long int i; int table_index;
+ double f; char *str; void *user;
hs_parse_args
(L, hs_bool(b), hs_int(i), hs_tbl(table_index),
hs_num(f), hs_str(str), hs_user(user));
@@ -571,7 +573,7 @@ TEST(parse_readme_example)
void hs_parse_args_tests()
{
- printf("running hs_parse_args() typechecking tests...\n");
+ printf("running hs_parse_args() tests...\n");
mu_run_test("parse bool typecheck", parse_bool_typecheck);
mu_run_test("parse int typecheck", parse_int_typecheck);
mu_run_test("parse num typecheck", parse_num_typecheck);
@@ -584,7 +586,6 @@ void hs_parse_args_tests()
mu_run_test("parse nil typecheck", parse_nil_typecheck);
mu_run_test("parse any typecheck", parse_any_typecheck);
- printf("running hs_parse_args() parsing tests...\n");
mu_run_test("parse bool", parse_bool);
mu_run_test("parse int", parse_int);
mu_run_test("parse num", parse_num);