Program logic bugs vs input/environmental errors

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 16 12:21:49 PDT 2014


On Thursday, 16 October 2014 at 06:11:46 UTC, Jacob Carlborg 
wrote:
> On 2014-10-15 16:25, Dicebot wrote:
>
>> How can one continue without recovering? This will result in 
>> any kind of
>> environment not being cleaned and false failures of other 
>> tests that
>> share it.
>
> I will probably use something else than "assert" in my unit 
> tests. Something like assertEq, assertNotEq and so on. It's 
> more flexible, can give better error message and I can have it 
> throw an exception instead of an error. But there's still the 
> problem with asserts in contracts and other parts of the code.

This is what we are using right now:

public void test ( char[] op, T1, T2 ) ( T1 a, T2 b, char[] file 
= __FILE__, size_t line = __LINE__ )
{
     enforce!(op, TestException)(a, b, file, line);
}

but it won't work well with 3d-party libraries that use 
assertions.


More information about the Digitalmars-d mailing list