[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Re: Integrating unit tests into source code
From: |
Thomas Christian Chust |
Subject: |
Re: [Chicken-users] Re: Integrating unit tests into source code |
Date: |
Fri, 15 Dec 2006 18:05:21 +0100 |
User-agent: |
Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; de-AT; rv:1.8.0.8) Gecko/20061030 SeaMonkey/1.0.6 |
Brandon J. Van Every wrote:
> Thomas Christian Chust wrote:
>
>> [...]
>> all the contract based programming systems I know don't come up with a
>> specific language for describing the contracts. I usually see contract
>> based programming systems as syntactic sugar allowing you to specify
>> arbitrary code which will be run upon entry to and exit from a function.
>>
>
> How is that better than just writing tests then?
Hello,
it's not better, but there is an important difference in the mode of
operation.
Unit tests are usually bundled into a test driver program -- either by
hand or by some automatism -- that is run once every time the code
changes to find any possible bugs in your library functions. The
important point is that each unit test you wrote is *run exactly once*
by the test driver program.
Contracts are compiled into the library itself when they are enabled and
they get *run every time the functions they belong to are called*.
So while tests are good for feeding your functions some pathological
inputs to see whether they still work, contracts are great to determine
whether the functions *and their callers* behave correctly during normal
operation of the final program -- and maybe to discover more
pathological cases to check for in the test suite ;-)
Actually we already have the choice to disable some kind of contract
checking in CHICKEN by using the unsafe runtime libraries.
cu,
Thomas
- Re: [Chicken-users] Integrating unit tests into source code, (continued)
Re: [Chicken-users] Integrating unit tests into source code, Kon Lovett, 2006/12/14