Unit Testing in Action

qznc qznc at web.de
Tue Oct 24 21:58:25 UTC 2017


On Tuesday, 24 October 2017 at 20:51:36 UTC, Walter Bright wrote:
> On 10/23/2017 4:44 AM, Martin Nowak wrote:
>> On Saturday, 21 October 2017 at 22:50:51 UTC, Walter Bright 
>> wrote:
>>> Coverage would give:
>>>
>>> 1|    x = 2;
>>> 2|    if (x == 1 || x == 2)
>>>
>>> I.e. the second line gets an execution count of 2. By 
>>> contrast,
>>>
>>> 1|    x = 1;
>>> 1|    if (x == 1 || x == 2)
>> 
>> Interesting point, but would likely fail for more complex 
>> stuff.
>> 
>> 1| stmt;
>> 2| if (api1 == 1 && api2 == 2 ||
>>         api2 == 2 && api3 == 3)
>
> There would be a separate coverage count for line 3 which would 
> be the sum of counts for (api2 == 2) and (api3 == 3).
>
> Generally, if this is inadequate, just split the expression 
> into more lines.

An example for inadequate is when you cannot see which expression 
is not covered:

2| if (api1 == 1 && api2 == 2 || api3 == 3)

Just splitting the expression is suggested in the blog post, but 
in an automatic fashion via dfmt. That is not elegant. The 
information is there just not expressed in a useable way.




More information about the Digitalmars-d-announce mailing list