QuickCheck is a Haskell library for software testing. It generates test cases and validates them against assertions provided by the programmer.
Questions tagged [quickcheck]
422 questions
1
vote
1 answer
QuickCheck with Dynamic Element Sets
Is there a way to control programmatically the set of values to use in an elements call within an arbitrary definition? I want to be able to generate an arbitrary variable reference as part of a random expression, but the set of variables…

Øystein Kolsrud
- 359
- 2
- 16
1
vote
1 answer
Generate a random string-date with QuickCheck
I need to generate a string of names-date separated by spaces, where the name is just a random length of characters and the date is just four numbers. For example:
"dfghjkl-1234 derftgyhjuik-5678"
Currently I have this solution:
genArgs :: Gen…

Cliff Stamp
- 531
- 5
- 11
1
vote
1 answer
Codewars (Haskell random testing QuickCheck)
I have this working code in the random testing part of a Kata:
it "handles randoms " $
property $ \x y -> updateHealth x y == if y > x then 0 else x-y
But I wanted the function signature to use Num, but when I did that I get an error because…

Cliff Stamp
- 531
- 5
- 11
1
vote
2 answers
context-sensitive generation using quick check
I would like to generate random terms based on some sort of "context" and I was wondering if this is possible using quickcheck. Basically I would like to have an additional data type passed around so that the arbitrary function can generate terms…

schmauss
- 53
- 3
1
vote
0 answers
How to generate random json diffs in haskell quickcheck
I need to test the framework that can observe the state of some json http resource (I'm simplifying a bit here) and can send information about its changes to message queue so that client of service based on this framework could reconstruct actual…

user1685095
- 5,787
- 9
- 51
- 100
1
vote
1 answer
How to fix ambiguity of an Arbitrary instance of a list-like type
Consider the following:
import Test.QuickCheck
import Test.QuickCheck.Checkers
import Test.QuickCheck.Classes
data List a = Nil | Cons a (List a) deriving (Eq, Show)
instance Functor List where
fmap _ Nil = Nil
fmap f (Cons a l) = Cons (f…

Jan Synáček
- 355
- 2
- 9
1
vote
1 answer
Using the quickCheckAll function in tasty-quickcheck
Short version: It is possible to use the quickCheckAll function in tasty-quickcheck?
Long version:
The quickCheckAll function tests all properties beginning with prop_ in the current module as shows the following example:
{-# LANGUAGE…

asr
- 1,166
- 6
- 18
1
vote
0 answers
Too many quickcheck permutations for nested JSON
I am following the example from this blog to test my JSON encoding/decoding and have run into an issue with deeply nested JSON. The JSON structure has too many permutations to successfully test with quickcheck. I ran into a similar issue with my…

anotherhale
- 175
- 1
- 6
1
vote
0 answers
Quickcheck specification DSL
I want to create a human readable DSL which non-haskell programmer could understand for creating specifications for black-box testing of external systems.
And I wonder if something like this is possible to do in Haskell.
action = readProcess "sleep…

user1685095
- 5,787
- 9
- 51
- 100
1
vote
1 answer
How to quickcheck applicative homomorphism property?
As an exercise, I am trying to quickCheck the applicative's homomorphism property:
pure f <*> pure x = pure (f x)
When I try to write the property in a general way using phantom types, I seem to run into endless 'Could not deduce' errors. At this…

mherzl
- 5,624
- 6
- 34
- 75
1
vote
2 answers
How to report failing test cases
I am using Haskell Test Framework through Stack to evaluate QuickCheck properties. When I run stack test, failing properties are reported in the form of Gave up! Passed only 95 tests. The many examples of property testing I've found report…
user7850864
1
vote
0 answers
QuickCheck and State monad
I have written a Haskell module that contains functions that operate on some state. Let's say that the code looks like this (the actual functions may return an actual result instead of (), but this is irrelevant to the question):
data StateContext =…

Boulougou
- 46
- 1
- 4
1
vote
1 answer
Abstracting Hspec tests
I am going through "Haskell programming from first principles" and I found myself writing code in the following fashion over and over:
type IntToInt = Fun Int Int
type TypeIdentity = ConcreteFunctorType Int -> Bool
type TypeComposition =…

D. Amoroso
- 170
- 2
- 10
1
vote
1 answer
How to write tests using QuickCheck for the definition of ($)
And also for composing function.
f $ a = f a
f . g = \x -> f (g x)

Jeremy Chen
- 17
- 5
1
vote
2 answers
Create an elements generator with an infinite list
I'm playing with QuickCheck, and stumbled upon some strange behavior
sample $ elements [1..5]
works as expected, however
sample $ elements [1..]
hangs in ghci, even when using a finite type such as Int
sample $ elements [(1::Int)..]
Why doesn't…

dimid
- 7,285
- 1
- 46
- 85