aboutsummaryrefslogtreecommitdiff
path: root/tests/testmod.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testmod.c')
-rw-r--r--tests/testmod.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/testmod.c b/tests/testmod.c
index cd56e76..345a8c9 100644
--- a/tests/testmod.c
+++ b/tests/testmod.c
@@ -63,6 +63,21 @@ static int test_getseti (lua_State *L) {
63} 63}
64 64
65 65
66#ifndef LUA_EXTRASPACE
67#define LUA_EXTRASPACE (sizeof(void*))
68#endif
69
70static int test_getextraspace (lua_State *L) {
71 size_t len = 0;
72 char const* s = luaL_optlstring(L, 1, NULL, &len);
73 void* p = lua_getextraspace(L);
74 lua_pushstring(L, p);
75 if (s)
76 memcpy(p, s, len > LUA_EXTRASPACE-1 ? LUA_EXTRASPACE-1 : len+1);
77 return 1;
78}
79
80
66/* additional tests for Lua5.1 */ 81/* additional tests for Lua5.1 */
67#define NUP 3 82#define NUP 3
68 83
@@ -307,6 +322,7 @@ static const luaL_Reg funcs[] = {
307 { "strtonum", test_str2num }, 322 { "strtonum", test_str2num },
308 { "requiref", test_requiref }, 323 { "requiref", test_requiref },
309 { "getseti", test_getseti }, 324 { "getseti", test_getseti },
325 { "extraspace", test_getextraspace },
310 { "newproxy", test_newproxy }, 326 { "newproxy", test_newproxy },
311 { "arith", test_arith }, 327 { "arith", test_arith },
312 { "compare", test_compare }, 328 { "compare", test_compare },