The hstest package

[Tags: bsd3, program]

hstest looks through all Haskell source files in the current directory (by default), runs all properties via QuickCheck 1 (properties must have a name that starts prop_), and runs all tests via HUnit (tests must have a name that starts test_).

For example, suppose you have this Haskell source file called mysort.hs:

 mySort xs = ... -- a function you wish to test (definition elided)

 prop_lengthStaysTheSame xs = length xs == length (mySort xs)
 prop_sumStaysTheSame xs = sum xs == sum (mySort xs)
 prop_lowestElementAtStart, prop_highestElementAtEnd :: [Int] -> Bool
 prop_lowestElementAtStart xs = not (null xs) ==> minimum xs == head (mySort xs)
 prop_highestElementAtEnd xs = not (null xs) ==> maximum xs == last (mySort xs)

Then to check all these tests, you run

 $ hstest
 Failed prop_highestElementAtEnd:
  *  [-3,2,-2]
 mysort.hs: Failed 1 property, passed 3 properties

Oops! Fix mySort and try again:

 $ hstest
 mysort.hs: Passed 4 properties

Properties

Versions0.0.0, 0.0.1
Dependenciesbase (>=4.0.0 && <4.3), directory (>=1.0.0 && <1.1), filepath (>=1.1.0 && <1.2), ghc (>=6.10.1 && <6.12), ghc-paths (>=0.1.0 && <0.2), HUnit (>=1.2.0 && <1.3), mtl (>=1.1.0 && <1.2), QuickCheck (>=1.2.0.0 && <1.3), random (>=1.0.0 && <1.1) or
base (>=4.0.0 && <4.3), directory (>=1.0.0 && <1.1), filepath (>=1.1.0 && <1.2), ghc (>=6.12.1 && <6.14), ghc-paths (>=0.1.0 && <0.2), HUnit (>=1.2.0 && <1.3), mtl (>=1.1.0 && <1.2), QuickCheck (>=1.2.0.0 && <1.3), random (>=1.0.0 && <1.1)
LicenseBSD3
Copyright© Dave Hinton, 2010; portions © Koen Claessen
AuthorDave Hinton
MaintainerDave Hinton <beakerchu@googlemail.com>
Stabilityalpha
CategoryTesting
Home pagehttp://bitbucket.org/dave4420/hstest/wiki/Home
Bug trackerhttp://bitbucket.org/dave4420/hstest/issues?status=new&status=open
Executableshstest
Upload dateTue Jun 15 01:25:57 UTC 2010
Uploaded byDaveHinton
Downloads150 total (11 in last 30 days)

Downloads

Maintainers' corner

For package maintainers and hackage trustees