random k-sample of a file

Christopher Wright dhasenan at gmail.com
Sat Oct 11 07:52:17 PDT 2008


Andrei Alexandrescu wrote:
> Christopher Wright wrote:
>> Andrei Alexandrescu wrote:
>>>     enforce(k > 0, "Must pass a strictly positive selection size");
>>
>> Out of curiosity, why are you using enforce rather than assert?
> 
> Enforce is never ignored, even in production builds. You wouldn't want a 
> release build of your app to skip checking command line arguments.

True -- I forgot about that.

>> I've written an assertions framework, but it provides some more 
>> options than assert:
>>
>> expect.because ("Must pass a strictly positive selection size").that 
>> (k).greaterThan (0);
>>
>> If that failed, it would produce:
>> AssertionException: Expected: greater than 0 but was: -4 -- Must pass 
>> a strictly positive selection size
> 
> That looks pretty darn nice.
> 
> 
> Andrei

If you want it, the code's in a public subversion repository:
http://svn.dsource.org/projects/dmocks/dunit/trunk/
modules dunit.expect and dunit.constraint

Currently BSD licensed, but if anyone wants it in a different license, 
that's up for negotiation. Though I think it would take some effort to 
make it work with Phobos.



More information about the Digitalmars-d mailing list