POV-Ray : Newsgroups : povray.off-topic : Unit tests : Re: Unit tests Server Time
4 Sep 2024 09:19:21 EDT (-0400)
  Re: Unit tests  
From: Darren New
Date: 3 Jun 2010 20:01:25
Message: <4c084255$1@news.povray.org>
Nicolas Alvarez wrote:
> Darren New wrote:
>> Warp wrote:
>>> Orchid XP v8 <voi### [at] devnull> wrote:
>>>> Eiffel has preconditions *and* postconditions, which most people don't
>>>> seem to bother checking with assert() calls.
>>>   A little thought experiment: How would you write a comprehensive
>>> postcondition to a function that sorts a list/array of elements?
>> Trivial.
>>
>> Forall(i < length-1) assert(j[i]<=j[i+1]);
>>
>> Basically, the definition of sorting. Of course, you need to be able to
>> put qualifiers in your assertions.}
> 
> A sorting function that, given any input, returns [1,2,3,4,5], will pass 
> that test.

Heck, for that matter anything returning a zero-length array would pass. OK, 
to be *comprehensive*, you would have to add that the result is a 
permutation of the original. You could do this by counting how many times 
each original value occurs in the list and making sure it occurs in the 
result the same number of times.

-- 
Darren New, San Diego CA, USA (PST)
    Eiffel - The language that lets you specify exactly
    that the code does what you think it does, even if
    it doesn't do what you wanted.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.