diff options
| author | Philipp Janda <siffiejoe@gmx.net> | 2018-07-27 07:35:24 +0200 |
|---|---|---|
| committer | Philipp Janda <siffiejoe@gmx.net> | 2018-07-27 07:35:24 +0200 |
| commit | c325be435c64be57cf2210fa6936af0d425d0ce0 (patch) | |
| tree | 0a6398c67346ff8df989994e7e29d4110c515889 /tests/testmod.c | |
| parent | 3c76f8f5edf602b023672f8d8f317b0eea2f1195 (diff) | |
| download | lua-compat-5.3-c325be435c64be57cf2210fa6936af0d425d0ce0.tar.gz lua-compat-5.3-c325be435c64be57cf2210fa6936af0d425d0ce0.tar.bz2 lua-compat-5.3-c325be435c64be57cf2210fa6936af0d425d0ce0.zip | |
Add an implementation of `lua_getextraspace()`.
Diffstat (limited to 'tests/testmod.c')
| -rw-r--r-- | tests/testmod.c | 16 |
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 | |||
| 70 | static 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 }, |
