diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-29 11:57:10 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-29 11:57:10 -0300 |
commit | 9e74ca62d7c2ea1326d9970b76403b03442f5933 (patch) | |
tree | dcc8d0a0f824765bf9b526eea303a2a205ebccc0 | |
parent | d396562b5ec0f14728e9a67fac7a7f7b845e1a20 (diff) | |
download | lua-9e74ca62d7c2ea1326d9970b76403b03442f5933.tar.gz lua-9e74ca62d7c2ea1326d9970b76403b03442f5933.tar.bz2 lua-9e74ca62d7c2ea1326d9970b76403b03442f5933.zip |
tests for lua_is*
-rw-r--r-- | ltests.c | 38 |
1 files changed, 29 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.34 2000/08/15 20:14:27 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.35 2000/08/28 17:57:04 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 | */ |
@@ -324,19 +324,15 @@ static int testC (lua_State *L) { | |||
324 | else if EQ("newtable") { | 324 | else if EQ("newtable") { |
325 | lua_newtable(L); | 325 | lua_newtable(L); |
326 | } | 326 | } |
327 | else if EQ("closure") { | ||
328 | lua_CFunction f; | ||
329 | lua_getglobal(L, getname); | ||
330 | f = lua_tocfunction(L, -1); | ||
331 | lua_settop(L, -1); | ||
332 | lua_pushcclosure(L, f, getnum); | ||
333 | } | ||
334 | else if EQ("pushobject") { | 327 | else if EQ("pushobject") { |
335 | lua_pushobject(L, getnum); | 328 | lua_pushobject(L, getnum); |
336 | } | 329 | } |
337 | else if EQ("getglobal") { | 330 | else if EQ("getglobal") { |
338 | lua_getglobal(L, getname); | 331 | lua_getglobal(L, getname); |
339 | } | 332 | } |
333 | else if EQ("getglobals") { | ||
334 | lua_getglobals(L); | ||
335 | } | ||
340 | else if EQ("ref") { | 336 | else if EQ("ref") { |
341 | reg[getreg] = lua_ref(L, 0); | 337 | reg[getreg] = lua_ref(L, 0); |
342 | } | 338 | } |
@@ -380,6 +376,30 @@ static int testC (lua_State *L) { | |||
380 | else if EQ("type") { | 376 | else if EQ("type") { |
381 | lua_pushstring(L, lua_type(L, getnum)); | 377 | lua_pushstring(L, lua_type(L, getnum)); |
382 | } | 378 | } |
379 | else if EQ("isnil") { | ||
380 | lua_pushnumber(L, lua_isnil(L, getnum)); | ||
381 | } | ||
382 | else if EQ("isnull") { | ||
383 | lua_pushnumber(L, lua_isnull(L, getnum)); | ||
384 | } | ||
385 | else if EQ("isnumber") { | ||
386 | lua_pushnumber(L, lua_isnumber(L, getnum)); | ||
387 | } | ||
388 | else if EQ("isstring") { | ||
389 | lua_pushnumber(L, lua_isstring(L, getnum)); | ||
390 | } | ||
391 | else if EQ("istable") { | ||
392 | lua_pushnumber(L, lua_istable(L, getnum)); | ||
393 | } | ||
394 | else if EQ("isfunction") { | ||
395 | lua_pushnumber(L, lua_isfunction(L, getnum)); | ||
396 | } | ||
397 | else if EQ("iscfunction") { | ||
398 | lua_pushnumber(L, lua_iscfunction(L, getnum)); | ||
399 | } | ||
400 | else if EQ("isuserdata") { | ||
401 | lua_pushnumber(L, lua_isuserdata(L, getnum)); | ||
402 | } | ||
383 | else if EQ("equal") { | 403 | else if EQ("equal") { |
384 | int n1 = getreg; | 404 | int n1 = getreg; |
385 | int n2 = getnum; | 405 | int n2 = getnum; |
@@ -425,7 +445,7 @@ static int testC (lua_State *L) { | |||
425 | } | 445 | } |
426 | else { | 446 | else { |
427 | int i = 0; | 447 | int i = 0; |
428 | while (!lua_isnull(L, ++i)) | 448 | while (!lua_isnull(L1, ++i)) |
429 | lua_pushstring(L, lua_tostring(L1, i)); | 449 | lua_pushstring(L, lua_tostring(L1, i)); |
430 | } | 450 | } |
431 | } | 451 | } |