www.digitalmars.com         C & C++   DMDScript  

D - postconditions?

reply Evan McClanahan <evan dontSPAMaltarinteractive.com> writes:
Is there any way to do tests on out/inout stuff that gets changed in 
functions in the function postconditions?  Although I guess you can use 
other contracts to get around this lack, I think that it would be nice 
to be able to test them in the postcondition code, so that all of the 
tests for the functions are in the same place.

Evan
Dec 18 2002
next sibling parent Russell Lewis <spamhole-2001-07-16 deming-os.org> writes:
Evan McClanahan wrote:
 Is there any way to do tests on out/inout stuff that gets changed in 
 functions in the function postconditions?  Although I guess you can use 
 other contracts to get around this lack, I think that it would be nice 
 to be able to test them in the postcondition code, so that all of the 
 tests for the functions are in the same place.
 
 Evan

Are you talking about testing the effects of a function, not just the result? That might be better tested in a unittest function that runs the function many times with different inputs and then checks the result. I think (not 100% sure) that you can defined multiple unittests in a single module; I would write the unittest right next to the function declaration.
Dec 18 2002
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
Yes, just put the assert's in the out { } block.

"Evan McClanahan" <evan dontSPAMaltarinteractive.com> wrote in message
news:atq57d$2nr6$1 digitaldaemon.com...
 Is there any way to do tests on out/inout stuff that gets changed in
 functions in the function postconditions?  Although I guess you can use
 other contracts to get around this lack, I think that it would be nice
 to be able to test them in the postcondition code, so that all of the
 tests for the functions are in the same place.

 Evan

Dec 18 2002
parent Evan McClanahan <evan dontSPAMaltarinteractive.com> writes:
Walter wrote:
 Yes, just put the assert's in the out { } block.

That's odd, I could have sworn that didn't work before. Sorry... Evan
Dec 19 2002