summaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-07-11 11:00:59 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-07-11 11:00:59 -0300
commit64b57db377d9c08ee0f25997559462c2a3507f32 (patch)
tree9ca69d8989accd097fcdc398100dae051e69e2b9 /ltests.c
parent575637319e7f7328253268b6705d961ff62784ca (diff)
downloadlua-64b57db377d9c08ee0f25997559462c2a3507f32.tar.gz
lua-64b57db377d9c08ee0f25997559462c2a3507f32.tar.bz2
lua-64b57db377d9c08ee0f25997559462c2a3507f32.zip
new test function for conversion from num to int
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ltests.c b/ltests.c
index 4ed78f25..900f349e 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.24 2005/05/03 19:01:17 roberto Exp roberto $ 2** $Id: ltests.c,v 2.25 2005/05/31 14:34:02 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*/
@@ -691,6 +691,7 @@ static int s2d (lua_State *L) {
691 return 1; 691 return 1;
692} 692}
693 693
694
694static int d2s (lua_State *L) { 695static int d2s (lua_State *L) {
695 double d = luaL_checknumber(L, 1); 696 double d = luaL_checknumber(L, 1);
696 lua_pushlstring(L, cast(char *, &d), sizeof(d)); 697 lua_pushlstring(L, cast(char *, &d), sizeof(d));
@@ -698,6 +699,12 @@ static int d2s (lua_State *L) {
698} 699}
699 700
700 701
702static int num2int (lua_State *L) {
703 lua_pushinteger(L, lua_tointeger(L, 1));
704 return 1;
705}
706
707
701static int newstate (lua_State *L) { 708static int newstate (lua_State *L) {
702 void *ud; 709 void *ud;
703 lua_Alloc f = lua_getallocf(L, &ud); 710 lua_Alloc f = lua_getallocf(L, &ud);
@@ -1112,6 +1119,7 @@ static const struct luaL_reg tests_funcs[] = {
1112 {"unref", unref}, 1119 {"unref", unref},
1113 {"d2s", d2s}, 1120 {"d2s", d2s},
1114 {"s2d", s2d}, 1121 {"s2d", s2d},
1122 {"num2int", num2int},
1115 {"upvalue", upvalue}, 1123 {"upvalue", upvalue},
1116 {"newuserdata", newuserdata}, 1124 {"newuserdata", newuserdata},
1117 {"pushuserdata", pushuserdata}, 1125 {"pushuserdata", pushuserdata},