[phobos] Silent failure of std.container unittests

Benjamin Shropshire benjamin at precisionsoftware.us
Thu Jul 15 16:59:01 PDT 2010


Hello Walter,

 > Andrei Alexandrescu wrote:
 >
 >> 4. DESIRED: assert is NOT hacked, any failing assert ends the current
 >> unittest, the failure message is printed, execution continues with
 >> the next unittest, program ends with error code if at least one
 >> assert failed, everybody's happy.
 >>
 > Everybody's happy except the guys like me who want to run all the unit
 > tests in one go.
 >

You still can't. If a failed assert ever returns, you can end up with 
even less results than case 4:

unittest
{
    char* c = some func();
    assert(c !is null);
    assert(c[0] == 'a');  // SEG-V
}

Beside, I don't now nor will I ever care about ANYTHING after the first 
failed assert in any given block. If code B should run even if an assert 
in code A fails, I'll put it in another unittest block. If anything BUT 
option 4 gets implemented I'll start using "if(!test) throw..." rather 
than assert.


More information about the phobos mailing list