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 AA995C5B2E4; Thu, 22 Aug 2024 17:33:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AA995C5B2E4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1724337228; bh=Wjwnf2/RF7ya0xtd3NbDfpMT1Pq9iQFtzD5Pd520qhw=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=qtJq6YDuVxgzMq/5kme1rfzFodT8BliqlcoaOu8BQaDC737WiVx+w53HwgLHsgIHb xzwe6mZadewDbb05f2t6YSFGypftftj1yGv1/GyszqEnOsiVe8jJOUd8ljxDqoMKFx 6XYGEFVS9glFLoSrbCrrTWpmA2Z2dmGaRKqnsKeQ= Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [95.163.41.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9A2C1C5B2E1 for ; Thu, 22 Aug 2024 17:33:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9A2C1C5B2E1 Received: by smtp39.i.mail.ru with esmtpa (envelope-from ) id 1sh8sk-0000000DFri-2ubO; Thu, 22 Aug 2024 17:33:47 +0300 Content-Type: multipart/alternative; boundary="------------0IsUNJS9BbjM3CaRYLQu5aEX" Message-ID: <7255a275-68de-43f1-8188-0950be8a6a6b@tarantool.org> Date: Thu, 22 Aug 2024 17:33:46 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9A67092BE052B1D9E31015FC5902C0B2438B46547866FC5B0182A05F538085040C1376CF07D91DEFDAC8EDD30083ED68E560DBE1C65ACF5F2899CA9E4233F3A8D8ED064EC5171B301 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77FAFB841CE9024F9EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006370999C8D6401250DC8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8A8A42E849B93401C5AB61C89CE543248FB05A6476F317537CC7F00164DA146DAFE8445B8C89999728AA50765F7900637F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F7900637CAEE156C82D3D7D9389733CBF5DBD5E9B5C8C57E37DE458BD9DD9810294C998ED8FC6C240DEA76428AA50765F7900637F609FDC7BF3E55A5D81D268191BDAD3DBD4B6F7A4D31EC0BE2F48590F00D11D6D81D268191BDAD3D78DA827A17800CE7D36F53DD076E3CB7EC76A7562686271ED91E3A1F190DE8FD2E808ACE2090B5E14AD6D5ED66289B5259CC434672EE63711DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C307FFBFDCC3B3F35035872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A5709CB25ACE0C54F45002B1117B3ED696FED85DDD3F791C7DE20DC3F561CE4150823CB91A9FED034534781492E4B8EEAD21D4E6D365FE45D1BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF261FA91EB5DD8300393BC2299AA6FF13179C15FFC580678A7FBFFC55AC791365124E09ADABDE41742FB0CAD32ADFBF84CD0F7AA78B532DC9E02FB405A4366FD65D2B4AE649F4F5175F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbUwDRTee1Xob3KNc8QV7CA== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140827CB0BF86C747F33D037D12F4EEF5045D78D9F4464143A10152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 luajit 39/45] test: enable LuaJIT test 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 Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------0IsUNJS9BbjM3CaRYLQu5aEX Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sergey, On 21.08.2024 11:58, Sergey Kaplun wrote: > This patch moves the aforementioned test from the to the > directory, includes it in , and names the subtest. > > Also, the NaN checks are skipped for parsing via `strtod()`, since > LuaJIT uses canonicalized NaNs, which are equal to -NaN > (0xfff8000000000000). > > Part of tarantool/tarantool#9398 > --- thanks for the patch! LGTM > test/LuaJIT-tests/lib/base/index | 1 + > .../{misc => lib/base}/tonumber_scan.lua | 58 ++++++++++++------- > 2 files changed, 37 insertions(+), 22 deletions(-) > rename test/LuaJIT-tests/{misc => lib/base}/tonumber_scan.lua (93%) > > diff --git a/test/LuaJIT-tests/lib/base/index b/test/LuaJIT-tests/lib/base/index > index 942c53c0..bef5dcb4 100644 > --- a/test/LuaJIT-tests/lib/base/index > +++ b/test/LuaJIT-tests/lib/base/index > @@ -8,4 +8,5 @@ pairs.lua > pcall_jit.lua > select.lua > tonumber_tostring.lua > +tonumber_scan.lua +ffi > xpcall_jit.lua +compat5.2 > diff --git a/test/LuaJIT-tests/misc/tonumber_scan.lua b/test/LuaJIT-tests/lib/base/tonumber_scan.lua > similarity index 93% > rename from test/LuaJIT-tests/misc/tonumber_scan.lua > rename to test/LuaJIT-tests/lib/base/tonumber_scan.lua > index 78e1ca3e..e2dcd4d0 100644 > --- a/test/LuaJIT-tests/misc/tonumber_scan.lua > +++ b/test/LuaJIT-tests/lib/base/tonumber_scan.lua > @@ -150,31 +150,45 @@ local function tohex64(x) > return "0x"..bit.tohex(tonumber(x/2LL^32))..bit.tohex(tonumber(x%2LL^32)).."ULL" > end > > -local conv = tonumber > +local e = ffi.new("char *[1]") > +local u = ffi.new("union { double d; uint64_t x; }") > > -if arg and arg[1] == "strtod" then > - local e = ffi.new("char *[1]") > - function conv(s) > - local d = ffi.C.strtod(s, e) > - return (e[0][0] == 0 and #s ~= 0) and d or nil > +local function test_conv(conv, skip_nan) > + for i = 1, #t, 2 do > + local y, s = t[i], t[i + 1] > + if s:lower():match('nan') and skip_nan then > + -- LuaJIT uses canonicalized NaNs. > + -- -NaN = 0xfff8000000000000. > + -- Hence, `strtod()` yields a different value here. > + goto continue > + end > + local d = conv(s) > + local ok > + if d == nil then > + ok = (y == false) > + else > + u.d = d > + ok = (y == u.x) > + end > + if not ok then > + error(string.format( > + "FAIL: '%s'\n\tGOT: %s\n\tOK: %s", > + s, > + d and tohex64(u.x) or "nil", > + y and tohex64(y) or "nil", "\n\n" > + )) > + end > + ::continue:: > end > end > > -local u = ffi.new("union { double d; uint64_t x; }") > - > -for i=1,#t,2 do > - local y, s = t[i], t[i+1] > - local d = conv(s) > - local ok > - if d == nil then > - ok = (y == false) > - else > - u.d = d > - ok = (y == u.x) > - end > - if not ok then > - io.write('FAIL: "', s, '"\n GOT: ', d and tohex64(u.x) or "nil", " OK: ", y and tohex64(y) or "nil", "\n\n") > --- print(" "..tohex64(u.x)..", \""..s.."\",") > - end > +do --- tonumber parsing > + test_conv(tonumber) > end > > +do --- strtod parsing > + test_conv(function(s) > + local d = ffi.C.strtod(s, e) > + return (e[0][0] == 0 and #s ~= 0) and d or nil > + end, true) > +end --------------0IsUNJS9BbjM3CaRYLQu5aEX Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Sergey,


On 21.08.2024 11:58, Sergey Kaplun wrote:
This patch moves the aforementioned test from the <misc> to the
<lib/base> directory, includes it in <index>, and names the subtest.

Also, the NaN checks are skipped for parsing via `strtod()`, since
LuaJIT uses canonicalized NaNs, which are equal to -NaN
(0xfff8000000000000).

Part of tarantool/tarantool#9398
---
thanks for the patch! LGTM
 test/LuaJIT-tests/lib/base/index              |  1 +
 .../{misc => lib/base}/tonumber_scan.lua      | 58 ++++++++++++-------
 2 files changed, 37 insertions(+), 22 deletions(-)
 rename test/LuaJIT-tests/{misc => lib/base}/tonumber_scan.lua (93%)

diff --git a/test/LuaJIT-tests/lib/base/index b/test/LuaJIT-tests/lib/base/index
index 942c53c0..bef5dcb4 100644
--- a/test/LuaJIT-tests/lib/base/index
+++ b/test/LuaJIT-tests/lib/base/index
@@ -8,4 +8,5 @@ pairs.lua
 pcall_jit.lua
 select.lua
 tonumber_tostring.lua
+tonumber_scan.lua +ffi
 xpcall_jit.lua +compat5.2
diff --git a/test/LuaJIT-tests/misc/tonumber_scan.lua b/test/LuaJIT-tests/lib/base/tonumber_scan.lua
similarity index 93%
rename from test/LuaJIT-tests/misc/tonumber_scan.lua
rename to test/LuaJIT-tests/lib/base/tonumber_scan.lua
index 78e1ca3e..e2dcd4d0 100644
--- a/test/LuaJIT-tests/misc/tonumber_scan.lua
+++ b/test/LuaJIT-tests/lib/base/tonumber_scan.lua
@@ -150,31 +150,45 @@ local function tohex64(x)
   return "0x"..bit.tohex(tonumber(x/2LL^32))..bit.tohex(tonumber(x%2LL^32)).."ULL"
 end
 
-local conv = tonumber
+local e = ffi.new("char *[1]")
+local u = ffi.new("union { double d; uint64_t x; }")
 
-if arg and arg[1] == "strtod" then
-  local e = ffi.new("char *[1]")
-  function conv(s)
-    local d = ffi.C.strtod(s, e)
-    return (e[0][0] == 0 and #s ~= 0) and d or nil
+local function test_conv(conv, skip_nan)
+  for i = 1, #t, 2 do
+    local y, s = t[i], t[i + 1]
+    if s:lower():match('nan') and skip_nan then
+      -- LuaJIT uses canonicalized NaNs.
+      -- -NaN = 0xfff8000000000000.
+      -- Hence, `strtod()` yields a different value here.
+      goto continue
+    end
+    local d = conv(s)
+    local ok
+    if d == nil then
+      ok = (y == false)
+    else
+      u.d = d
+      ok = (y == u.x)
+    end
+    if not ok then
+      error(string.format(
+        "FAIL: '%s'\n\tGOT: %s\n\tOK:  %s",
+        s,
+        d and tohex64(u.x) or "nil",
+        y and tohex64(y) or "nil", "\n\n"
+      ))
+    end
+    ::continue::
   end
 end
 
-local u = ffi.new("union { double d; uint64_t x; }")
-
-for i=1,#t,2 do
-  local y, s = t[i], t[i+1]
-  local d = conv(s)
-  local ok
-  if d == nil then
-    ok = (y == false)
-  else
-    u.d = d
-    ok = (y == u.x)
-  end
-  if not ok then
-    io.write('FAIL: "', s, '"\n GOT: ', d and tohex64(u.x) or "nil", "   OK: ", y and tohex64(y) or "nil", "\n\n")
---      print("  "..tohex64(u.x)..", \""..s.."\",")
-  end
+do --- tonumber parsing
+  test_conv(tonumber)
 end
 
+do --- strtod parsing
+  test_conv(function(s)
+    local d = ffi.C.strtod(s, e)
+    return (e[0][0] == 0 and #s ~= 0) and d or nil
+  end, true)
+end
--------------0IsUNJS9BbjM3CaRYLQu5aEX--