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
1
vote
1 answer

QuickCheck to Generate from Static Permutations List

Say that I have the data types: data A = A1 | A2 | A3 data B = B1 A | B2 A I can easily generate a list of all possibilities of B. I want to test all possible permutations, but I still want to use QuickCheck to spit out all the elements of the…
GreenSaguaro
  • 2,968
  • 2
  • 22
  • 41
1
vote
1 answer

Generate edges from an Arbitrary list of nodes

data Edge v = Edge {source :: v, target :: v} deriving (Show,Eq,Ord) data Graph v = Graph {nodes :: Set v, edges :: Set (Edge v)} deriving Show instance Arbitrary v => Arbitrary (Edge v) where arbitrary = do s <-…
ohiohai
  • 73
  • 8
1
vote
1 answer

?SUCHTHAT vs ?IMPLIES in quickcheck

In Triq, PropEr, Quickcheck in Erlang what is the difference between using a ?SUCHTHAT property and the ?IMPLIES? From what understand they are both specializations of the values produced by generators.
Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
1
vote
1 answer

Generating a random rule for property based test

I am using Triq (erlang quickcheck) and I am having trouble generating a set of nice rules for my program. What I want to generate are things that looks like this: A -> B where I would like to provide A and the size of B, with latter not having any…
Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
1
vote
1 answer

Generate events/commands using a property based testing tool?

As I understand it, most property testing tools operate at the level of functions. Given a set of arguments, such tools will generate random input and test output against some invariant. I have read that ScalaCheck is now starting to include…
Shahbaz
  • 10,395
  • 21
  • 54
  • 83
1
vote
1 answer

QuickChecking simple Functors: Is defining an Arbitrary instance necessary ? Why ? How?

I'm doing exercise with Functors and QuickCheck. I have a super simple Functor, whose composition law I wish to quickCheck. The Functor is simply an Identity a. This is the code I have so far: import Data.Functor import Test.QuickCheck newtype…
Stephane Rolland
  • 38,876
  • 35
  • 121
  • 169
1
vote
1 answer

Quickcheck for runtime errors

I have interest in using the quick check library but it seems that it is designed to test properties. What I would like to do is generate random data for my defined data types and test functions I have written. I do not care about what the result…
44701
  • 397
  • 4
  • 10
1
vote
4 answers

remove zero from infinite float list

I want to sample from an infinite list of floats for QuickCheck consumption. However, as I intend to use division, I want to remove zero from that list. It is such a conceptually simple problem I was wondering if I could do it with a list…
dmvianna
  • 15,088
  • 18
  • 77
  • 106
1
vote
1 answer

How to print the test seed in Haskell's test-framework?

The test-framework docs state that it supports "Reporting of the seed used upon a failed QuickCheck run, so you can reproduce the failure if necessary." However the default output does not display this, and I cannot find any command line option that…
Will Sewell
  • 2,593
  • 2
  • 20
  • 39
1
vote
1 answer

Generating arbitrary `JointList` with concrete types

I am writing tests for one of the exercises of this course homework. In this homework the following data type is defined: data JoinList m a = Empty | Single m a | Append m (JoinList m a) (JoinList m a) …
Damian Nadales
  • 4,907
  • 1
  • 21
  • 34
1
vote
0 answers

Arbitrary instance for StdGen

Please define: instance Arbitrary StdGen where arbitrary = undefined shrink = undefined Why is this not defined in the standard library? Are there some pitfalls I should avoid, is it even possible?
xiaolingxiao
  • 4,793
  • 5
  • 41
  • 88
1
vote
1 answer

How do I call a constructor that may fail, especially when implementing 'Read' and 'Arbitrary'?

I have a "public safe" that may fail with a (potentially informative) errors: data EnigmaError = BadRotors | BadWindows | MiscError String instance Show EnigmaError where show BadRotors = "Bad rotors" show…
orome
  • 45,163
  • 57
  • 202
  • 418
1
vote
1 answer

Can I generate arbitrary strings, and avoid repeating specifications in QuickCheck?

Given data MyType = MyType ... makeMyType :: String -> String -> String -> MyType -- ... type StringThing = String where the strings that makeMyType expects are (respectively): a - delimited string of some custom strings (e.g.,…
orome
  • 45,163
  • 57
  • 202
  • 418
1
vote
2 answers

Compare two functions using quickcheck to generate positive integers

I have the following Haskell functions: expM :: Integer -> Integer -> Integer -> Integer expM x y = rem (x^y) And exMME :: Integer -> Integer -> Integer -> Integer exMME b 0 m = 1 exMME b e m = exMME' b e m 1 0 where exMME' b e m…
Phaeton
  • 79
  • 8
1
vote
2 answers

Uniqueness and other restrictions for Arbitrary in QuickCheck

I'm trying to write a modified Arbitrary instance for my data type, where (in my case) a subcomponent has a type [String]. I would ideally like to bring uniqueness in the instance itself, that way I don't need ==> headers / prerequisites for every…
Athan Clark
  • 3,886
  • 2
  • 21
  • 39