diff options
Diffstat (limited to 'src/tests/hs_create_table_tests.c')
-rw-r--r-- | src/tests/hs_create_table_tests.c | 215 |
1 files changed, 202 insertions, 13 deletions
diff --git a/src/tests/hs_create_table_tests.c b/src/tests/hs_create_table_tests.c index 0d6465d..c33454a 100644 --- a/src/tests/hs_create_table_tests.c +++ b/src/tests/hs_create_table_tests.c @@ -3,6 +3,16 @@ static int testfunc1(lua_State *L) { return 0; } static int testfunc2(lua_State *L) { return 0; } +static void print_stack(lua_State *L) +{ + printf("stack: %d [", lua_gettop(L)); + for (int i=0; i<lua_gettop(L); i++) { + printf(" %s, ", lua_typename(L, lua_type(L, i+1))); + } + printf("]\n"); +} + + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * tests for hs_create_table @@ -32,7 +42,7 @@ TEST(table_correct_index) #define loadkey_num(index, value) \ load_key(index, value, lua_pushnumber) #define loadkey_str(index, value) \ - load_key(index, value, lua_pushstring) + lua_getfield(L, index, value) #define loadkey_tbl(index, value) do { \ lua_pushvalue(L, value); lua_gettable(L, index); \ mu_assert("value at table (index '" #value "') is nil!", \ @@ -57,27 +67,26 @@ TEST(table_correct_index) do { \ mu_assert("value is not of type " typestring, is_type(L, -1)); \ type value = conversion(L, -1); lua_pop(L, 1); \ - mu_assert("test " #comparison " failed!", (comparison)); \ - lua_pop(L, 1); /* remove key */ \ + mu_assert("test " #comparison " failed!", (comparison)); \ } while(0) -#define checkval_bool(expected) \ +#define checkval_bool(expected) \ check_value(lua_isboolean, "boolean", bool, lua_toboolean, value==expected) -#define checkval_int(expected) \ +#define checkval_int(expected) \ check_value(lua_isnumber, "integer", lua_Integer, lua_tointeger, value==expected) -#define checkval_num(expected) \ +#define checkval_num(expected) \ check_value(lua_isnumber, "number", lua_Number, lua_tonumber, value==expected) -#define checkval_str(expected) \ - check_value(lua_isstring, "string", const char *, lua_tostring, strcmp(value, expected)) -#define checkval_tbl(expected) \ +#define checkval_str(expected) \ + check_value(lua_isstring, "string", const char *, lua_tostring, strcmp(value, expected)==0) +#define checkval_tbl(expected) \ check_value(lua_istable, "table", const void *, lua_topointer, value==lua_topointer(L, expected)) -#define checkval_func(expected) \ +#define checkval_func(expected) \ check_value(lua_isfunction, "function", const void *, lua_topointer, value==lua_topointer(L, expected)) -#define checkval_cfunc(expected) \ +#define checkval_cfunc(expected) \ check_value(lua_iscfunction, "C function", lua_CFunction, lua_tocfunction, value==expected) -#define checkval_user(expected) \ +#define checkval_user(expected) \ check_value(lua_isuserdata, "userdata", void *, lua_touserdata, value==lua_topointer(L, expected)) -#define checkval_light(expected) \ +#define checkval_light(expected) \ check_value(lua_islightuserdata, "light userdata", void *, lua_touserdata, value==expected) #define store(name) \ @@ -103,6 +112,8 @@ TEST(create_table_bool_bool) int index = hs_create_table (L, hs_bool_bool(true, true), hs_bool_bool(false, true)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_bool(index, true); checkval_bool(true); @@ -117,6 +128,8 @@ TEST(create_table_bool_int) int index = hs_create_table (L, hs_bool_int(true, 15), hs_bool_int(false, 25)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_bool(index, true); checkval_int(15); @@ -131,6 +144,8 @@ TEST(create_table_bool_num) int index = hs_create_table (L, hs_bool_num(true, 2.718), hs_bool_num(false, 1.618)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_bool(index, true); checkval_num(2.718); @@ -141,15 +156,24 @@ TEST(create_table_bool_num) TEST(create_table_bool_str) { + print_stack(L); int oldtop = lua_gettop(L); int index = hs_create_table (L, hs_bool_str(true, "hello"), hs_bool_str(false, "world")); + print_stack(L); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_bool(index, true); + print_stack(L); + printf("value: '%s'", lua_tostring(L, -1)); checkval_str("hello"); + print_stack(L); loadkey_bool(index, false); + print_stack(L); checkval_str("world"); + print_stack(L); return 0; } @@ -165,6 +189,8 @@ TEST(create_table_bool_tbl) int index = hs_create_table (L, hs_bool_tbl(true, value1), hs_bool_tbl(false, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(value1); load(value2); @@ -188,9 +214,15 @@ TEST(create_table_bool_func) int index = hs_create_table (L, hs_bool_func(true, value1), hs_bool_func(false, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); + + printf("index: %d, stack: %d\n", index, lua_gettop(L)); load(value1); + printf("index: %d, stack: %d\n", index, lua_gettop(L)); load(value2); + printf("index: %d, stack: %d\n", index, lua_gettop(L)); loadkey_bool(index, true); checkval_func(value1); @@ -206,6 +238,8 @@ TEST(create_table_bool_cfunc) int index = hs_create_table (L, hs_bool_cfunc(true, testfunc1), hs_bool_cfunc(false, testfunc2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_bool(index, true); checkval_cfunc(testfunc1); @@ -227,6 +261,8 @@ TEST(create_table_bool_user) int index = hs_create_table (L, hs_bool_user(true, user1), hs_bool_user(false, user2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -249,6 +285,8 @@ TEST(create_table_bool_light) int index = hs_create_table (L, hs_bool_light(true, light1), hs_bool_light(false, light2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_bool(index, true); checkval_light(light1); @@ -271,6 +309,8 @@ TEST(create_table_int_bool) int index = hs_create_table (L, hs_int_bool(15, true), hs_int_bool(25, true)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_int(index, 15); checkval_bool(true); @@ -285,6 +325,8 @@ TEST(create_table_int_int) int index = hs_create_table (L, hs_int_int(15, 15), hs_int_int(25, 25)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_int(index, 15); checkval_int(15); @@ -299,6 +341,8 @@ TEST(create_table_int_num) int index = hs_create_table (L, hs_int_num(15, 2.718), hs_int_num(25, 1.618)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_int(index, 15); checkval_num(2.718); @@ -313,8 +357,11 @@ TEST(create_table_int_str) int index = hs_create_table (L, hs_int_str(15, "hello"), hs_int_str(25, "world")); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_int(index, 15); + printf("value: %s\n", lua_tostring(L, -1)); checkval_str("hello"); loadkey_int(index, 25); checkval_str("world"); @@ -333,6 +380,8 @@ TEST(create_table_int_tbl) int index = hs_create_table (L, hs_int_tbl(15, value1), hs_int_tbl(25, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(value1); load(value2); @@ -356,6 +405,8 @@ TEST(create_table_int_func) int index = hs_create_table (L, hs_int_func(15, value1), hs_int_func(25, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(value1); load(value2); @@ -374,6 +425,8 @@ TEST(create_table_int_cfunc) int index = hs_create_table (L, hs_int_cfunc(15, testfunc1), hs_int_cfunc(25, testfunc2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_int(index, 15); checkval_cfunc(testfunc1); @@ -395,6 +448,8 @@ TEST(create_table_int_user) int index = hs_create_table (L, hs_int_user(15, user1), hs_int_user(25, user2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -417,6 +472,8 @@ TEST(create_table_int_light) int index = hs_create_table (L, hs_int_light(15, light1), hs_int_light(25, light2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_int(index, 15); checkval_light(light1); @@ -439,6 +496,8 @@ TEST(create_table_num_bool) int index = hs_create_table (L, hs_num_bool(43.3f, true), hs_num_bool(23.56f, false)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_num(index, 43.3f); checkval_bool(true); @@ -453,6 +512,8 @@ TEST(create_table_num_int) int index = hs_create_table (L, hs_num_int(43.3f, 15), hs_num_int(23.56f, 25)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_num(index, 43.3f); checkval_int(15); @@ -467,6 +528,8 @@ TEST(create_table_num_num) int index = hs_create_table (L, hs_num_num(43.3f, 2.718), hs_num_num(23.56f, 1.618)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_num(index, 43.3f); checkval_num(2.718); @@ -481,6 +544,8 @@ TEST(create_table_num_str) int index = hs_create_table (L, hs_num_str(43.3f, "hello"), hs_num_str(23.56f, "world")); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_num(index, 43.3f); checkval_str("hello"); @@ -501,6 +566,8 @@ TEST(create_table_num_tbl) int index = hs_create_table (L, hs_num_tbl(43.3f, value1), hs_num_tbl(23.56f, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(value1); load(value2); @@ -524,6 +591,8 @@ TEST(create_table_num_func) int index = hs_create_table (L, hs_num_func(43.3f, value1), hs_num_func(23.56f, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(value1); load(value2); @@ -542,6 +611,8 @@ TEST(create_table_num_cfunc) int index = hs_create_table (L, hs_num_cfunc(43.3f, testfunc1), hs_num_cfunc(23.56f, testfunc2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_num(index, 43.3f); checkval_cfunc(testfunc1); @@ -563,6 +634,8 @@ TEST(create_table_num_user) int index = hs_create_table (L, hs_num_user(43.3f, user1), hs_num_user(23.56f, user2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -585,6 +658,8 @@ TEST(create_table_num_light) int index = hs_create_table (L, hs_num_light(43.3f, light1), hs_num_light(23.56f, light2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_num(index, 43.3f); checkval_light(light1); @@ -603,15 +678,23 @@ TEST(create_table_num_light) TEST(create_table_str_bool) { + print_stack(L); int oldtop = lua_gettop(L); int index = hs_create_table (L, hs_str_bool("c:", true), hs_str_bool(":)", true)); + print_stack(L); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_str(index, "c:"); + print_stack(L); checkval_bool(true); + print_stack(L); loadkey_str(index, ":)"); + print_stack(L); checkval_bool(true); + print_stack(L); return 0; } @@ -621,6 +704,8 @@ TEST(create_table_str_int) int index = hs_create_table (L, hs_str_int("c:", 15), hs_str_int(":)", 25)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_str(index, "c:"); checkval_int(15); @@ -635,6 +720,8 @@ TEST(create_table_str_num) int index = hs_create_table (L, hs_str_num("c:", 2.718), hs_str_num(":)", 1.618)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_str(index, "c:"); checkval_num(2.718); @@ -649,6 +736,8 @@ TEST(create_table_str_str) int index = hs_create_table (L, hs_str_str("c:", "hello"), hs_str_str(":)", "world")); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_str(index, "c:"); checkval_str("hello"); @@ -669,6 +758,8 @@ TEST(create_table_str_tbl) int index = hs_create_table (L, hs_str_tbl("c:", value1), hs_str_tbl(":)", value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(value1); load(value2); @@ -692,6 +783,8 @@ TEST(create_table_str_func) int index = hs_create_table (L, hs_str_func("c:", value1), hs_str_func(":)", value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(value1); load(value2); @@ -710,6 +803,8 @@ TEST(create_table_str_cfunc) int index = hs_create_table (L, hs_str_cfunc("c:", testfunc1), hs_str_cfunc(":)", testfunc2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_str(index, "c:"); checkval_cfunc(testfunc1); @@ -731,6 +826,8 @@ TEST(create_table_str_user) int index = hs_create_table (L, hs_str_user("c:", user1), hs_str_user(":)", user2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -753,6 +850,8 @@ TEST(create_table_str_light) int index = hs_create_table (L, hs_str_light("c:", light1), hs_str_light(":)", light2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_str(index, "c:"); checkval_light(light1); @@ -781,6 +880,8 @@ TEST(create_table_tbl_bool) int index = hs_create_table (L, hs_tbl_bool(tbl1, true), hs_tbl_bool(tbl2, false)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(tbl1); load(tbl2); @@ -804,6 +905,8 @@ TEST(create_table_tbl_int) int index = hs_create_table (L, hs_tbl_int(tbl1, 15), hs_tbl_int(tbl2, 25)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(tbl1); load(tbl2); @@ -827,6 +930,8 @@ TEST(create_table_tbl_num) int index = hs_create_table (L, hs_tbl_num(tbl1, 2.718), hs_tbl_num(tbl2, 1.618)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(tbl1); load(tbl2); @@ -850,6 +955,8 @@ TEST(create_table_tbl_str) int index = hs_create_table (L, hs_tbl_str(tbl1, "hello"), hs_tbl_str(tbl2, "world")); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(tbl1); load(tbl2); @@ -879,6 +986,8 @@ TEST(create_table_tbl_tbl) int index = hs_create_table (L, hs_tbl_tbl(tbl1, value1), hs_tbl_tbl(tbl2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(tbl1); load(tbl2); @@ -911,6 +1020,8 @@ TEST(create_table_tbl_func) int index = hs_create_table (L, hs_tbl_func(tbl1, value1), hs_tbl_func(tbl2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(tbl1); load(tbl2); @@ -938,6 +1049,8 @@ TEST(create_table_tbl_cfunc) int index = hs_create_table (L, hs_tbl_cfunc(tbl1, testfunc1), hs_tbl_cfunc(tbl2, testfunc2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(tbl1); load(tbl2); @@ -968,6 +1081,8 @@ TEST(create_table_tbl_user) int index = hs_create_table (L, hs_tbl_user(tbl1, user1), hs_tbl_user(tbl2, user2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(tbl1); load(tbl2); @@ -999,6 +1114,8 @@ TEST(create_table_tbl_light) int index = hs_create_table (L, hs_tbl_light(tbl1, light1), hs_tbl_light(tbl2, light2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(tbl1); load(tbl2); @@ -1030,6 +1147,8 @@ TEST(create_table_func_bool) int index = hs_create_table (L, hs_func_bool(func1, true), hs_func_bool(func2, false)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(func1); load(func2); @@ -1053,6 +1172,8 @@ TEST(create_table_func_int) int index = hs_create_table (L, hs_func_int(func1, 15), hs_func_int(func2, 25)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(func1); load(func2); @@ -1076,6 +1197,8 @@ TEST(create_table_func_num) int index = hs_create_table (L, hs_func_num(func1, 2.718), hs_func_num(func2, 1.618)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(func1); load(func2); @@ -1099,6 +1222,8 @@ TEST(create_table_func_str) int index = hs_create_table (L, hs_func_str(func1, "hello"), hs_func_str(func2, "world")); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(func1); load(func2); @@ -1128,6 +1253,8 @@ TEST(create_table_func_tbl) int index = hs_create_table (L, hs_func_tbl(func1, value1), hs_func_tbl(func2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(func1); load(func2); @@ -1160,6 +1287,8 @@ TEST(create_table_func_func) int index = hs_create_table (L, hs_func_func(func1, value1), hs_func_func(func2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(func1); load(func2); @@ -1187,6 +1316,8 @@ TEST(create_table_func_cfunc) int index = hs_create_table (L, hs_func_cfunc(func1, testfunc1), hs_func_cfunc(func2, testfunc2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(func1); load(func2); @@ -1217,6 +1348,8 @@ TEST(create_table_func_user) int index = hs_create_table (L, hs_func_user(func1, user1), hs_func_user(func2, user2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(func1); load(func2); @@ -1248,6 +1381,8 @@ TEST(create_table_func_light) int index = hs_create_table (L, hs_func_light(func1, light1), hs_func_light(func2, light2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(func1); load(func2); @@ -1273,6 +1408,8 @@ TEST(create_table_cfunc_bool) int index = hs_create_table (L, hs_cfunc_bool(testfunc1, true), hs_cfunc_bool(testfunc2, true)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_cfunc(index, testfunc1); checkval_bool(true); @@ -1287,6 +1424,8 @@ TEST(create_table_cfunc_int) int index = hs_create_table (L, hs_cfunc_int(testfunc1, 15), hs_cfunc_int(testfunc2, 25)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_cfunc(index, testfunc1); checkval_int(15); @@ -1301,6 +1440,8 @@ TEST(create_table_cfunc_num) int index = hs_create_table (L, hs_cfunc_num(testfunc1, 2.718), hs_cfunc_num(testfunc2, 1.618)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_cfunc(index, testfunc1); checkval_num(2.718); @@ -1315,6 +1456,8 @@ TEST(create_table_cfunc_str) int index = hs_create_table (L, hs_cfunc_str(testfunc1, "hello"), hs_cfunc_str(testfunc2, "world")); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_cfunc(index, testfunc1); checkval_str("hello"); @@ -1335,6 +1478,8 @@ TEST(create_table_cfunc_tbl) int index = hs_create_table (L, hs_cfunc_tbl(testfunc1, value1), hs_cfunc_tbl(testfunc2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(value1); load(value2); @@ -1358,6 +1503,8 @@ TEST(create_table_cfunc_func) int index = hs_create_table (L, hs_cfunc_func(testfunc1, value1), hs_cfunc_func(testfunc2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(value1); load(value2); @@ -1376,6 +1523,8 @@ TEST(create_table_cfunc_cfunc) int index = hs_create_table (L, hs_cfunc_cfunc(testfunc1, testfunc1), hs_cfunc_cfunc(testfunc2, testfunc2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_cfunc(index, testfunc1); checkval_cfunc(testfunc1); @@ -1397,6 +1546,8 @@ TEST(create_table_cfunc_user) int index = hs_create_table (L, hs_cfunc_user(testfunc1, user1), hs_cfunc_user(testfunc2, user2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -1419,6 +1570,8 @@ TEST(create_table_cfunc_light) int index = hs_create_table (L, hs_cfunc_light(testfunc1, light1), hs_cfunc_light(testfunc2, light2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_cfunc(index, testfunc1); checkval_light(light1); @@ -1447,6 +1600,8 @@ TEST(create_table_user_bool) int index = hs_create_table (L, hs_user_bool(user1, true), hs_user_bool(user2, false)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -1470,6 +1625,8 @@ TEST(create_table_user_int) int index = hs_create_table (L, hs_user_int(user1, 15), hs_user_int(user2, 25)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -1493,6 +1650,8 @@ TEST(create_table_user_num) int index = hs_create_table (L, hs_user_num(user1, 2.718), hs_user_num(user2, 1.618)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -1516,6 +1675,8 @@ TEST(create_table_user_str) int index = hs_create_table (L, hs_user_str(user1, "hello"), hs_user_str(user2, "world")); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -1545,6 +1706,8 @@ TEST(create_table_user_tbl) int index = hs_create_table (L, hs_user_tbl(user1, value1), hs_user_tbl(user2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -1577,6 +1740,8 @@ TEST(create_table_user_func) int index = hs_create_table (L, hs_user_func(user1, value1), hs_user_func(user2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -1604,6 +1769,8 @@ TEST(create_table_user_cfunc) int index = hs_create_table (L, hs_user_cfunc(user1, testfunc1), hs_user_cfunc(user2, testfunc2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -1634,6 +1801,8 @@ TEST(create_table_user_user) int index = hs_create_table (L, hs_user_user(user1, value1), hs_user_user(user2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -1665,6 +1834,8 @@ TEST(create_table_user_light) int index = hs_create_table (L, hs_user_light(user1, light1), hs_user_light(user2, light2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -1696,6 +1867,8 @@ TEST(create_table_light_bool) int index = hs_create_table (L, hs_light_bool(light1, true), hs_light_bool(light2, true)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_light(index, light1); checkval_bool(true); @@ -1716,6 +1889,8 @@ TEST(create_table_light_int) int index = hs_create_table (L, hs_light_int(light1, 15), hs_light_int(light2, 25)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_light(index, light1); checkval_int(15); @@ -1736,6 +1911,8 @@ TEST(create_table_light_num) int index = hs_create_table (L, hs_light_num(light1, 2.718), hs_light_num(light2, 1.618)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_light(index, light1); checkval_num(2.718); @@ -1756,6 +1933,8 @@ TEST(create_table_light_str) int index = hs_create_table (L, hs_light_str(light1, "hello"), hs_light_str(light2, "world")); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_light(index, light1); checkval_str("hello"); @@ -1781,6 +1960,8 @@ TEST(create_table_light_tbl) int index = hs_create_table (L, hs_light_tbl(light1, value1), hs_light_tbl(light2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(value1); load(value2); @@ -1809,6 +1990,8 @@ TEST(create_table_light_func) int index = hs_create_table (L, hs_light_func(light1, value1), hs_light_func(light2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(value1); load(value2); @@ -1833,6 +2016,8 @@ TEST(create_table_light_cfunc) int index = hs_create_table (L, hs_light_cfunc(light1, testfunc1), hs_light_cfunc(light2, testfunc2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_light(index, light1); checkval_cfunc(testfunc1); @@ -1859,6 +2044,8 @@ TEST(create_table_light_user) int index = hs_create_table (L, hs_light_user(light1, user1), hs_light_user(light2, user2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); load(user1); load(user2); @@ -1887,6 +2074,8 @@ TEST(create_table_light_light) int index = hs_create_table (L, hs_light_light(light1, value1), hs_light_light(light2, value2)); mu_assert_equal(oldtop + 1, lua_gettop(L)); + mu_assert_equal(index, lua_gettop(L)); + mu_assert_equal(lua_type(L, index), LUA_TTABLE); loadkey_light(index, light1); checkval_light(value1); |