unittesting generic functions
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Thu Aug 14 11:47:48 PDT 2014
On 08/14/2014 08:39 PM, Timon Gehr wrote:
> On 08/14/2014 08:26 PM, bearophile wrote:
>> Andrei Alexandrescu:
>>> Destroy https://issues.dlang.org/show_bug.cgi?id=13291?
>>
>> I'd like a way to test nested functions:
>> ...
>> void foo() {
>> int bar() { return 0; }
>>
>> unittest {
>> assert(bar() == 1);
>> }
>> }
>>
>> void main() {}
>> ...
> It is already possible, ...
Another way:
void foo(){
static int bar() { return 0; }
static struct T{ unittest{ assert(bar()==1); } }
}
void main() {}
More information about the Digitalmars-d
mailing list