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 76BDE6B467; Fri, 26 Mar 2021 10:54:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 76BDE6B467 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616745253; bh=2N096WWgS8DT7AXBeOFvHrfY+QGZxG0F5W9ZwYzTkxE=; 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=OzbthUdO8aY1wcG6jzAFYPoZ9tIMf4tNyG+AoXiHyJRiXEfWLUA70/oc6MXz8sRWb KbevJHGO3HwVvGK1v6xlYA3URT7iw4IRE3Kk2M1bVBp1KpXpKTU1/U/YfPKRUirbU0 iLW2Utu6KWUTwl+caJIS0WXWxZWjrX31ZU8bVmeA= Received: from smtp63.i.mail.ru (smtp63.i.mail.ru [217.69.128.43]) (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 5C92B68F49 for ; Fri, 26 Mar 2021 10:44:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5C92B68F49 Received: by smtp63.i.mail.ru with esmtpa (envelope-from ) id 1lPh93-00042u-Fm; Fri, 26 Mar 2021 10:44:37 +0300 To: Sergey Ostanevich , Igor Munkin Date: Fri, 26 Mar 2021 10:43:03 +0300 Message-Id: <422eaeb77d4cb957338af0bdc0151ae7787e1567.1616743343.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9064ADF4728AA0EE922675D89A18E042B1EBC993A8274C79D182A05F538085040D684714CE580BB5E0650EC99210C358F6A5FBDE4397319D2DBF811999025C555 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE789066434B85BF7C7EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063795AFAF91F541EBCE8638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95C5DD32608FC869F5D2F8078D59EA6603C71211B4D5E852CD3A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE7328B01A8D746D8839FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3ED8438A78DFE0A9E117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947C0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E73528A6D463EDFD0DBBC4224003CC83647689D4C264860C145E X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C5DD32608FC869F5D2F8078D59EA6603C71211B4D5E852CD39C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFF532FBFD8162E58C699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D4140D813EC137C69191B3BC0784A8979469A1652D93A9924A6ED48EBD9E23EE7951CAD60025711D1D7E09C32AA3244C78A70811470F1A6C91A9726A99E5D14A3E8609A02908F271927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojapPp7P/VpAg3GN930DEjuw== X-Mailru-Sender: 3B9A0136629DC91206CBC582EFEF4CB4D91689A962750CFAC37CE200D0FCECB756B6319870E30A2CF2400F607609286E924004A7DEC283833C7120B22964430C52B393F8C72A41A89437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 luajit 20/30] test: adapt PUC Lua test for args in vararg func 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 like additional first argument, unlike LuaJIT does. All extra arguments is set into `arg` variable. Implicit `arg` parameter for old-style vararg functions was finally removed in Lua 5.2. This patch adjust tests in vararg.lua considering Lua 5.2 test suite taken from https://www.lua.org/tests/lua-5.2.0-tests.tar.gz. Closes tarantool/tarantool#5712 Part of tarantool/tarantool#5845 Part of tarantool/tarantool#4473 --- test/PUC-Lua-5.1-tests/vararg.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/PUC-Lua-5.1-tests/vararg.lua b/test/PUC-Lua-5.1-tests/vararg.lua index ae068fa..efb76c5 100644 --- a/test/PUC-Lua-5.1-tests/vararg.lua +++ b/test/PUC-Lua-5.1-tests/vararg.lua @@ -2,9 +2,13 @@ print('testing vararg') _G.arg = nil +-- Lua 5.1 interprets ... in the vararg functions like additional +-- first argument, unlike LuaJIT does. All extra arguments is set +-- into `arg` variable. This extension is from Lua 5.2. +-- See also https://github.com/tarantool/tarantool/issues/5712. +-- LuaJIT: 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 +21,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 +48,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