[Tarantool-patches] [PATCH v2 luajit 11/30] test: adapt getlocal PUC test for vararg func

Sergey Kaplun skaplun at tarantool.org
Fri Mar 26 10:42:54 MSK 2021


Lua 5.1 interprets `...` in the vararg functions like an additional
first argument unlike LuaJIT does. So, `a:f()` function will not set
corresponding table `arg`, as test expects.

Implicit `arg` parameter for old-style vararg functions was finally
removed in Lua 5.2. The test is adapted from PUC-Rio Lua 5.2 test suite
by removing additional check for amountt of arguments via `arg.n`.
Lua 5.2 test suite is taken from
https://www.lua.org/tests/lua-5.2.0-tests.tar.gz.

Part of tarantool/tarantool#5845
Part of tarantool/tarantool#4473
---
 test/PUC-Lua-5.1-tests/db.lua | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/test/PUC-Lua-5.1-tests/db.lua b/test/PUC-Lua-5.1-tests/db.lua
index e5d8885..6985c29 100644
--- a/test/PUC-Lua-5.1-tests/db.lua
+++ b/test/PUC-Lua-5.1-tests/db.lua
@@ -300,7 +300,16 @@ debug.sethook(function (e)
 end, "c")
 
 a:f(1,2,3,4,5)
-assert(X.self == a and X.a == 1   and X.b == 2 and X.arg.n == 3 and X.c == nil)
+
+-- LuaJIT: Lua 5.1 interprets `...` in the vararg functions like
+-- an additional first argument unlike LuaJIT does.
+-- So, `a:f()` function will not set corresponding table `arg`,
+-- as test expects.
+-- Implicit `arg` parameter for old-style vararg functions was
+-- finally removed in Lua 5.2
+-- The test is adapted from PUC-Rio Lua 5.2 test suite by removing
+-- additional `arg.n == 3` check.
+assert(X.self == a and X.a == 1   and X.b == 2 and X.c == nil)
 assert(XX == 12)
 assert(debug.gethook() == nil)
 
-- 
2.31.0



More information about the Tarantool-patches mailing list