Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

verboseCheck in QuickCheck 2?

The function verboseCheck from QuickCheck 1 seems to be absent in QuickCheck 2 (or at least, I can't find it). Is there any other way to show which values are used during testing?

like image 340
Alexey Romanov Avatar asked Mar 25 '10 16:03

Alexey Romanov


People also ask

How do I import a QuickCheck into ghci?

If you want to use QuickCheck in a command such as stack ghci or stack ghc , you can add it as a --package option e.g. to run a REPL to play around with QuickCheck you can use stack ghci --package QuickCheck and then write import Test. QuickCheck .

What is QuickCheck in Haskell?

QuickCheck is a software library, specifically a combinator library, originally written in the programming language Haskell, designed to assist in software testing by generating test cases for test suites – an approach known as property testing.

Is Haskell QuickCheck static?

Haskell is a statically-typed functional programming language: Haskell type declarations are identified and checked during compilation, guaranteeing that program semantics are known by the designers before execution or possibly even before the implementation.


2 Answers

The sample function is also useful:

Prelude Test.QuickCheck
ghci> sample (arbitrary :: Gen String)
""
")\223"
"(\227\&5F"
"\DC1"
"\136'\140\180\FS"
"K\DC2\NUL\CAN\253Q"
"\DC4\f\184&.\DC3\159\&1I\160j\147"
....

This way, it's easy to play with your Arbitrary instances, and make sure they generate what you think they generate.

like image 87
jrockway Avatar answered Oct 25 '22 18:10

jrockway


Yes, this seems to be a functionality regression with respect to QuickCheck 1.

You can work around it by annotating your properties with a Debug.Trace.trace statement, however. Something like:

import Debug.Trace

prop_eq xs = traceShow xs $ 
   xs == reverse (reverse xs)
like image 42
Don Stewart Avatar answered Oct 25 '22 19:10

Don Stewart