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 8494F6EC40; Mon, 20 Sep 2021 12:37:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8494F6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632130667; bh=V1OkA/Uh7xDsI6jD5yfenKEpevIIScrvwoUljZXJWXQ=; h=Date:In-Reply-To:To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=lEJpn7YOz5Z0H3eO4Y5PUcJosdC526KAEbzT/OGjYqk5WstsCff1Jl7ZB/p5RR1s8 0MXnuBdMBa3DAWpCHYystpbIRRZleVC9Xbdaqremhbh89BTFE6/Uch4p7Sz21GI0LL UXD3mzAjjdWqy2nNUOPzLJf77SOl8dP+dC2Gh0LA= Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (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 A36806EC40 for ; Mon, 20 Sep 2021 12:37:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A36806EC40 Received: by smtp55.i.mail.ru with esmtpa (envelope-from ) id 1mSFk8-0003o0-Ii; Mon, 20 Sep 2021 12:37:45 +0300 Message-Id: <62E85140-FE65-43FC-9F10-9B0611B22F2D@tarantool.org> Content-Type: multipart/alternative; boundary="Apple-Mail=_522AFF65-712E-4E83-B7DA-8C75C51CE35D" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Date: Mon, 20 Sep 2021 12:37:43 +0300 In-Reply-To: To: Sergey Kaplun References: <0d207e1a15360109e1e9c4bb775248f0fc04edc6.1631170629.git.skaplun@tarantool.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91AE02D33A9C88A2FECE56E2A292C9F7D3C69CC5C84EEB3A800894C459B0CD1B99EC7ACE88A8CCEC8D02B4995524D627B29E88886021A9387021035654F677716 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7C42AF033AFE07300EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375448D590B04CE87D8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D881423351D58E53268C85059422372D3F117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18F04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A1DCCEB63E2F10FB089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A587E9AA876D27C48A08033987892847575A8017F2C6933302D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75DD5744CF7ED0C6846D6546786ADF492D5A0AA20F8A030721AEF7A422EC9C26711AD47A1A022709478E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3490011A262ADAEDFE561E445900E17A339FF365E8DD6D4A228252469E8E8C4F13FCC48077D8852BE31D7E09C32AA3244C8A100E06DA74E1AD073E7DAB9F0948FB39C99C45E8D137E9FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojsFc9NKou+3g90vuUyJrw4Q== X-Mailru-Sender: 3B9A0136629DC912F4AABCEFC589C81EAC31BDF4125C9C8417D91E6B718AC7987A5CDCC3C24EB485AD07DD1419AC565FA614486B47F28B67C5E079CCF3B0523AED31B7EB2E253A9E112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/3] test: fix path storage for non-concatable objects 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: sergos via Tarantool-patches Reply-To: sergos Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" --Apple-Mail=_522AFF65-712E-4E83-B7DA-8C75C51CE35D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Thanks for explanation!=20 LGTM. Sergos > On 20 Sep 2021, at 11:28, Sergey Kaplun wrote: >=20 > Hi, Sergos! >=20 > Thanks for the review! >=20 > On 15.09.21, sergos wrote: >> Hi! >> Thanks for the patch! >>=20 >>> On 9 Sep 2021, at 10:03, Sergey Kaplun > wrote: >>>=20 >>> When the key of a table to compare via `tap.test:is_deeply()` is >>> non-concatable object (i.e. lightuserdata) concatenation with path >> ^^^^ does it mean the object has no __concat, while has __tostring? >>=20 >> As a result: is there a case an object has no __tostring? >=20 > Yes, for example, userdata may have no neither __tostring, nor = __concat > metamethod, but tostring() will show us its value and prevent raising = an > error. >=20 > | luajit -e 'print(getmetatable(newproxy(true)).__tostring, = getmetatable(newproxy(true)).__concat); local r =3D "ud: = "..tostring(newproxy()) print(r)' > | nil nil > | ud: userdata: 0x41edce48 >=20 >>=20 >>> raises an error. >>>=20 >>> This patch converts object to string to avoid this error. >>>=20 >>> Needed for tarantool/tarantool#5629 >>> --- >>> test/tarantool-tests/tap.lua | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>=20 >>> diff --git a/test/tarantool-tests/tap.lua = b/test/tarantool-tests/tap.lua >>> index 44fcac3d..a1f54d20 100644 >>> --- a/test/tarantool-tests/tap.lua >>> +++ b/test/tarantool-tests/tap.lua >>> @@ -166,7 +166,7 @@ local function is_deeply(test, got, expected, = message, extra) >>>=20 >>> for k, v in pairs(got) do >>> has[k] =3D true >>> - extra.path =3D path .. "." .. k >>> + extra.path =3D path .. "." .. tostring(k) >>> if not cmpdeeply(v, expected[k], extra) then >>> return false >>> end >>> @@ -175,7 +175,7 @@ local function is_deeply(test, got, expected, = message, extra) >>> -- Check if expected contains more keys then got. >>> for k, v in pairs(expected) do >>> if has[k] ~=3D true and (extra.strict or v ~=3D NULL) then >>> - extra.path =3D path .. "." .. k >>> + extra.path =3D path .. "." .. tostring(k) >>> extra.expected =3D "key (exists): " .. tostring(k) >>> extra.got =3D "key (missing): " .. tostring(k) >>> return false >>> --=20 >>> 2.31.0 >>>=20 >>=20 >=20 > --=20 > Best regards, > Sergey Kaplun --Apple-Mail=_522AFF65-712E-4E83-B7DA-8C75C51CE35D Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Thanks for explanation! 

LGTM.

Sergos

On 20 = Sep 2021, at 11:28, Sergey Kaplun <skaplun@tarantool.org> wrote:

Hi, Sergos!

Thanks for the review!

On 15.09.21, sergos wrote:
Hi!
Thanks for the = patch!

On 9 Sep 2021, at 10:03, Sergey Kaplun <skaplun@tarantool.org> wrote:

When the key of a table to compare via `tap.test:is_deeply()` = is
non-concatable object (i.e. lightuserdata) = concatenation with path
 ^^^^ does it = mean the object has no __concat, while has __tostring?

As a result: is there a case an object has no __tostring?

Yes, for example, userdata may have no neither __tostring, = nor __concat
metamethod, = but tostring() will show us its value and prevent raising an
error.

| luajit -e 'print(getmetatable(newproxy(true)).__tostring, = getmetatable(newproxy(true)).__concat); local r =3D "ud: = "..tostring(newproxy()) print(r)'
| nil     nil
| ud: = userdata: 0x41edce48


raises an error.

This patch converts object to string to avoid this error.

Needed for tarantool/tarantool#5629
---
test/tarantool-tests/tap.lua | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/tarantool-tests/tap.lua = b/test/tarantool-tests/tap.lua
index 44fcac3d..a1f54d20 = 100644
--- a/test/tarantool-tests/tap.lua
+++ = b/test/tarantool-tests/tap.lua
@@ -166,7 +166,7 @@ local = function is_deeply(test, got, expected, message, extra)

   for k, v in pairs(got) do
     has[k] =3D true
- =      extra.path =3D path .. "." .. k
+      extra.path =3D path .. "." .. = tostring(k)
     if not = cmpdeeply(v, expected[k], extra) then
       return false
     end
@@ -175,7 = +175,7 @@ local function is_deeply(test, got, expected, message, = extra)
   -- Check if expected contains = more keys then got.
   for k, v in = pairs(expected) do
     if has[k] = ~=3D true and (extra.strict or v ~=3D NULL) then
- =        extra.path =3D path .. "." .. = k
+        extra.path =3D= path .. "." .. tostring(k)
       extra.expected =3D = "key (exists): " ..  tostring(k)
       extra.got =3D "key = (missing): " .. tostring(k)
       return false
-- 
2.31.0



-- Best = regards,
Sergey = Kaplun

= --Apple-Mail=_522AFF65-712E-4E83-B7DA-8C75C51CE35D--