extrapolate: generalize counter-examples of test properties

[ bsd3, library, testing ] [ Propose Tags ]

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 [RSS] [faq] 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
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:52:26Z
Distributions LTSHaskell:0.4.6, NixOS:0.4.6, Stackage:0.4.6
Downloads 7572 total (66 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user
Build status unknown [no reports yet]




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.