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
How to use ByteStrings with QuickTest in DocTest?
How do I define the Arbitrary instance (as stated here) when using doctest and quickcheck?
Doctest and Cabal are set up as described here with a separate directory for tests.
The doctest line looks like this:
-- prop> (\s -> (decode . encode $ s ==…

fho
- 6,787
- 26
- 71
1
vote
3 answers
Testing not equal in Quickcheck?
I'm new to QuickCheck and can't quite wrap my head around how to use it.
Let's say I accidentally implemented a data-type with a Set (instead of a List):
data Profile = Profile (Set Strategy)
--for completeness:
data Strategy = Strategy Int
and…

Andriy Drozdyuk
- 58,435
- 50
- 171
- 272
1
vote
0 answers
Haskell quickcheck issue
I am writing a simple test using quickcheck.
import Test.QuickCheck
f :: Int -> Int
f x
| x < 0 = (-x)
| otherwise = x
main = do
putStrLn "Testing"
quickCheck ((\x -> ((f x) >= 0)) :: Int -> Bool)
Whenever I run…

rsinha
- 2,167
- 3
- 18
- 17
1
vote
1 answer
QuickCheck NonEmpty String - listOf
i am learning quickcheck(and haskell too), i have de bellow code:
newtype Urls = FN { unFN :: String } deriving Show
instance Arbitrary Urls where
arbitrary = do protocol <- elements ["http://"]
name <- listOf $ elements ['a'..'z']
…

Édipo Féderle
- 4,169
- 5
- 31
- 35
0
votes
1 answer
where is function generate in Haskell Platform 2011.2.0.1
would like to print a random number between 0 and 10, but generate seems undefined
can not be compiled, the following code edited from example
i am using Haskell Platform 2011.2.0.1
Updated:
import System.IO
import System.Random
import…

M-Askman
- 400
- 4
- 17
0
votes
1 answer
How to write a Quickcheck property for ANSI escaped coded string parser?
Please consider the following piece of code:
-- Represents a parsing result of an ANSI coded string.
data Slice = Slice
{ text :: String,
color :: Color
}
newtype Color = Color
{ string :: String
}
-- A function that receives a string…

Refael Sheinker
- 713
- 7
- 20
0
votes
0 answers
Issues with installing QuickCheck
I am having issues with installing QuickCheck for Haskell using GHC 9.4.4 and GHC 8.8.4, and I get the same output. Any assistance would be greatly appreciated!
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] next goal: ghc…

OwlZeroOne
- 1
- 1
0
votes
1 answer
How to constraint quickcheck test argument to be non-empty in Rust
I am trying to write a test which depends on non-empty vector of tuples as an argument but unsure of how to add such a constraint using quickcheck.
#[quickcheck]
fn graph_contains_vertex(vs: Vec<(u64, i64)>) {
// ...
let rand_index =…

iamsmkr
- 800
- 2
- 10
- 29
0
votes
1 answer
Quickcheck Applicative homomorphism law for Binary Tree
I am aware that the following question exists:
haskell - How to quickcheck applicative homomorphism property? - Stack Overflow
However, the introduction of the following PRAGMA
{-# LANGUAGE ScopedTypeVariables #-}
didn't solve my issue.
These are…

F. Zer
- 1,081
- 7
- 9
0
votes
1 answer
Using QuickCheck properties with coverage inside a monadic context
I'm trying to write a QuickCheck property that uses cover to make sure that the test data covers certain cases in combination with the fact that the test involves an IO action.
The problem essentially boils down to the following:
prop = do
res <-…

l7r7
- 1,134
- 1
- 7
- 23
0
votes
1 answer
How do you run a single test with QuickCheck when using monadicIO in Haskell?
I am using QuickCheck as a test suite in Haskell. I want to run a single test that is always the same in the IO Monad.
The problem is that QuickCheck generates 100 tests automatically even though the test does not take any parameters. As an example…

Terra
- 100
- 1
- 8
0
votes
1 answer
QuickCheck Stack Overflow
I have the following struct:
pub struct Restriction {
pub min: Option,
pub max: Option,
}
for which I have defined Arbitrary as follows:
impl Arbitrary for Restriction {
fn arbitrary(g: &mut Gen) -> Self {
let x =…

James Burton
- 746
- 3
- 12
0
votes
1 answer
How to configure QuickCheck with cabal?
I'm learning to build a Haskell package. One thing I'm stuck with is running tests with QuickCheck.
Specifically, how can I configure the number of trials to run?
Here is my test file (Test.hs) with a dummy test:
module Main where
import…

Hongtao Yang
- 381
- 3
- 14
0
votes
1 answer
How to make the property test get a collection of entities an entity-generator can return?
I have recently started exploring property based testing using junit-quickcheck. I came across an usecase where a property has to take a list of entities(I have a generator for a standalone entity). I have tried with the code below and it always…

Kranthi
- 37
- 6
0
votes
1 answer
Haskell QuickCheck runs slowly
I am learning Haskell and recently worked on a small project to mimic arithmetics in the way how human does it, ultimately I can keep as many decimal places as I want and computation results are not subject to the float precision issue. I also tried…

dhu
- 718
- 6
- 19