[Haskell-cafe] Announce: Properties-0.0.2

Alberto G. Corona agocorona at gmail.com
Sun Jun 13 15:58:32 EDT 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100613/12c2d8c0/attachment.html


More information about the Haskell-Cafe mailing list