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.
@@ -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"
@@ -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;
@@ -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