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
0
votes
1 answer

Functor laws checking with QuickCheck-classes library

I want to check functor laws for instance: instance Functor Stream where fmap f (x :> xs) = (f x) :> fmap f xs where Stream is data Stream a = a :> Stream a I use QuickCheck.Classes (http://hackage.haskell.org/package/quickcheck-classes) to…
0
votes
2 answers

Is there any ways to traverse a random json string created by a generator in java?

I have a generator which is generating a completely json scripts with random keys and values(quickcheck.generator). I want to read this string and get the values of the keys. The problem is that each time, a new json string is creating with…
0
votes
1 answer

quickCheck returns error when comparing zipWith functions

I created my own myzipWith function and want to compare it with the original zipWith with the use of quickCheck. myzipWith :: (a -> b -> c) -> [a] -> [b] -> [c] myzipWith a y [] = [] myzipWith a [] y = [] myzipWith a (x:xs) (z:zs) = [a x z] ++…
0
votes
1 answer

Is there any way to generate values for testing this way in Haskell QuickCheck?

I have 2 data types that I use for the representation of natural numbers in the unary system data Valoare_Unar = Unu deriving(Show); data Numar_Unar = Invalid | Unar [Valoare_Unar] deriving(Show); I have those functions for converting this number…
0
votes
1 answer

How to test functions that assume their inputs come from smart constructors?

tl;dr I'd like to understand how to use Test.QuickCheck to test functions whose arguments are passed to smart constructors and/or assumed as coming out of a smart constructor. Long version In a module I have a user defined type like this: newtype…
Enlico
  • 23,259
  • 6
  • 48
  • 102
0
votes
1 answer

Why does QuickCheck take a long time when testing a Functor instance with a specific type signature?

I'm working through the wonderful Haskell Book. While solving some exercises I ran QuickCheck test that took a relatively long time to run and I can't figure out why. The exercise I am solving is in Chapter 16 - I need to write a Functor instance…
javinor
  • 674
  • 4
  • 8
0
votes
1 answer

python-quickcheck: error fixture not found

I'm trying to use the python-quickcheck library, and I just wrote a super simple test inspired by the official documentation: #!/usr/bin/env python3 import pytest @pytest.mark.randomize(min_num=0, max_num=2, ncalls=5) def…
tobiasBora
  • 1,542
  • 14
  • 23
0
votes
1 answer

How to generate hidden instance for data field which type is Generic

I looking for a safe way to generate instance for a data type which has fields without a deriving class, but such fields have Generic instance. I think it is very popular case for testing with QuickCheck, cause every type should have…
Daniil Iaitskov
  • 5,525
  • 8
  • 39
  • 49
0
votes
1 answer

QuickCheck Arbitrary instance for abstract data type with smart constructor

I am new to the language, trying to write my first non-trivial program. On the way, I am stuck creating an Arbitrary instance. Yet, I suppose my question to follow points at my general lack of understanding composing several applicative and monadic…
Ulrich Schuster
  • 1,670
  • 15
  • 24
0
votes
0 answers

QuickCheck property with type [Int] -> Property

I'm very new to QuickCheck. I know how to write QuickCheck properties like : prop_rev_involutive l = (reverse $ reverse l) == l that test the reverse function. But now I need to write a QuickCheck property with this signature…
Tomer
  • 1,159
  • 7
  • 15
0
votes
0 answers

Using QuickCheck for testing if a list is shuffled

I need to use QuickCheck to check if a list of integers is truly shuffled prop_fastShuffle_correct :: [Int] -> Property prop_fastShuffle_correct s = ??? My shuffle function has this signature: fastShuffle :: [a] -> IO [a] No need to go for full…
Tomer
  • 1,159
  • 7
  • 15
0
votes
1 answer

Haskell QuickCheck generating values within a function

How do I get this contrived example to work? newtype Q = Q [Int] instance Arbitrary Q where arbitrary :: Gen Q arbitrary = do len <- choose (1, 5) pure $ g len (\ i -> i + choose (0, 1)) -- want different choice for each…
puzzled
  • 77
  • 4
0
votes
1 answer

error[E0599]: no method named `gen` found for type `&mut G` in the current scope

I'm trying to use the quickcheck crate. I've implemented Arbitrary for the struct Point {x: u32, y: u32} impl Arbitrary for Point { fn arbitrary(g: &mut G) -> Point { let x = g.gen::(); let y = g.gen::(); …
russelldb
  • 21
  • 4
0
votes
1 answer

Haskell: Understanding QuickCheck with higher order function

I have the function foo: foo :: [a] -> (a -> b) -> [b] foo [] f = [] foo (x:xs) f = foo xs f And the following two properties that it must satisfy: prop_1 :: [Int] -> Bool prop_1 xs = foo xs id == xs prop_2 :: [Int] -> (Int -> Int) -> (Int ->…
0
votes
1 answer

How to run a specific number of tests in QuickCheck?

I am trying to learn Haskell and specifically QuickCheck. While Haskell has a lot of information online I am struggling to create some random test with QuickCheck. For example, I have the following script: import Test.QuickCheck whatAge :: Int ->…
Andi Domi
  • 731
  • 2
  • 19
  • 48