http://hackage.haskell.org/package/properties-0.0.2

 <http://hackage.haskell.org/package/properties-0.0.2>Properties can
use QuickCheck properties in the same way than assertions are used,
for causal debugging of real programs. It also add an human readable
structure for grouping properties for classes or libraries. The
properties can then be tested in the instanceĀ“s body or in programs as
if they were assertions. The main advantage is that the compliance of
properties can be done with the complete data range that the real
application generates (hopefully, with an pleasant separation of real
code and debug code).

This is a simple example:


stringProperty= [Property
<http://hackage.haskell.org/packages/archive/properties/0.0.2/doc/html/Test-Properties.html#t%3AProperty>
"length" (\(x, y)-> length (x++y)== length x + length y)]


main= do
        let s=  "hello "
        let s2= "world"
        print $ s++ s2                 `verify
<http://hackage.haskell.org/packages/archive/properties/0.0.2/doc/html/Test-Properties.html#v%3Averify>`
stringProperty `with
<http://hackage.haskell.org/packages/archive/properties/0.0.2/doc/html/Test-Properties.html#v%3Awith>`(s,s2)
        print "that's all!"

It is possible to check quickCheck style properties.

 The same example with a quickCheck-style property:

quickCheckProperty x y=  length (x++y)== length x + length y

main= do
        let s=  "hello "
        let s2= "world"
        print $ s++ s2           `verify
<http://hackage.haskell.org/packages/archive/properties/0.0.2/doc/html/Test-Properties.html#v%3Averify>`
[Property "stringSumLength" $ uncurry quickCheckProperty] `with
<http://hackage.haskell.org/packages/archive/properties/0.0.2/doc/html/Test-Properties.html#v%3Awith>`(s,s2)
        print "that's all!"


The package include a more sophisticated example.

I Hope that this would be useful


Alberto
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to