Re: Unit testing with asserts: Why is assertHandler required to throw?

2010-01-31 Thread bearophile
Trip Volpe: > Ah ha! I din't know that D had __LINE__ and __FILE__. I thought those had > been done away with along with the preprocessor. It looks like they're a lot > smarter than in C as well, since this works just fine: > > test.d: > 1 void main() { > 2 printlocation();// prints "

Re: Unit testing with asserts: Why is assertHandler required to throw?

2010-01-31 Thread Trip Volpe
Pelle MÃ¥nsson Wrote: > > An assertion handler should be created for use in unittests. Preferably > with colorized output. :) > > I stole and changed slightly from std.contracts.enforce (untested) > > T test(T, string file=__FILE__, int line=__LINE__) > (T value, string message="T

Re: Unit testing with asserts: Why is assertHandler required to throw?

2010-01-31 Thread Nick Sabalausky
"Trip Volpe" wrote in message news:hk583n$28e...@digitalmars.com... > Nick Sabalausky Wrote: >> The deferAssert module (possible name change and other API improvements >> pending) of my SemiTwist D Tools library ( >> http://www.dsource.org/projects/semitwist ) is designed to get around >> those

Re: Unit testing with asserts: Why is assertHandler required to throw?

2010-01-31 Thread Trip Volpe
Nick Sabalausky Wrote: > The deferAssert module (possible name change and other API improvements > pending) of my SemiTwist D Tools library ( > http://www.dsource.org/projects/semitwist ) is designed to get around those > problems. Good to know I'm not the only one who's had to working around

Re: Unit testing with asserts: Why is assertHandler required to throw?

2010-01-31 Thread Trip Volpe
Lutger Wrote: > > You can use line and file info with default arguments, this works > (special case). I just hack around the default unittest system, > something like this: > > void test(string testName)(void delegate () testClosure, > int line = __LINE__, >

Re: Unit testing with asserts: Why is assertHandler required to throw?

2010-01-31 Thread Pelle Månsson
On 01/31/2010 09:39 PM, Trip Volpe wrote: I recently began porting an existing C++ project of mine (a compiler/interpreter for a dynamic language) to D. In the process I found that the built-in unit testing support, while an awesome concept, was a little bit sparse. In particular, assert() is

Re: Unit testing with asserts: Why is assertHandler required to throw?

2010-01-31 Thread Lutger
On 01/31/2010 10:04 PM, Nick Sabalausky wrote: "Lutger" wrote in message news:hk4r35$1hp...@digitalmars.com... You can use line and file info with default arguments, this works (special case). That must be a D2 thing, because I know it doesn't work in D1. Indeed, here is the change: htt

Re: Unit testing with asserts: Why is assertHandler required to throw?

2010-01-31 Thread Nick Sabalausky
"Lutger" wrote in message news:hk4r35$1hp...@digitalmars.com... > > You can use line and file info with default arguments, this works (special > case). That must be a D2 thing, because I know it doesn't work in D1.

Re: Unit testing with asserts: Why is assertHandler required to throw?

2010-01-31 Thread Lutger
On 01/31/2010 09:39 PM, Trip Volpe wrote: I recently began porting an existing C++ project of mine (a compiler/interpreter for a dynamic language) to D. In the process I found that the built-in unit testing support, while an awesome concept, was a little bit sparse. In particular, assert() is

Re: Unit testing with asserts: Why is assertHandler required to throw?

2010-01-31 Thread Nick Sabalausky
"Trip Volpe" wrote in message news:hk4pql$1eh...@digitalmars.com... >I recently began porting an existing C++ project of mine (a >compiler/interpreter for a dynamic language) to D. In the process I found >that the built-in unit testing support, while an awesome concept, was a >little bit spars

Unit testing with asserts: Why is assertHandler required to throw?

2010-01-31 Thread Trip Volpe
I recently began porting an existing C++ project of mine (a compiler/interpreter for a dynamic language) to D. In the process I found that the built-in unit testing support, while an awesome concept, was a little bit sparse. In particular, assert() is fairly useless for unit tests, since it thr