Utah Valley University teaches D (using TDPL)

Jonathan M Davis jmdavisProg at gmx.com
Thu Nov 18 08:43:54 PST 2010


On Thursday 18 November 2010 04:47:43 Bruno Medeiros wrote:
> On 16/11/2010 21:11, Gide Nwawudu wrote:
> > On Tue, 16 Nov 2010 10:54:50 -0800, Jonathan M Davis
> > 
> > <jmdavisProg at gmx.com>  wrote:
> >> On Tuesday, November 16, 2010 07:53:01 Sean Kelly wrote:
> >>> bearophile Wrote:
> >>>> He also gives a quite useful unittest that the student implementation
> >>>> must pass, this is a good usage of unittests. The unit test ends like
> >>>> this:
> >>>> 
> >>>> ...
> >>>> 
> >>>>      writeln("unit test passed");
> >>>> 
> >>>> }
> >>>> 
> >>>> Indeed, a person needs feedback that the unittests have run (and have
> >>>> succeed), I have used similar things in my dlbs1 (but more refined).
> >>>> This kind of need for feedback is so natural that something like that
> >>>> will be better somehow done on default by D.
> >>> 
> >>> I'd like unit tests to be optionally named: unittest("name").  The rest
> >>> could then be done in library code.
> >> 
> >> That would indeed be great. With that done, it could become possible to
> >> run unit tests by name (though that would likely mean more changes for
> >> the compiler) in an IDE or whatnot. There's at least one bug report
> >> suggesting it, IIRC, though I think that it was suggested that they be
> >> named without the quotes. unittest(name) should probably translate to
> >> something like unittest_name in whatever scope it's in.
> >> 
> >> In any case, it's a good enhancement request that hasn't come to
> >> fruition yet. Most of the rest (if not all of it) could indeed be done
> >> in a library. Right now unit tests follow the unix convention of saying
> >> nothing on success, which I think is best for the current set up -
> >> particularly when it's not all that hard to add code yourself which
> >> prints out success if you really want it to.
> >> 
> >> - Jonathan M Davis
> > 
> > Already requested, see
> > http://d.puremagic.com/issues/show_bug.cgi?id=2749
> > 
> > Gide
> 
> I also agree having named unittests might be quite useful. I'm not sure
> about the nesting though, its seems to me using the D module itself as
> nesting is perfectly fine.

I see no point in nesting. Name unit tests, however, would make stack traces 
from unit tests actually useable (since you'd know which test they were from 
when they weren't actually assertion failures in the tests themselves which give 
you a line number in the tests), and it helps open the doors for allowing 
external tools to access them directly.

- Jonathan M Davis


More information about the Digitalmars-d-announce mailing list