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]

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]

Properties

Versions0.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
Change logNone available
Dependenciesbase (==4.9.*), leancheck, speculate, template-haskell [details]
LicenseBSD-3-Clause
AuthorRudy Matela
MaintainerRudy Matela <rudy@matela.com.br>
CategoryTesting
Home pagehttps://github.com/rudymatela/extrapolate#readme
Source repositoryhead: git clone https://github.com/rudymatela/speculate
this: git clone https://github.com/rudymatela/speculate(tag v0.0.1)
UploadedTue Aug 1 13:51:21 UTC 2017 by rudymatela

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees


Readme for extrapolate-0.0.1

[back to package description]

Extrapolate

Extrapolate Build Status Extrapolate on Hackage

Extrapolate automatically generalizes counter-examples to test properties.

Example

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
  where
  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]
Generalization:
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.