[dmd-internals] changeset 455

Steve Schveighoffer schveiguy at yahoo.com
Mon May 3 18:07:12 PDT 2010





----- Original Message ----
> From: Walter Bright <walter at digitalmars.com>
>
> I'm reluctant to transform 
> all asserts because:
> 
> 1. this means all asserts, whether meant for unit 
> testing or not, have to have return code, negatively affecting optimization all 
> the time
> 
> 2. many asserts are not meant at all to be unit tests, and 
> there's no reason to think otherwise when they are outside the unittest 
> block

We're forgetting 2 things here:

1. unit tests run independently of any user input, they are completely defined by the unit test code itself.

2. Nobody, and I mean nobody, should ever compile unittest code for production.  In fact, I'd say you probably have not understood the meaning of unit tests if your main function looks anything unlike:

void main() {}

Therefore, you shouldn't be concerned with the optimization quality of unittest code during asserts.

What if we solve this with a completely global solution -- when compiling with unit tests enabled, all asserts do a unittest style assert (decided at link), when compiling without unittests, asserts function as they do now.  Can this be done?

-Steve



      


More information about the dmd-internals mailing list