aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-02 16:10:01 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-02 16:10:01 -0300
commit9c14b5e416e1ca3ebed37c4ceb860579124ac29f (patch)
treeef660a076ee64a28ff38fd1b8ecd4c7359ae2892
parent6b9bf492651231786274a1b04dc89a01efc7b900 (diff)
downloadlua-9c14b5e416e1ca3ebed37c4ceb860579124ac29f.tar.gz
lua-9c14b5e416e1ca3ebed37c4ceb860579124ac29f.tar.bz2
lua-9c14b5e416e1ca3ebed37c4ceb860579124ac29f.zip
new test function to list strings from a function
-rw-r--r--ltests.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/ltests.c b/ltests.c
index f8464261..49b5195d 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 1.21 2000/05/26 19:17:57 roberto Exp roberto $ 2** $Id: ltests.c,v 1.22 2000/06/02 17:06:42 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*/
@@ -104,6 +104,24 @@ static void listcode (void) {
104 lua_pushobject(t); 104 lua_pushobject(t);
105} 105}
106 106
107
108static void liststrings (void) {
109 lua_Object o = luaL_nonnullarg(1);
110 lua_Object t = lua_createtable();
111 Proto *p;
112 int i;
113 luaL_arg_check(ttype(o) == TAG_LCLOSURE, 1, "Lua function expected");
114 p = clvalue(o)->f.l;
115 for (i=0; i<p->nkstr; i++) {
116 lua_pushobject(t);
117 lua_pushnumber(i+1);
118 lua_pushstring(p->kstr[i]->str);
119 lua_settable();
120 }
121 lua_pushobject(t);
122}
123
124
107/* }====================================================== */ 125/* }====================================================== */
108 126
109 127
@@ -377,6 +395,7 @@ static const struct luaL_reg tests_funcs[] = {
377 {"hash", (lua_CFunction)hash_query}, 395 {"hash", (lua_CFunction)hash_query},
378 {"limits", (lua_CFunction)get_limits}, 396 {"limits", (lua_CFunction)get_limits},
379 {"listcode", (lua_CFunction)listcode}, 397 {"listcode", (lua_CFunction)listcode},
398 {"liststrings", (lua_CFunction)liststrings},
380 {"querystr", (lua_CFunction)string_query}, 399 {"querystr", (lua_CFunction)string_query},
381 {"querytab", (lua_CFunction)table_query}, 400 {"querytab", (lua_CFunction)table_query},
382 {"testC", (lua_CFunction)testC}, 401 {"testC", (lua_CFunction)testC},