Disallow side effects in assert

bearophile bearophileHUGS at lycos.com
Mon Feb 3 18:43:47 PST 2014


Jesse Phillips:

> Aren't these things you might do inside a unittest?

Mutating state and calling impure functions is OK in an unittest. 
So this code is OK:


int foo(ref int y) pure nothrow {
     return y++;
}
unittest {
     int x;
     ++x;
     assert(x);
     foo(x);
     assert(x);
}


Bye,
bearophile


More information about the Digitalmars-d mailing list