[phobos] Silent failure of std.container unittests
Leandro Lucarella
luca at llucax.com.ar
Fri Jul 16 14:02:48 PDT 2010
Walter Bright, el 16 de julio a las 12:13 me escribiste:
>
>
> Adam Ruppe wrote:
> >On 7/15/10, Walter Bright <walter-UwkSZrAjFffxfQ63PejmQw at public.gmane.org> wrote:
> >>>Assertion failure should abort the current unittest block.
> >>>
> >>>Do we all agree about the above?
> >>Not me.
> >
> >That's madness!
> >
> >unittest {
> > auto a = something();
> > assert(a !is null);
> > a.stuff(); // if a is null, this is meaningless
> >}
>
> Yes, and I could easily rewrite that as:
>
> unittest {
> auto a = something();
> if (a)
> a.stuff();
> else
> assert(0);
>
> Is that worse than your rewrite of the following?
Yes :)
> >>Everybody's happy except the guys like me who want to run all the unit
> >>tests in one go.
> >
> >What you could do is:
> >
> >unittest { assert(my test); }
> >unittest { assert(my other test); }
> >unittest {
> > // complex test
> >}
> >
> >It is a bit verbose, but you'd get all the results you want without
> >breaking cases like my first null assert one.
> >
>
> Yeah, but try it if you want to go through a table of inputs and
> compare the results to a table of outputs. Of course, that can be
> done, too, but it's extra code as well.
import std.test: check;
unittest {
check(my test); // use expect() if it makes Andrei happier =P
check(my other test);
}
Done! Really Walter, what's the point of changing assert semantics for
something that can be naturally solved by a new function. Everybody is
happy then, and there are no odd behaviour or backward-incompatible
changes.
--
Leandro Lucarella (AKA luca) http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
In Minnesota there's a law
That prevents men from having sex with living fish
More information about the phobos
mailing list