diff options
Diffstat (limited to 'ltests.c')
| -rw-r--r-- | ltests.c | 19 |
1 files changed, 17 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 1.40 2000/09/05 19:33:32 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.41 2000/09/11 19:42:57 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 | */ |
| @@ -25,6 +25,7 @@ | |||
| 25 | #include "lstring.h" | 25 | #include "lstring.h" |
| 26 | #include "ltable.h" | 26 | #include "ltable.h" |
| 27 | #include "luadebug.h" | 27 | #include "luadebug.h" |
| 28 | #include "lualib.h" | ||
| 28 | 29 | ||
| 29 | 30 | ||
| 30 | void luaB_opentests (lua_State *L); | 31 | void luaB_opentests (lua_State *L); |
| @@ -275,6 +276,19 @@ static int newstate (lua_State *L) { | |||
| 275 | return 1; | 276 | return 1; |
| 276 | } | 277 | } |
| 277 | 278 | ||
| 279 | static int loadlib (lua_State *L) { | ||
| 280 | lua_State *L1 = (lua_State *)lua_touserdata(L, 1); | ||
| 281 | switch (*luaL_check_string(L, 2)) { | ||
| 282 | case 'm': lua_mathlibopen(L1); break; | ||
| 283 | case 's': lua_strlibopen(L1); break; | ||
| 284 | case 'i': lua_iolibopen(L1); break; | ||
| 285 | case 'd': lua_dblibopen(L1); break; | ||
| 286 | case 'b': lua_baselibopen(L1); break; | ||
| 287 | default: luaL_argerror(L, 2, "invalid option"); | ||
| 288 | } | ||
| 289 | return 0; | ||
| 290 | } | ||
| 291 | |||
| 278 | static int closestate (lua_State *L) { | 292 | static int closestate (lua_State *L) { |
| 279 | luaL_checktype(L, 1, "userdata"); | 293 | luaL_checktype(L, 1, "userdata"); |
| 280 | lua_close((lua_State *)lua_touserdata(L, 1)); | 294 | lua_close((lua_State *)lua_touserdata(L, 1)); |
| @@ -405,7 +419,7 @@ static int testC (lua_State *L) { | |||
| 405 | else if EQ("call") { | 419 | else if EQ("call") { |
| 406 | int narg = getnum; | 420 | int narg = getnum; |
| 407 | int nres = getnum; | 421 | int nres = getnum; |
| 408 | if (lua_call(L, narg, nres)) lua_error(L, NULL); | 422 | lua_rawcall(L, narg, nres); |
| 409 | } | 423 | } |
| 410 | else if EQ("type") { | 424 | else if EQ("type") { |
| 411 | lua_pushstring(L, lua_type(L, getnum)); | 425 | lua_pushstring(L, lua_type(L, getnum)); |
| @@ -425,6 +439,7 @@ static const struct luaL_reg tests_funcs[] = { | |||
| 425 | {"listcode", listcode}, | 439 | {"listcode", listcode}, |
| 426 | {"liststrings", liststrings}, | 440 | {"liststrings", liststrings}, |
| 427 | {"listlocals", listlocals}, | 441 | {"listlocals", listlocals}, |
| 442 | {"loadlib", loadlib}, | ||
| 428 | {"querystr", string_query}, | 443 | {"querystr", string_query}, |
| 429 | {"querytab", table_query}, | 444 | {"querytab", table_query}, |
| 430 | {"testC", testC}, | 445 | {"testC", testC}, |
