[Haskell-cafe] Type System vs Test Driven Development

Henning Thielemann lemming at henning-thielemann.de
Wed Jan 12 13:18:03 CET 2011


On Wed, 12 Jan 2011, Serge Le Huitouze wrote:

> Also, I wonder how you guys do when you're trying to tests code
> using a lot of  numbers (be them floating point or even integer).

Machine size integers and floating point numbers are indeed nasty. I test 
a lot in NumericPrelude with QuickCheck, but then I test on Integers and 
Rationals in order to see whether my algorithms are in principle correct. 
I can test floating point algorithms only with approximate equality tests 
and finding general valid tolerances is difficult, as you pointed out.


> E.g., integers:
> A code doing addition and substraction of some sort.
> A property such as "X = (X add Y) sub Y" is easily falsifiable when
> the number of bits of your integer is too small for your numbers.

Since fix-width words represent modulo-arithmetic, your law would even 
hold in case of overflows.



More information about the Haskell-Cafe mailing list