Questions tagged [quickcheck]

QuickCheck is a Haskell library for software testing. It generates test cases and validates them against assertions provided by the programmer.

422 questions
6
votes
2 answers

Can't define custom `Arbitrary` instance for `Char` since it already exists

I tried following the Introduction to Quickcheck and wanted to test my function which takes strings containing of digits. For that, I defined an Arbitrary instance for Char: instance Arbitrary Char where arbitrary = choose ('0', '9') But ghc…
Turion
  • 5,684
  • 4
  • 26
  • 42
6
votes
1 answer

Haskell: QuickCheck property fails tests using implications

I've got the following property I want to test using quickcheck: prop_zip xs ys = length xs == length ys ==> unzip (zip xs ys) == (xs,ys) Eventhough it seems to be logically right according to the definition of zip and unzip, that this…
David
  • 75
  • 3
6
votes
4 answers

How to set constant seeds for Haskell's quickCheck function

Every time I run "quickCheck prop_xyz", a new random seed is used. How do I enforce QuickCheck to always use the same random seed? Thanks!
user1546806
  • 137
  • 6
6
votes
2 answers

Haskell QuickCheck generate random data for function with many input variables

I have a function with the following type signature rndListIndex :: Double -> Double -> Double -> Double rndListIndex maxIdx r1 r2 = … the first input should be a value coming from a non-negative strictly positive integer the second and third…
epsilonhalbe
  • 15,637
  • 5
  • 46
  • 74
6
votes
3 answers

Using quickCheck

I wrote an implementation for foldl and wanted to check if it worked, I tried some cases and it seems to be working well but I want to make sure. I read about quickCheck and tried it, but I can't seem to make it work, this is the code foldl'' :: (b…
chamini2
  • 2,820
  • 2
  • 24
  • 37
6
votes
1 answer

Using a custom generator vs Arbitrary instance in QuickCheck

Here's a simple function. It takes an input Int and returns a (possibly empty) list of (Int, Int) pairs, where the input Int is the sum of the cubed elements of any of the pairs. cubeDecomposition :: Int -> [(Int, Int)] cubeDecomposition n = [(x,…
jtobin
  • 3,253
  • 3
  • 18
  • 27
6
votes
1 answer

Quickcheck for non-boolean tests

I am using QuickCheck to test my code for some numeric calculations. Basically I have an exact function and several approximations of it that are much more efficient. I'm currently implementing the properties I want to test something…
Mike Izbicki
  • 6,286
  • 1
  • 23
  • 53
5
votes
3 answers

SIMPLE random number generation

I'm writing this after a good while of frustrating research, and I'm hoping someone here can enlighten me about the topic. I want to generate a simple random number in a haskell function, but alas, this seems impossible to do without all sorts of…
JaimeBarrachina
  • 430
  • 8
  • 21
5
votes
1 answer

What exactly is the "size" parameter in QuickCheck?

The size parameter is used in many functions in quickcheck. But I am having difficulty understanding what it is exactly. What does getSize return?
sinoTrinity
  • 1,125
  • 2
  • 15
  • 27
5
votes
1 answer

Custom QuickCheck failed message

test1 = hspec $ do describe "blabla" $ do it "should be equl" $ verbose $ \input-> ... In the above code, when a test failed, it prints the failed input. But I'm actually interested in another value that can be calculated from input.…
McBear Holden
  • 805
  • 4
  • 14
5
votes
1 answer

Dependent shrinking in QuickCheck

I'm faced with the problem of writing a shrinking function for a generator that depends of the value (s) output by another one. Basically a generator of the form: do a <- genA b <- f a pure $! g a b where genA :: Gen a, f :: a -> Gen b g :: a…
Damian Nadales
  • 4,907
  • 1
  • 21
  • 34
5
votes
2 answers

Arbitrary instance for TimeOfDay

Using QuickCheck, I'd like to create a series of pseudorandom TimeOfDay values. It's easy to create a specific TimeOfDay: now = TimeOfDay 17 35 22 Printing this with GHCi 8.6.5 yields: 17:35:22 I thought that the Arbitrary instance necessary for…
Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
5
votes
2 answers

Could not find module ‘Test.QuickCheck’ on Windows

My ghci version is 8.4.3 I tried stack install QuickCheck Something was installed. But when I input import Test.QuickCheck, it tells Could not find module ‘Test.QuickCheck’ again. How can I fix it?
user8314628
  • 1,952
  • 2
  • 22
  • 46
5
votes
1 answer

How to use QuickCheck in Hspec tests?

I build the initial codebase for my Haskell project with cabal init I have several tests written with Hspec. On cabal test it compiles and runs these tests like expected and gives a message for failing/passing. Now I included a quickCheck test and…
5
votes
0 answers

How can I QuickCheck value wrapped by effect in PureScript?

I have a shuffle function for Array: shuffle:: forall e. Array -> Eff (random :: RANDOM | e) Array It shuffles an array in a Control.Monad.Eff.Random monad and returns the wrapped one. I want to test the array is shuffled, like to compare the…
snowmantw
  • 1,611
  • 1
  • 13
  • 25