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 99766C996AB; Wed, 14 Aug 2024 17:12:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 99766C996AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1723644752; bh=R1Zsdh399NLG1cXbCyVgdCoBH66EskiLLwEeKvkMSCY=; 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=YeFEdWPPAdbfHjQZZlfap50i9nNFN85B5JBKpGPS5QvBiV6nFccvdP8B3rBcrBjIW T+uNybC31so5GXvRQ6pZWNfgfyXycHTghCxh5bvmDmfrJEi0wYKUxpqaPZsuchVMYH tLCZ13gi+KD3drYrNi66/gJcb53aIH7/fpf8DIg8= Received: from smtp45.i.mail.ru (smtp45.i.mail.ru [95.163.41.83]) (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 9B24FC13AC6 for ; Wed, 14 Aug 2024 16:58:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9B24FC13AC6 Received: by smtp45.i.mail.ru with esmtpa (envelope-from ) id 1seEVk-00000003nAF-1kbA; Wed, 14 Aug 2024 16:58:00 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Wed, 14 Aug 2024 16:56:13 +0300 Message-ID: <54e05a4bf2de03cf389b6fdea8648f9e2d8bec78.1723638851.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D7B6E71A78C20FB9D9356C89D4936CE4844AD87712F71107182A05F538085040412A5C363C5EDE41A6D5EE0DB6E1EC8D3DA9C2A31C6E031C129B12038A8E527C92B1A6A82314B74A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE781C4E570E9C9D556C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE7ED971EE68B26EF8CEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38B043BF0FB74779F364D988F0F53399612748B3677A9AF800614ABDD2EDEA99B71A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE77E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6A50BD5087FBFCDAACC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C22491F4CF9FF084B7DCD76E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8B851A6377A55447BB3AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FCF1175FABE1C0F9B6E2021AF6380DFAD18AA50765F7900637F09814068C508CC822CA9DD8327EE4930A3850AC1BE2E735BA6625F88748EAEFC4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A584EBE895BB25AB915002B1117B3ED696762AC19C0D5072F3B48B7A7F94616420823CB91A9FED034534781492E4B8EEADADEF88395FA75C5FC79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFB3AE4DB6C7F9BC1FC71E5CEAD19D7A56BCF0A584BEDAD3159262544D61E91FEC9FED342E2040E994470327EB0AC8E6934B7BBD231E4C6BE1E98BAB6BFF30A4784B5E04D45A0D915DC226CC413062362A913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnMg09N3zL/ihHM272LRRSg== X-Mailru-Sender: 520A125C2F17F0B1A9638AD358559B5903DC3E407492644BA6D5EE0DB6E1EC8D3DA9C2A31C6E031CB7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit 31/36] 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 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" 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 --- 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 -- 2.45.2