diff options
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 43 |
1 files changed, 42 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.10 2004/07/09 18:23:17 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.11 2004/08/24 20:12:06 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -1029,6 +1029,44 @@ static int coresume (lua_State *L) { | |||
1029 | 1029 | ||
1030 | 1030 | ||
1031 | 1031 | ||
1032 | /* | ||
1033 | ** {====================================================== | ||
1034 | ** tests auxlib functions | ||
1035 | ** ======================================================= | ||
1036 | */ | ||
1037 | |||
1038 | static int auxgsub (lua_State *L) { | ||
1039 | const char *s1 = luaL_checkstring(L, 1); | ||
1040 | const char *s2 = luaL_checkstring(L, 2); | ||
1041 | const char *s3 = luaL_checkstring(L, 3); | ||
1042 | lua_settop(L, 3); | ||
1043 | luaL_gsub(L, s1, s2, s3); | ||
1044 | lua_assert(lua_gettop(L) == 4); | ||
1045 | return 1; | ||
1046 | } | ||
1047 | |||
1048 | |||
1049 | static int auxgetf (lua_State *L) { | ||
1050 | const char *s = luaL_checkstring(L, 1); | ||
1051 | lua_settop(L, 2); | ||
1052 | lua_pushstring(L, luaL_getfield(L, s)); | ||
1053 | lua_assert(lua_gettop(L) == 3); | ||
1054 | return 2; | ||
1055 | } | ||
1056 | |||
1057 | |||
1058 | static int auxsetf (lua_State *L) { | ||
1059 | const char *s = luaL_checkstring(L, 1); | ||
1060 | lua_settop(L, 3); | ||
1061 | lua_pushstring(L, luaL_setfield(L, s)); | ||
1062 | lua_assert(lua_gettop(L) == 2); | ||
1063 | return 1; | ||
1064 | } | ||
1065 | |||
1066 | /* }====================================================== */ | ||
1067 | |||
1068 | |||
1069 | |||
1032 | static const struct luaL_reg tests_funcs[] = { | 1070 | static const struct luaL_reg tests_funcs[] = { |
1033 | {"hash", hash_query}, | 1071 | {"hash", hash_query}, |
1034 | {"limits", get_limits}, | 1072 | {"limits", get_limits}, |
@@ -1063,6 +1101,9 @@ static const struct luaL_reg tests_funcs[] = { | |||
1063 | {"totalmem", mem_query}, | 1101 | {"totalmem", mem_query}, |
1064 | {"resume", coresume}, | 1102 | {"resume", coresume}, |
1065 | {"setyhook", setyhook}, | 1103 | {"setyhook", setyhook}, |
1104 | {"gsub", auxgsub}, | ||
1105 | {"getfield", auxgetf}, | ||
1106 | {"setfield", auxsetf}, | ||
1066 | {NULL, NULL} | 1107 | {NULL, NULL} |
1067 | }; | 1108 | }; |
1068 | 1109 | ||