Added manual and tests for version 5.4-w2

This commit is contained in:
Roberto Ierusalimschy
2018-07-09 12:33:01 -03:00
parent f59e6a93c0
commit 7c519dfbd0
37 changed files with 22260 additions and 0 deletions

44
testes/libs/lib1.c Normal file
View File

@@ -0,0 +1,44 @@
#include "lua.h"
#include "lauxlib.h"
static int id (lua_State *L) {
return lua_gettop(L);
}
static const struct luaL_Reg funcs[] = {
{"id", id},
{NULL, NULL}
};
/* function used by lib11.c */
LUAMOD_API int lib1_export (lua_State *L) {
lua_pushstring(L, "exported");
return 1;
}
LUAMOD_API int onefunction (lua_State *L) {
luaL_checkversion(L);
lua_settop(L, 2);
lua_pushvalue(L, 1);
return 2;
}
LUAMOD_API int anotherfunc (lua_State *L) {
luaL_checkversion(L);
lua_pushfstring(L, "%d%%%d\n", (int)lua_tointeger(L, 1),
(int)lua_tointeger(L, 2));
return 1;
}
LUAMOD_API int luaopen_lib1_sub (lua_State *L) {
lua_setglobal(L, "y"); /* 2nd arg: extra value (file name) */
lua_setglobal(L, "x"); /* 1st arg: module name */
luaL_newlib(L, funcs);
return 1;
}

10
testes/libs/lib11.c Normal file
View File

@@ -0,0 +1,10 @@
#include "lua.h"
/* function from lib1.c */
int lib1_export (lua_State *L);
LUAMOD_API int luaopen_lib11 (lua_State *L) {
return lib1_export(L);
}

23
testes/libs/lib2.c Normal file
View File

@@ -0,0 +1,23 @@
#include "lua.h"
#include "lauxlib.h"
static int id (lua_State *L) {
return lua_gettop(L);
}
static const struct luaL_Reg funcs[] = {
{"id", id},
{NULL, NULL}
};
LUAMOD_API int luaopen_lib2 (lua_State *L) {
lua_settop(L, 2);
lua_setglobal(L, "y"); /* y gets 2nd parameter */
lua_setglobal(L, "x"); /* x gets 1st parameter */
luaL_newlib(L, funcs);
return 1;
}

10
testes/libs/lib21.c Normal file
View File

@@ -0,0 +1,10 @@
#include "lua.h"
int luaopen_lib2 (lua_State *L);
LUAMOD_API int luaopen_lib21 (lua_State *L) {
return luaopen_lib2(L);
}

26
testes/libs/makefile Normal file
View File

@@ -0,0 +1,26 @@
# change this variable to point to the directory with Lua headers
# of the version being tested
LUA_DIR = ../../
CC = gcc
# compilation should generate Dynamic-Link Libraries
CFLAGS = -Wall -std=gnu99 -O2 -I$(LUA_DIR) -fPIC -shared
# libraries used by the tests
all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so
lib1.so: lib1.c
$(CC) $(CFLAGS) -o lib1.so lib1.c
lib11.so: lib11.c
$(CC) $(CFLAGS) -o lib11.so lib11.c
lib2.so: lib2.c
$(CC) $(CFLAGS) -o lib2.so lib2.c
lib21.so: lib21.c
$(CC) $(CFLAGS) -o lib21.so lib21.c
lib2-v2.so: lib2.so
mv lib2.so ./lib2-v2.so