[Tarantool-patches] [PATCH v2 luajit 10/26] test: enable <ffi_enum.lua> in LuaJIT-tests
Sergey Bronnikov
sergeyb at tarantool.org
Thu Feb 1 19:07:18 MSK 2024
Hi, Sergey
thanks for the patch! LGTM
On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch changes the `dofile()` (which uses an unreliable relative
> file path and mutates `_G` with global functions to be defined) to the
> corresponding `require()` call and renames the C library in the
> `require()` call. Also, it names all subtests and includes the test in
> <index>.
>
> Part of tarantool/tarantool#9398
> ---
> test/LuaJIT-tests/lib/ffi/ffi_enum.lua | 11 +++++------
> test/LuaJIT-tests/lib/ffi/index | 1 +
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/test/LuaJIT-tests/lib/ffi/ffi_enum.lua b/test/LuaJIT-tests/lib/ffi/ffi_enum.lua
> index e8e40ad0..49c874c7 100644
> --- a/test/LuaJIT-tests/lib/ffi/ffi_enum.lua
> +++ b/test/LuaJIT-tests/lib/ffi/ffi_enum.lua
> @@ -1,7 +1,7 @@
>
> local ffi = require("ffi")
>
> -dofile("../common/ffi_util.inc")
> +local fails = require("common.fails")
>
> ffi.cdef[[
> typedef enum enum_i { FOO_I = -1, II = 10 } enum_i;
> @@ -13,10 +13,9 @@ int call_i_ei(enum_i a) asm("call_i");
> int call_i_eu(enum_u a) asm("call_i");
> ]]
>
> -local C = ffi.load("../clib/ctest")
> -
> -do
> +local C = ffi.load("ctest")
>
> +do --- base
> local t = ffi.new("enum_i[100]")
> for i=0,99 do t[i] = "II" end
> for i=0,99 do assert(t[i] == "II") end
> @@ -42,14 +41,14 @@ do
> for i=0,99 do assert(t[i] ~= u[i]) end
> end
>
> -do
> +do --- calls
> for i=0,99 do assert(C.call_ei_i(9) == "II") end
> for i=0,99 do assert(C.call_eu_i(9) == "UU") end
> for i=0,99 do assert(C.call_i_ei("II") == 11) end
> for i=0,99 do assert(C.call_i_eu("UU") == 11) end
> end
>
> -do
> +do --- cast to bool
> local f = ffi.cast("bool (*)(enum_i)", function(e) return e == "II" end)
> assert(f("II"))
> assert(not f(0))
> diff --git a/test/LuaJIT-tests/lib/ffi/index b/test/LuaJIT-tests/lib/ffi/index
> index 5c2be87f..b11e5aa4 100644
> --- a/test/LuaJIT-tests/lib/ffi/index
> +++ b/test/LuaJIT-tests/lib/ffi/index
> @@ -8,6 +8,7 @@ ffi_call.lua
> ffi_callback.lua
> ffi_const.lua
> ffi_convert.lua
> +ffi_enum.lua
> istype.lua
> jit_array.lua
> jit_complex.lua
More information about the Tarantool-patches
mailing list