From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id DFF916BD2D; Tue, 13 Apr 2021 16:33:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DFF916BD2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618320812; bh=Hbp3I6J2f23/pmaioUzLpUCoIn3ys40gZ1q6Q1dUlfY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=fwO/IxSox7JsysBPaYBtBDav2+1liJTeoyDC0JUB9IjY2liBAR3f5WJ+QVBSzqOF2 iVpBLdb0N6+rqhKGGailG+jde4Ln9ksKq72se4N8tBFsFyP1kINgGvrLqHnXhotYoc kbtcplrqiQ0EZ0EtyX5P0bZn+GNGhuPnWYXX+3i8= Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 696E56B95A for ; Tue, 13 Apr 2021 16:28:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 696E56B95A Received: by smtp48.i.mail.ru with esmtpa (envelope-from ) id 1lWJ5q-0000dj-Hp; Tue, 13 Apr 2021 16:28:38 +0300 To: Sergey Ostanevich , Igor Munkin Date: Tue, 13 Apr 2021 16:27:10 +0300 Message-Id: <10d1caacaa2fe63d52e0155d85436de665e2b59a.1618320000.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E7480EBD5CA77A668ECB87DA2124B0A8E6609182A05F538085040D02F38B2128B0DB4615BE42777ECD7F91C29C01F9F80CBDDB5F5CC603B3DE060 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79145AB6E9E75F07EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637BA5555A0C16230F4EA1F7E6F0F101C67CDEEF6D7F21E0D1D9295C2E9FA3191EE1B59CA4C82EFA658B6F50DD690516A46E78BB1BE6C638BC9F6B57BC7E64490618DEB871D839B73339E8FC8737B5C2249D082881546D93491CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481F9449624AB7ADAF372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F4AF35CDC743633045E1C53F199C2BB95B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CB69F9342289A40B38A6FFB50635FB46A5629D9AB4653B4F29C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF0417BEADF48D1460699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34BC3EEE75EF3BACCF12344D8DE14CDF1E3CB694066A70A61397E64D13A7D2FFE34E522EC585EA83F11D7E09C32AA3244C5BB45697B6200DEE4E938EE848F6E40A8894E9C85370243E927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnA7/qPBUIXHPUCQWrcW0Tw== X-Mailru-Sender: 3B9A0136629DC91206CBC582EFEF4CB49C1A2220742C2AB10CB0C4669B49AB2CD537AA6D4973CF86F2400F607609286E924004A7DEC283833C7120B22964430C52B393F8C72A41A89437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit v3 10/29] test: adapt PUC-Rio tests with vararg functions X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Lua 5.1 interprets `...` in the vararg functions as an additional local argument unlike LuaJIT does. This behaviour is extension from Lua 5.2. This patch adapted tests considering behaviour of LuaJIT and Lua 5.2. The tests are adapted like it done in Lua 5.2 test suite taken from https://www.lua.org/tests/lua-5.2.0-tests.tar.gz. Tests in the following files are adapted: * db.lua * vararg.lua Resolves tarantool/tarantool#5712 Part of tarantool/tarantool#5694 Part of tarantool/tarantool#5845 Part of tarantool/tarantool#4473 --- test/PUC-Rio-Lua-5.1-tests/db.lua | 7 +++++++ test/PUC-Rio-Lua-5.1-tests/vararg.lua | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/test/PUC-Rio-Lua-5.1-tests/db.lua b/test/PUC-Rio-Lua-5.1-tests/db.lua index c9741981..82d1cfa6 100644 --- a/test/PUC-Rio-Lua-5.1-tests/db.lua +++ b/test/PUC-Rio-Lua-5.1-tests/db.lua @@ -224,6 +224,13 @@ assert(debug.getinfo(1, "l").currentline == L+11) -- check count of lines function g(...) + -- LuaJIT: Lua 5.1 interprets `...` in the vararg functions like + -- an additional local argument unlike LuaJIT does. + -- This extension is from Lua 5.2. + -- See also https://github.com/tarantool/tarantool/issues/5694. + -- Test is adapted from PUC-Rio Lua 5.2 test suite by adding + -- additional variable `arg`. + local arg = {...} do local a,b,c; a=math.sin(40); end local feijao local AAAA,B = "xuxu", "mamão" diff --git a/test/PUC-Rio-Lua-5.1-tests/vararg.lua b/test/PUC-Rio-Lua-5.1-tests/vararg.lua index ae068fac..a9c3a6a2 100644 --- a/test/PUC-Rio-Lua-5.1-tests/vararg.lua +++ b/test/PUC-Rio-Lua-5.1-tests/vararg.lua @@ -2,9 +2,14 @@ print('testing vararg') _G.arg = nil +-- LuaJIT: Lua 5.1 interprets ... in the vararg functions as an +-- additional local argument, unlike LuaJIT does. All extra +-- arguments are set into `arg` variable. This extension +-- is from Lua 5.2. +-- See also https://github.com/tarantool/tarantool/issues/5712. +-- Test is adapted from PUC-Rio Lua 5.2 test suite. function f(a, ...) - assert(type(arg) == 'table') - assert(type(arg.n) == 'number') + local arg = {n = select('#', ...), ...} for i=1,arg.n do assert(a[i]==arg[i]) end return arg.n end @@ -17,7 +22,9 @@ function c12 (...) return res, 2 end -function vararg (...) return arg end +-- LuaJIT: Test chunk is adapted from PUC-Rio Lua 5.2 test suite. +-- See the comment above. +function vararg (...) return {n = select('#', ...), ...} end local call = function (f, args) return f(unpack(args, 1, args.n)) end @@ -42,7 +49,9 @@ a = call(print, {'+'}) assert(a == nil) local t = {1, 10} -function t:f (...) return self[arg[1]]+arg.n end +-- LuaJIT: Test chunk is adapted from PUC-Rio Lua 5.2 test suite. +-- See the comment above. +function t:f (...) local arg = {...}; return self[...]+#arg end assert(t:f(1,4) == 3 and t:f(2) == 11) print('+') -- 2.31.0