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
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
If you don't have GHC, hstest won't work. Sorry.
If you have GHC 6.10.x (except 6.10.0) or GHC 6.12.x (except 6.12.0), you can install it using cabal-install:
$ cabal install hstest
I have only tested it with GHC 6.10.1 and 6.12.1.
If you can't use cabal-install, you will have to install it manually:
- download it from Hackage
- extract the files into a temporary directory
- edit 'hstest.cabal' to reflect the version of GHC you have installed
$ ./Setup.lhs configure && ./Setup.lhs build && dist/build/hstest/hstest --expose-package ghc && sudo ./Setup.lhs install
Please tell me whether hstest works or not with your versions of GHC and other libraries.