Re: [PATCH v2 2/6] unit-tests: add for_test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 23.07.24 um 00:41 schrieb Kyle Lippincott:
> On Mon, Jul 22, 2024 at 12:37 PM Junio C Hamano <gitster@xxxxxxxxx> wrote:
>>
>> Kyle Lippincott <spectral@xxxxxxxxxx> writes:
>>
>>> I can see based on this description where the name came from, but
>>> without this context, it's not clear when reading a test what it
>>> actually does. The name comes from an implementation detail, and is
>>> not describing what it _does_, just _how_ it does it.
>>>
>>> Maybe a name like `small_test` or `quick_test` or something like that
>>> would better express the intended usage?
>>
>> Names that explicitly have C keyword for control structures, e.g.
>> "if_somecondition_test()", "while_foo_test()" or "for_test()" is
>> vastly preferrable than these, in order to make it clear that we are
>> introducing a macro that defines control structure.
>
> Perhaps expression_test or something, then? It's testing an expression
> (I think blocks are a type of expression? I never remember which is
> 'larger': expressions or statements, and that might only be a C++
> thing, C might not have the same terminology).

If in doubt, feel free to look it up.  We're not taking a test here
(bad pun intended).

https://en.cppreference.com/w/c/language/expressions
https://en.cppreference.com/w/c/language/statements

TEST requires test bodies to be expressions, for_test allows them to
be statements.  Statements can include arbitrary expressions, but not
the other way around.

The "for" in for_test indicates that it's a for-like macro.  This
already implies that it is followed by a statement.  It works for the
existing for_each macros.

René





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux