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]):

  • [0,0] is a counter-example;

  • x:x:_ is a generalized counter-example.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 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 && <4.10), 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
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 8948 total (49 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

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.