From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Maxim Kokryashkin <m.kokryashkin@tarantool.org>, Sergey Bronnikov <sergeyb@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH luajit 22/25] test: enable <lightud.lua> LuaJIT test Date: Fri, 19 Jan 2024 14:32:45 +0300 [thread overview] Message-ID: <75e5f1cc7b525ed7d46affc17107792c85091384.1705661401.git.skaplun@tarantool.org> (raw) In-Reply-To: <cover.1705661401.git.skaplun@tarantool.org> This patch moves the <lightud.lua> test from the <misc> to <lang> directory, includes it in <index>, 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
next prev parent reply other threads:[~2024-01-19 11:48 UTC|newest] Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-19 11:32 [Tarantool-patches] [PATCH luajit 00/25] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 01/25] test: prepare lauxilarily libs for LuaJIT-tests Sergey Kaplun via Tarantool-patches 2024-01-23 9:10 ` Sergey Bronnikov via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 02/25] test: separate LuaJIT helpers from ffi_util.inc Sergey Kaplun via Tarantool-patches 2024-01-23 9:17 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:35 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 03/25] test: enable <ffi_arith_ptr.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches 2024-01-23 9:21 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 13:10 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 04/25] test: enable <ffi_bitfield.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 05/25] test: enable <ffi_call.lua> " Sergey Kaplun via Tarantool-patches 2024-01-23 9:32 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:46 ` Sergey Kaplun via Tarantool-patches 2024-01-24 11:05 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 06/25] test: enable <ffi_callback.lua> " Sergey Kaplun via Tarantool-patches 2024-01-23 9:36 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:01 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:58 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 07/25] test: enable <ffi_const.lua> " Sergey Kaplun via Tarantool-patches 2024-01-23 9:38 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 11:59 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:52 ` Sergey Kaplun via Tarantool-patches 2024-01-23 12:49 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 08/25] test: enable <ffi_convert.lua> " Sergey Kaplun via Tarantool-patches 2024-01-23 9:39 ` Sergey Bronnikov via Tarantool-patches 2024-01-23 12:51 ` Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 09/25] test: enable <ffi_enum.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 10/25] test: enable <ffi_gcstep_recursive.lua> Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 11/25] test: enable <ffi_jit_arith.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 12/25] test: enable <ffi_jit_call.lua> " Sergey Kaplun via Tarantool-patches 2024-01-24 14:43 ` Sergey Bronnikov via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 13/25] test: enable <ffi_jit_conv.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 14/25] test: enable <ffi_lex_number.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 15/25] test: enable <ffi_metatype.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 16/25] test: enable <ffi_new.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 17/25] test: enable <ffi_parse_array.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 18/25] test: enable <ffi_parse_basic.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 19/25] test: enable <ffi_parse_cdef.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 20/25] test: enable <ffi_parse_struct.lua> LuaJIT test Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 21/25] test: enable <ffi_tabov.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` Sergey Kaplun via Tarantool-patches [this message] 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 23/25] test: enable <api_call.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 24/25] test: enable <catch_wrap.lua> " Sergey Kaplun via Tarantool-patches 2024-01-19 11:32 ` [Tarantool-patches] [PATCH luajit 25/25] test: enable <catch_cpp.lua> " Sergey Kaplun via Tarantool-patches 2024-01-23 9:01 ` [Tarantool-patches] [PATCH luajit 00/25] More tests from LuaJIT-tests, part 1 Sergey Bronnikov via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=75e5f1cc7b525ed7d46affc17107792c85091384.1705661401.git.skaplun@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=m.kokryashkin@tarantool.org \ --cc=sergeyb@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit 22/25] test: enable <lightud.lua> LuaJIT test' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox