std.unittests for (final?) review
Lutger Blijdestijn
lutger.blijdestijn at gmail.com
Thu Jan 6 03:45:41 PST 2011
Michel Fortin wrote:
> I'm not sold on the concept. The whole point of this module seems to
> offer a way to replace the built-in assertion mechanism with a
> customized one, with the sole purpose of giving better error messages.
> So we're basically encouraging the use of:
>
> assertPredicate!"a > b"(a, b, "message");
>
> instead of:
>
> assert(a > b, "message");
>
> It looks like an uglification of the language to me.
As you said, it is all about the error messages, not replacing assert perse.
So this comparison would be more fair, using the syntax suggested by Andrei:
assertPred!">"(a, b);
vs
assert(a > b, format("a > b failed: [%s] is not > [%s]", a, b) );
If you really want the error message, regular asserts are a bit uglier and
duplicate code.
Cutting down on the characters further, 'expect' could be used instead of
assertPred. Some unittest libraries also use this, but I can't remember
which one. I think it then makes sense to unify everything:
expect!">"(a, b);
expect!Exception( { throw new Exception(""); } () );
More information about the Digitalmars-d
mailing list