Re: unittests and templates

2010-05-13 Thread Steven Schveighoffer
On Wed, 12 May 2010 18:54:20 -0400, bearophile wrote: Steven Schveighoffer: class ArrayList(V) { V take() {...} unittest { auto al = new ArrayList!uint; ... That unit test is the test of just take(). [snip] I don't have other ideas for you. Right now, I'm doing f

Re: unittests and templates

2010-05-12 Thread bearophile
Steven Schveighoffer: > class ArrayList(V) > { > V take() {...} > unittest > { >auto al = new ArrayList!uint; > ... That unit test is the test of just take(). To denote it in my code I add a comment: class ArrayList(V) { V take() {...} unittest { // Test of take() .

Re: unittests and templates

2010-05-11 Thread Steven Schveighoffer
On Tue, 11 May 2010 16:06:31 -0400, Steven Schveighoffer wrote: The ugly solution is to use static if like so: static if(isIntegral!V) { unittest { } } But that is, well, ugly. I found a less ugly solution -- remove the braces: static if(isIntegral!V) unittest { ... } Th

unittests and templates

2010-05-11 Thread Steven Schveighoffer
A cool thing I learned on the way to d2. unittests can be templatized just like the classes/structs they reside in. When enhancing dcollections with lots of detailed unit tests, I was doing things like this: class ArrayList(V) { V take() {...} unittest { auto al = new ArrayL