aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-05-03 10:36:19 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-05-03 10:36:19 -0300
commit01bded3d8cd88a2d7f472b45f706565f1a9ef3b1 (patch)
treeda7f8f1eb23d852a876c1c61f64015aa10805403
parent7c5786479c1d617ec7c133f2c2b955726436267a (diff)
downloadlua-01bded3d8cd88a2d7f472b45f706565f1a9ef3b1.tar.gz
lua-01bded3d8cd88a2d7f472b45f706565f1a9ef3b1.tar.bz2
lua-01bded3d8cd88a2d7f472b45f706565f1a9ef3b1.zip
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.
-rw-r--r--testes/attrib.lua2
-rw-r--r--testes/libs/lib22.c25
-rw-r--r--testes/libs/makefile4
3 files changed, 28 insertions, 3 deletions
diff --git a/testes/attrib.lua b/testes/attrib.lua
index 4adb42e0..b1a4a199 100644
--- a/testes/attrib.lua
+++ b/testes/attrib.lua
@@ -275,7 +275,7 @@ else
275 -- check correct access to global environment and correct 275 -- check correct access to global environment and correct
276 -- parameters 276 -- parameters
277 assert(_ENV.x == "lib2-v2" and _ENV.y == DC"lib2-v2") 277 assert(_ENV.x == "lib2-v2" and _ENV.y == DC"lib2-v2")
278 assert(lib2.id("x") == "x") 278 assert(lib2.id("x") == true) -- a different "id" implementation
279 279
280 -- test C submodules 280 -- test C submodules
281 local fs, ext = require"lib1.sub" 281 local fs, ext = require"lib1.sub"
diff --git a/testes/libs/lib22.c b/testes/libs/lib22.c
new file mode 100644
index 00000000..8e656502
--- /dev/null
+++ b/testes/libs/lib22.c
@@ -0,0 +1,25 @@
1#include "lua.h"
2#include "lauxlib.h"
3
4static int id (lua_State *L) {
5 lua_pushboolean(L, 1);
6 lua_insert(L, 1);
7 return lua_gettop(L);
8}
9
10
11static const struct luaL_Reg funcs[] = {
12 {"id", id},
13 {NULL, NULL}
14};
15
16
17LUAMOD_API int luaopen_lib2 (lua_State *L) {
18 lua_settop(L, 2);
19 lua_setglobal(L, "y"); /* y gets 2nd parameter */
20 lua_setglobal(L, "x"); /* x gets 1st parameter */
21 luaL_newlib(L, funcs);
22 return 1;
23}
24
25
diff --git a/testes/libs/makefile b/testes/libs/makefile
index acff4848..698f8984 100644
--- a/testes/libs/makefile
+++ b/testes/libs/makefile
@@ -23,5 +23,5 @@ lib2.so: lib2.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h
23lib21.so: lib21.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h 23lib21.so: lib21.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h
24 $(CC) $(CFLAGS) -o lib21.so lib21.c 24 $(CC) $(CFLAGS) -o lib21.so lib21.c
25 25
26lib2-v2.so: lib2.so 26lib2-v2.so: lib21.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h
27 cp lib2.so ./lib2-v2.so 27 $(CC) $(CFLAGS) -o lib2-v2.so lib22.c