[Tarantool-patches] [PATCH luajit 1/5] test: introduce `samevalues()` TAP checker
Sergey Bronnikov
sergeyb at tarantool.org
Thu Aug 24 10:44:58 MSK 2023
H, Igor, Sergey
On 8/21/23 13:47, Igor Munkin wrote:
> Sergey,
>
> <snipped>
>
>>>>> The introduced `samevalues()` helper checks that values in range from
>>>>> 1, to `table.maxn()` of the given table are exactly the same. It may be
>>>>> usefull for test consistency of JIT and VM behaviour. Originally, the
>>>>> `arr_is_consistent()` function was introduced in the
>>>>> <tarantool-tests/gh-6163-min-max.test.lua>. `samevalues()` has the same
>>>>> functionallity (except usage of `table.maxn()` instead `#` operator to
>>>>> be sure, that the table we check isn't a sparse array).
>>>> I would rename samevalues to something like assert_equals or
>>>> assert_items_equals just because
>>>>
>>>> similar functions are named in unit testing frameworks and helpers with
>>>> prefix assert_
>>> As you can see we use naming without _ for exported function in the
>>> <tap.lua> module, so additional one with strange naming will be
>>> inconsistent.
>>>
>>> Also, discussed this naming with Igor and Max offline and this name is
>>> OK for them, feel free also to CC Igor to discuss:).
>>>
>>>> more readable from my point of view. See names for assertions in luatest
>>>> [1] and JUnit (popular unit testing framework).
>>>>
>>>>
>>>> 1. https://github.com/tarantool/luatest#list-of-luatest-functions
>>>>
>>>> 2.
>>>> https://junit.org/junit5/docs/5.0.1/api/org/junit/jupiter/api/Assertions.html
>>>>
>>>>
>> Igor, what do you think regarding naming of the introduced function?
> Frankly speaking, it was me, who originally suggested this name (AFAIR,
> but Sergey K. might correct me if I'm wrong), so I'm totally fine with
> the naming and here why:
> 1. There are no functions named in the style you're referring to above.
> This may relate to luatest, but definitely not to our version of
> tap.lua module.
> 2. All the names *except* <is_deeply> for some historical reasons (and
> due to many Python lovers, that worked in Tarantool, I guess) are
> named in so-called "Lua-way" (you can see many examples in Lua
> Reference Manual or in popular Lua modules): short name with in lower
> case with no separators like underscore or other. This applies to
> <samevalues> too.
> 3. As for me <assert_items_equals> should validate all the items in
> table against the one *expected*, however <samevalues> just checks
> that the table consists of the same values, but nobody has to know
> this particular value.
>
> All in all, I'm OK with the current name, since it fits to the current
> naming policy. However, I'm open to other options regarding the
> assertion module to be used in our testing suite (of course, out of the
> scope of this series).
>
Igor, thanks for detailed explanation. Arguments looks reasonable for me.
I just wanted to make sure that the choice is not accidental and made
spontaneously.
Sergey, LGTM now.
More information about the Tarantool-patches
mailing list