extrapolate: generalize counter-examples of test properties

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Extrapolate is a tool able to provide generalized counter-examples of test properties where irrelevant sub-expressions are replaces with variables.

For the incorrect property xs -> nub xs == (xs::[Int]):

[Skip to Readme]


Versions 0.0.1, 0.0.1, 0.1.0, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4.0, 0.4.1, 0.4.2, 0.4.4, 0.4.6
Change log None available
Dependencies base (==4.9.*), leancheck, speculate, template-haskell [details]
License BSD-3-Clause
Author Rudy Matela
Maintainer Rudy Matela <rudy@matela.com.br>
Category Testing
Home page https://github.com/rudymatela/extrapolate#readme
Source repo head: git clone https://github.com/rudymatela/speculate
this: git clone https://github.com/rudymatela/speculate(tag v0.0.1)
Uploaded by rudymatela at 2017-08-01T13:51:21Z




Maintainer's Corner

For package maintainers and hackage trustees

Readme for extrapolate-0.0.1

[back to package description]


Extrapolate Build Status Extrapolate on Hackage

Extrapolate automatically generalizes counter-examples to test properties.


Consider the following (faulty) sort function and property:

sort :: Ord a => [a] -> [a]
sort [] = []
sort (x:xs) = sort (filter (< x) xs)
           ++ [x]
           ++ sort (filter (> x) xs)

prop_sortCount :: Ord a => a -> [a] -> Bool
prop_sortCount x xs = count x (sort xs) == count x xs
  count x = length . filter (== x)

Extrapolate both returns a fully defined counter-example along with a generalization:

> import Test.Extrapolate
> check (prop_sortCount :: Int -> [Int] -> Bool)
*** Failed! Falsifiable (after 4 tests):
0 [0,0]
x (x:x:xs)

This hopefully makes it easier to find the source of the bug. In this case, the faulty sort function discard repeated elements.

More documentation

For more examples, see the eg folder.