Am 28.01.2011 13:30, schrieb spir: > On 01/28/2011 12:36 PM, bearophile wrote: > >> I think the problem here is that you are not using your D tools well enough >> yet: >> - Preconditions allow you to save some tests in your unittests, because you >> have less need to test many input boundary conditions. >> - Postconditions are useful to save some code to test the correctness of the >> results inside your unittests. You still need to put many tricky but correct >> input conditions inside your unittests, but then the postcondition will test >> that the outputs are inside the class of the correct outputs, and you will >> need less unittest code to test that the results are exactly the expected >> ones >> in some important situations. > > Very intersting points, thank you. > >> - The missing "old" feature once somehow implemented allows to remove some >> other unittests, because you don't need a unittest any more to test the >> output >> is generally correct given a certain class of input. > > What is this "old" feature?
if you've got a function fun(int x){ ... ; x++; ... } then you can use old.x (or something like that) in the dbc block at the end to access the original value of x. like assert(x == old.x+1) or something like that. after hearing about dbc in university I thought that having old was fundamental for dbc.. but D doesn't support it. Cheers, - Daniel