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 251769DC61E; Mon, 29 Jan 2024 14:00:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 251769DC61E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1706526055; bh=Hbx3PW4+4NTJDiiqmiwZrFSchkqoEmc0lFGaoDf5vPM=; 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=f/orBd0E3bgFUXW7GoOkc/HO5P5XO4aItmHg21g8cyhytbr0Dhi/BeA10468JqCvJ VbuAcipRGumhkQO3GD/mHExjvZVdXBvkXbZeft3Ln7EFIBm9NYY2p7AN9YtlTRptys jOcY9r/m7a/SEa41bFQ2a5wIs8grc36Rvf2SufBc= Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [95.163.41.73]) (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 A54D49DC608 for ; Mon, 29 Jan 2024 13:50:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A54D49DC608 Received: by smtp32.i.mail.ru with esmtpa (envelope-from ) id 1rUPDI-0000000BQ6r-3f0S; Mon, 29 Jan 2024 13:50:05 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Mon, 29 Jan 2024 13:45:23 +0300 Message-ID: <82bbfc368ccb9f8d7188a10dfc69dae16eec47d1.1706520765.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD96A58C36AA2E9964978ECFE5B85237D574143F5FE24BA91E3182A05F53808504023BAD03F9D9EAA8433594132A326AF8B0D53AC3735E9297DDCA41764705814780617A7DEC1BA40D2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77A6D8F9467FE415BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637822A0A225AD602F38638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D80F8ED511190CC886BE1BF1E404F07B8E863A3E3E7C1EB889CC7F00164DA146DAFE8445B8C89999728AA50765F79006370D9A29B7FD16D1239FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C332941D3B652364A4117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CF6804EF05EF4ADF2A3AA81AA40904B5D9CF19DD082D7633A0C84D3B47A649675F3AA81AA40904B5D98AA50765F7900637EF1F32DBCCB8E3DECD04E86FAF290E2DB606B96278B59C421DD303D21008E29813377AFFFEAFD269176DF2183F8FC7C088D2E8BEBF93D4B068655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CEB8BE9EE02D59E2D43847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5C9F042BA7C5D376C5002B1117B3ED6968EA532F643FA165E1E49B01306B5E3AD823CB91A9FED034534781492E4B8EEAD45F93BA578C2B99FC79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFFE54141C66DD75BAE6A9F97BC6864339CD5C609B1E13AC2D8558FC49B5042A1C715D154A38A044DC8FB01E7B8BF01A6936023D490F71F4C9B718120DE96C5CC5D97B9BD4AC492361C226CC413062362A913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojmd9AG1X07oSgQKP3SL7hYw== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769B675761EC23E328033594132A326AF8B0D53AC3735E9297DB7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 luajit 23/26] 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 test from the to directory, includes it in , and names subtests. Also, it enables tests for all arches and fixes tests for 47-bit lightuserdata because it is available since the commit 2cacfa8e7ffefb715abf55dc5b0c708c63251868 ("Add support for full-range 64 bit lightuserdata.") Part of tarantool/tarantool#9398 --- test/LuaJIT-tests/lang/index | 1 + test/LuaJIT-tests/lang/lightud.lua | 89 ++++++++++++++++++++++++++++++ test/LuaJIT-tests/misc/lightud.lua | 88 ----------------------------- 3 files changed, 90 insertions(+), 88 deletions(-) create mode 100644 test/LuaJIT-tests/lang/lightud.lua delete mode 100644 test/LuaJIT-tests/misc/lightud.lua diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index index 88e2edfa..60cbecfb 100644 --- a/test/LuaJIT-tests/lang/index +++ b/test/LuaJIT-tests/lang/index @@ -5,6 +5,7 @@ compare_nan.lua constant for.lua length.lua +lightud.lua modulo.lua concat.lua self.lua diff --git a/test/LuaJIT-tests/lang/lightud.lua b/test/LuaJIT-tests/lang/lightud.lua new file mode 100644 index 00000000..aee9e85c --- /dev/null +++ b/test/LuaJIT-tests/lang/lightud.lua @@ -0,0 +1,89 @@ +local ctest = require("libctest") + +local lightud = ctest.lightud +local assert = assert + +-- x64 lightud tests +do --- light userdata comparison and tostring +x64 + local ud1 = lightud(0x12345678) + local ud2 = lightud(0x12345678) + assert(ud1 == ud2) + assert(tostring(ud1) == "userdata: 0x12345678") +end + +do --- unequal light userdata comparison +x64 + local ud1 = lightud(1) + local ud2 = lightud(2) + assert(ud1 ~= ud2) +end + +do --- big light userdata comparison and tostring +x64 + local ud1 = lightud(2^47-1) + local ud2 = lightud(2^47-1) + assert(ud1 == ud2) + assert(tostring(ud1) == "userdata: 0x7fffffffffff") +end + +do --- unequal light userdata comparison JIT +x64 + local ud1 = lightud(0x12345678+123*2^32) + local ud2 = lightud(0x12345678+456*2^32) + for i=1,100 do assert(ud1 ~= ud2) end +end + +do --- 47 bits light userdata +x64 + assert(tostring(lightud(0x5abc*2^32 + 0xdef01234)) == "userdata: 0x5abcdef01234") + -- Now more than 47 bits are available. + assert(pcall(lightud, 2^47) == true) + assert(pcall(lightud, 2^64-2048) == true) +end + +do --- metatable check + assert(getmetatable(lightud(1)) == nil) +end + +do --- lightuserdata SLOAD value and HREF key + local ud = lightud(12345) + local t = {[ud] = 42} + for i=1,100 do + assert(t[ud] == 42) + end +end + +do --- lightuserdata NEWREF key + local ud = lightud(12345) + for i=1,100 do + local t = {[ud] = 42} + assert(t[ud] == 42) + end +end + +do --- lightuserdata ASTORE/HSTORE value + local ud = lightud(12345) + local t = {} + for i=1,100 do + t[i] = ud + end + assert(t[100] == ud) +end + +do --- lightuserdata sync to stack + local ud = lightud(12345) + local x = nil + for j=1,20 do + for i=1,50 do + x = ud + end + assert(x == ud) + end +end + +do --- lightuserdata vs. number type check + local t = {} + for i=1,200 do t[i] = i end + t[180] = lightud(12345) + local x = 0 + assert(not pcall(function(t) + for i=1,200 do x = x + t[i] end + end, t)) + assert(x == 16110) +end diff --git a/test/LuaJIT-tests/misc/lightud.lua b/test/LuaJIT-tests/misc/lightud.lua deleted file mode 100644 index 4974d50f..00000000 --- a/test/LuaJIT-tests/misc/lightud.lua +++ /dev/null @@ -1,88 +0,0 @@ -local ctest = require("ctest") - -local lightud = ctest.lightud -local assert = assert - --- x64 lightud tests -if jit and jit.arch == "x64" then - do - local ud1 = lightud(0x12345678) - local ud2 = lightud(0x12345678) - assert(ud1 == ud2) - assert(tostring(ud1) == "userdata: 0x12345678") - end - do - local ud1 = lightud(1) - local ud2 = lightud(2) - assert(ud1 ~= ud2) - end - do - local ud1 = lightud(2^47-1) - local ud2 = lightud(2^47-1) - assert(ud1 == ud2) - assert(tostring(ud1) == "userdata: 0x7fffffffffff") - end - do - local ud1 = lightud(0x12345678+123*2^32) - local ud2 = lightud(0x12345678+456*2^32) - for i=1,100 do assert(ud1 ~= ud2) end - end - assert(tostring(lightud(0x5abc*2^32 + 0xdef01234)) == "userdata: 0x5abcdef01234") - assert(pcall(lightud, 2^47) == false) - assert(pcall(lightud, 2^64-2048) == false) -end - -assert(getmetatable(lightud(1)) == nil) - --- lightuserdata SLOAD value and HREF key -do - local ud = lightud(12345) - local t = {[ud] = 42} - for i=1,100 do - assert(t[ud] == 42) - end -end - --- lightuserdata NEWREF key -do - local ud = lightud(12345) - for i=1,100 do - local t = {[ud] = 42} - assert(t[ud] == 42) - end -end - --- lightuserdata ASTORE/HSTORE value -do - local ud = lightud(12345) - local t = {} - for i=1,100 do - t[i] = ud - end - assert(t[100] == ud) -end - --- lightuserdata sync to stack -do - local ud = lightud(12345) - local x = nil - for j=1,20 do - for i=1,50 do - x = ud - end - assert(x == ud) - end -end - --- lightuserdata vs. number type check -do - local t = {} - for i=1,200 do t[i] = i end - t[180] = lightud(12345) - local x = 0 - assert(not pcall(function(t) - for i=1,200 do x = x + t[i] end - end, t)) - assert(x == 16110) -end - -- 2.43.0