Unit tests in D

Walter Bright newshound1 at digitalmars.com
Wed May 5 17:25:45 PDT 2010


bearophile wrote:

> 
> But the "specs" of the Range template say that Range must not work if step is zero (this means that the unittest has to fail if Range compiles when the given step is zero). So I have to test this too. I can do that with one more unittest (D1 code):
> 
>     static assert(!is(typeof( Range!(15, 3, 0) )));
> 
> In D2 I can use the __traits:
> 
>     static assert(!__traits(compiles, Range!(15, 3, 0) ));

Oh, I see. You want to ensure it does not compile, rather than it compiles. I 
got the ! flipped around.


More information about the Digitalmars-d mailing list