From 9c14b5e416e1ca3ebed37c4ceb860579124ac29f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 2 Jun 2000 16:10:01 -0300 Subject: [PATCH] new test function to list strings from a function --- ltests.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ltests.c b/ltests.c index f8464261..49b5195d 100644 --- a/ltests.c +++ b/ltests.c @@ -1,5 +1,5 @@ /* -** $Id: ltests.c,v 1.21 2000/05/26 19:17:57 roberto Exp roberto $ +** $Id: ltests.c,v 1.22 2000/06/02 17:06:42 roberto Exp roberto $ ** Internal Module for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -104,6 +104,24 @@ static void listcode (void) { lua_pushobject(t); } + +static void liststrings (void) { + lua_Object o = luaL_nonnullarg(1); + lua_Object t = lua_createtable(); + Proto *p; + int i; + luaL_arg_check(ttype(o) == TAG_LCLOSURE, 1, "Lua function expected"); + p = clvalue(o)->f.l; + for (i=0; inkstr; i++) { + lua_pushobject(t); + lua_pushnumber(i+1); + lua_pushstring(p->kstr[i]->str); + lua_settable(); + } + lua_pushobject(t); +} + + /* }====================================================== */ @@ -377,6 +395,7 @@ static const struct luaL_reg tests_funcs[] = { {"hash", (lua_CFunction)hash_query}, {"limits", (lua_CFunction)get_limits}, {"listcode", (lua_CFunction)listcode}, + {"liststrings", (lua_CFunction)liststrings}, {"querystr", (lua_CFunction)string_query}, {"querytab", (lua_CFunction)table_query}, {"testC", (lua_CFunction)testC},