From 64b57db377d9c08ee0f25997559462c2a3507f32 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 11 Jul 2005 11:00:59 -0300 Subject: new test function for conversion from num to int --- ltests.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'ltests.c') diff --git a/ltests.c b/ltests.c index 4ed78f25..900f349e 100644 --- a/ltests.c +++ b/ltests.c @@ -1,5 +1,5 @@ /* -** $Id: ltests.c,v 2.24 2005/05/03 19:01:17 roberto Exp roberto $ +** $Id: ltests.c,v 2.25 2005/05/31 14:34:02 roberto Exp roberto $ ** Internal Module for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -691,6 +691,7 @@ static int s2d (lua_State *L) { return 1; } + static int d2s (lua_State *L) { double d = luaL_checknumber(L, 1); lua_pushlstring(L, cast(char *, &d), sizeof(d)); @@ -698,6 +699,12 @@ static int d2s (lua_State *L) { } +static int num2int (lua_State *L) { + lua_pushinteger(L, lua_tointeger(L, 1)); + return 1; +} + + static int newstate (lua_State *L) { void *ud; lua_Alloc f = lua_getallocf(L, &ud); @@ -1112,6 +1119,7 @@ static const struct luaL_reg tests_funcs[] = { {"unref", unref}, {"d2s", d2s}, {"s2d", s2d}, + {"num2int", num2int}, {"upvalue", upvalue}, {"newuserdata", newuserdata}, {"pushuserdata", pushuserdata}, -- cgit v1.2.3-55-g6feb