Unit testing with asserts: Why is assertHandler required to throw?
bearophile
bearophileHUGS at lycos.com
Sun Jan 31 23:41:01 PST 2010
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 "test.d:2" (as opposed to "test.d:5")
> 3 }
> 4
> 5 void printlocation( string file = __FILE__, int line = __LINE__ ) {
> 6 writefln( "%s:%d", file, line );
> 7 }
>
> This still feels a little more hacky than I'd like, but it should do. Thanks! :-)
It looks like the bad special cased magic you can find in Perl :-)
Bye,
bearophile
More information about the Digitalmars-d
mailing list