On Sat, 17 Jan 2015 00:38:08 +0000 Luc Bourhis via Digitalmars-d <[email protected]> wrote:
> Testing constness implementation is easy: > > const Foo a; > a.non_const_method(); // <<< compilation fails > > but how would I catch that in a unittest? i don't think that you can do it with one command, but at least you can use `__trait(compiles, ...)` to check if it compiles. and if it's not, you can either assume that the test is passed, or investigate the thing further, examining the type of `a` (using `isMutable!`, for example), or creating `Unqual!(typeof(a)) aa` and try "compiles" with it. it can be done with cool and hard to decipher template to ease your life. just don't forget to document what that template intended to so, so you will not force to reverse-engineer it later. ;-)
signature.asc
Description: PGP signature
