lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 01bded3d8cd88a2d7f472b45f706565f1a9ef3b1
parent 7c5786479c1d617ec7c133f2c2b955726436267a
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Fri,  3 May 2019 10:35:52 -0300

File 'lib2-v2.so' generated from its own source

Instead of being a copy of 'lib2.so', 'lib2-v2.so' has its own source
file ('lib22.c'), so that the test can distinguish both libraries.

Diffstat:
Mtestes/attrib.lua | 2+-
Atestes/libs/lib22.c | 25+++++++++++++++++++++++++
Mtestes/libs/makefile | 4++--
3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/testes/attrib.lua b/testes/attrib.lua @@ -275,7 +275,7 @@ else -- check correct access to global environment and correct -- parameters assert(_ENV.x == "lib2-v2" and _ENV.y == DC"lib2-v2") - assert(lib2.id("x") == "x") + assert(lib2.id("x") == true) -- a different "id" implementation -- test C submodules local fs, ext = require"lib1.sub" diff --git a/testes/libs/lib22.c b/testes/libs/lib22.c @@ -0,0 +1,25 @@ +#include "lua.h" +#include "lauxlib.h" + +static int id (lua_State *L) { + lua_pushboolean(L, 1); + lua_insert(L, 1); + 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; +} + + diff --git a/testes/libs/makefile b/testes/libs/makefile @@ -23,5 +23,5 @@ lib2.so: lib2.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h lib21.so: lib21.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h $(CC) $(CFLAGS) -o lib21.so lib21.c -lib2-v2.so: lib2.so - cp lib2.so ./lib2-v2.so +lib2-v2.so: lib21.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h + $(CC) $(CFLAGS) -o lib2-v2.so lib22.c