On Monday 03 January 2011 05:26:14 Andrej Mitrovic wrote: > On 1/3/11, Jonathan M Davis <jmdavisp...@gmx.com> wrote: > > Other changes that some people have expressed interest in are things like > > having > > it printed when a test passes, and those should not be in the language or > > druntime itself. > > Isn't this already done in Phobos?: > > unittest > { > debug(std_algorithm) scope(success) > writeln("unittest @", __FILE__, ":", __LINE__, " done."); > } > > --
I think that it's fine if someone wants to make their unittest blocks print out on success, but that doesn't work in the general case with the unit tests running before main. And if you made it so that they _did_ print success, then what would the people who only want the failures do? With the current scheme, you can make it print if you want to, but it's not forced on you. And honestly, aside from creating a simple string mixin which does what Phobos is doing in your example, I don't how you could really have helper functions for that. However, maybe adding a function which returns an appropriate string to mixin to print successes like Phobos is there would be of some value in std.unittests. Regardless, printing test successes is definitely example of where named unit tests would be nice. And being able to name unittest blocks is definitely a change that would have to be made in the language. Of course, what I _really_ want named unit tests for is so that the stack traces have recognizable names in them for unittest blocks. In any case, it's perfectly possible to do as Phobos does above and have extra code in your unittest blocks which prints upon success. - Jonathan M Davis