[phobos] Silent failure of std.container unittests
Michel Fortin
michel.fortin at michelf.com
Thu Jul 15 21:07:47 PDT 2010
Le 2010-07-15 à 22:52, Sean Kelly a écrit :
> It wouldn't be terribly onerous to me to break stateless tests into multiple unittest blocks, but it's probably more readable to simply have:
>
> unittest {
> verify(sort("bac") == "abc");
> verify(sort("bba") == "abb");
> ...
> }
Perhaps the syntax for one-statement unit tests could be relaxed to not require the braces. This:
unittest { assert(sort("bac") == "abc"); }
unittest { assert(sort("bba") == "abc"); }
could become this:
unittest assert(sort("bac") == "abc");
unittest assert(sort("bba") == "abc");
And it's suddenly more elegant, more readable and easier to write. No need for a new kind of assert (your 'verify') or a non-throwing mode for asserts. It reminds me of what happened to enum.
But of course, that's probably more work to do in the compiler.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the phobos
mailing list