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

Generate choose on custom data type with 2 options

I am trying to achieve something very simple. I have this data type : import Test.QuickCheck import System.Random data Letter = G | B deriving(Show, Eq, Bounded) arbitraryLetter :: Gen Letter arbitraryLetter = choose (G,B) I am compiling and…
Eyzuky
  • 1,843
  • 2
  • 22
  • 45
0
votes
1 answer

`No instance for System.Random.Random` on a custom typeclass when using `choose`

I am doing an exercise in Haskell Programming from First Principles. It asks me to generate equal probabilities, and 1/3, 2/3 probabilities from each of: data Fool = Fulse | Frue deriving (Eq, Show) And my answer is module Random where --…
cmal
  • 2,062
  • 1
  • 18
  • 35
0
votes
1 answer

Hspec & QuickCheck - Ambiguous type variable a0?

I have written a function in Haskell that takes a list of arbitrary elements and returns (mapped) a list of tuples. Each tuple contains the original element and a fraction, with all the fractions in the list adding to 1 (therefore I simply calculate…
Raiden616
  • 1,545
  • 3
  • 18
  • 42
0
votes
1 answer

QuickCheck Haskell - generating random lottery tickets

This works : genAnimal :: Gen String genAnimal = do animals <- shuffle ["tiger","rabbit","dragon","snake","rat","ox","pig","sheep","horse","monkey","dog"] return (head animals) genWinner :: Gen String genWinner = do animal <- genAnimal …
Cliff Stamp
  • 531
  • 5
  • 11
0
votes
1 answer

How to quickCheck on custom ADT in PureScript?

For using QuickCheck, I'm trying to implement the Arbitrary instance: import Test.QuickCheck import Test.QuickCheck.Arbitrary (class Arbitrary, class Coarbitrary) data Arith = Lit Int | Add Arith Arith | Neg Arith derive instance arithEq :: Eq…
luochen1990
  • 3,689
  • 1
  • 22
  • 37
0
votes
1 answer

Could not find module ‘Test.QuickCheck’ on Mac

When I try to test my code, IntelliJ gave me this error. However, I have used cabal install QuickCheck to install. Testing.hs:3:1: error: Could not find module ‘Test.QuickCheck’ Use -v to see a list of the files searched for. | 3 | import…
0
votes
0 answers

In Yesod.Test, is it possible to get into `SpecM (TestApp site)` from `IO`, similarly to how `liftIO` allows the opposite?

More specifically, I'm looking for a function of type: f :: site -> SpecM (TestApp site) b -> IO b or similar. In other words, I am looking for the inverse function of: liftIO :: IO b -> SpecM (TestApp _site) b I've looked in the Yesod.Test docs…
Wizek
  • 4,854
  • 2
  • 25
  • 52
0
votes
1 answer

"Gave up" - QuickCheck

I want use quickcheck in a function that tests if a Maclaurin series is equal to 1/x, for x>1 and x<2. However, for small values of n, quickcheck returns false tests. Additionally, if I put n>100 restriction, for example, quickcheck returns: "Gave…
89 Juan
  • 3
  • 1
0
votes
1 answer

How to generate test data with shuffle in QuickCeck

For a given list [1..n], where n is a random positive integer, I want to generate the test data with 2 steps: Shuffle the list, xs = shuffle [1..n]; Random mutate a number x in xs to y, where 1 <= y <= n; After these 2 steps, the new list is…
Larry LIU Xinyu
  • 2,003
  • 1
  • 13
  • 10
0
votes
1 answer

Defining a property in haskel locally

I have written this property check in haskell: prop_XY (x,y) sud = ((!!) (rows (sud)) x) !! y and i need to define this locally, any suggestions on how to do it as i am clueless how to do it? EDIT So this is the two prop functions i have, and i…
Timo Cengiz
  • 3,367
  • 4
  • 23
  • 45
0
votes
1 answer

"[(),()]" array in Haskell

Recently, I've been doing automatic testing with Haskell and QuickCheck. Some time I have got some fails, but the program retrieved [(),()] as checked argument. What does "[(),()]" mean?
fant0me
  • 201
  • 1
  • 3
  • 15
0
votes
1 answer

Haskell GHC: Failed to load interface for 'Test.QuickCheck'

So I have to include the 'Test.QuickCheck' library for some testings for a subject. Although I've use it the whole year, I reinstalled GHC/GHCi recently and it doesn't load this library. The other functions work as planned. Currently using Xubuntu…
fant0me
  • 201
  • 1
  • 3
  • 15
0
votes
1 answer

Generating random strings from a string-pool using QuickCheck

Consider the problem of generating strings out our a set of possible strings, in such a way that once a string is chosen, it cannot be repeated again. For this task I would like to use QuickCheck's Gen functions. If I look at the type of the…
Damian Nadales
  • 4,907
  • 1
  • 21
  • 34
0
votes
1 answer

Testing 'DAG' aka acyclic graphs properties in Haskell QuickCheck

module Graph where import Control.Monad.State import Data.Maybe import Data.Set as Set -- | 'Edge' represents an edge entre two nodes. data Edge v = Edge {source :: v, target :: v} deriving (Show,Eq,Ord) data Graph v = Graph {nodes…
Fluids
  • 51
  • 5
0
votes
1 answer

Haskell Generating graphs with QuickCheck properties

Graphs have these properties: The type 'Edge' represents an edge between two nodes. data Edge v = Edge {source :: v, target :: v} deriving (Show,Eq,Ord) The 'Graph' type represents a directed graph. data Graph v = Graph {nodes :: Set v,…