lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 64b57db377d9c08ee0f25997559462c2a3507f32
parent 575637319e7f7328253268b6705d961ff62784ca
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Mon, 11 Jul 2005 11:00:37 -0300

new test function for conversion from num to int

Diffstat:
Mltests.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git 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},