aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/compat53/tests/testmod.c
diff options
context:
space:
mode:
authorLibravatarLibravatar daurnimator <quae@daurnimator.com> 2020-07-09 22:56:47 +1000
committerLibravatarLibravatar daurnimator <quae@daurnimator.com> 2020-07-09 22:56:47 +1000
commit1baeacb17e1dccc843a0f25579a22c68d5a8a1e1 (patch)
treeb68489fd969b5762e9ebf34b5b9c6076879a8daa /vendor/compat53/tests/testmod.c
parentd826b20c71398e2e77c1cfe4e90086d8a72f3414 (diff)
parentde60088d19ff006b4feceb780e97a15611fe2905 (diff)
downloadluaossl-1baeacb17e1dccc843a0f25579a22c68d5a8a1e1.tar.gz
luaossl-1baeacb17e1dccc843a0f25579a22c68d5a8a1e1.tar.bz2
luaossl-1baeacb17e1dccc843a0f25579a22c68d5a8a1e1.zip
Merge lua-compat-5.3 v0.9
Diffstat (limited to 'vendor/compat53/tests/testmod.c')
-rw-r--r--vendor/compat53/tests/testmod.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/vendor/compat53/tests/testmod.c b/vendor/compat53/tests/testmod.c
index cd56e76..0d73ed4 100644
--- a/vendor/compat53/tests/testmod.c
+++ b/vendor/compat53/tests/testmod.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
#include "compat-5.3.h"
@@ -63,6 +64,21 @@ static int test_getseti (lua_State *L) {
}
+#ifndef LUA_EXTRASPACE
+#define LUA_EXTRASPACE (sizeof(void*))
+#endif
+
+static int test_getextraspace (lua_State *L) {
+ size_t len = 0;
+ char const* s = luaL_optlstring(L, 1, NULL, &len);
+ char* p = (char*)lua_getextraspace(L);
+ lua_pushstring(L, p);
+ if (s)
+ memcpy(p, s, len > LUA_EXTRASPACE-1 ? LUA_EXTRASPACE-1 : len+1);
+ return 1;
+}
+
+
/* additional tests for Lua5.1 */
#define NUP 3
@@ -270,6 +286,7 @@ static int test_buffer (lua_State *L) {
static int test_exec (lua_State *L) {
const char *cmd = luaL_checkstring(L, 1);
+ errno = 0;
return luaL_execresult(L, system(cmd));
}
@@ -307,6 +324,7 @@ static const luaL_Reg funcs[] = {
{ "strtonum", test_str2num },
{ "requiref", test_requiref },
{ "getseti", test_getseti },
+ { "extraspace", test_getextraspace },
{ "newproxy", test_newproxy },
{ "arith", test_arith },
{ "compare", test_compare },