Running unittests of a module with -betterC

jmh530 john.michael.hall at gmail.com
Wed Oct 30 15:09:40 UTC 2019


On Tuesday, 29 October 2019 at 08:45:15 UTC, mipri wrote:
> [snip]
>
> -unittest sets the 'unittest' version identifier. So this works:
>
>   unittest {
>      assert(0);
>   }
>
>   version(unittest) {
>       extern(C) void main() {
>           static foreach(u; __traits(getUnitTests, 
> __traits(parent, main)))
>               u();
>       }
>   }
>
> dmd -betterC -unittest -run module.d

I feel like this should be added into the compiler so that it 
just works.


More information about the Digitalmars-d-learn mailing list