quickcheck Questions

1

The Batch module of QuickCheck was removed with version 2 (1.2.0.1 still has it). Because of this, I'm always feeling like mapM_-ing multiple tests together is kind of hacky. Am I overlooking the s...
Electrician asked 23/11, 2012 at 17:35

1

Solved

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...
Trouveur asked 13/11, 2012 at 2:18

1

Solved

I'd like to write a tests for a Parsec parser. Here is the example of parser and data structure: data Event = Event { keyEvent :: String } deriving Show parseKey :: Parser Event parseKey = do c...
Wicket asked 19/10, 2012 at 18:45

1

Solved

I wrote a QuickCheck property for a function that merges two sorted inputs into a sorted output: prop_merge xs ys = if (sorted xs && sorted ys) then (sorted (merge xs ys)) else True Tha...
Stewpan asked 14/10, 2012 at 17:57

3

Solved

Say I want to write some unit tests for the (!!) function. my_prop xs n = ... I want to restrict n to only valid indexes and I know I could do something like my_prop xs n = (not.null) (drop n x...
Emperor asked 10/10, 2012 at 20:32

1

Solved

I've a function, rev, that returns some value for a type that is in three typeclasses: rev :: (Integral a, Show a, Read a) => a -> a rev = read . reverse . show I'd like to test some prope...
Selffulfillment asked 17/9, 2012 at 20:24

1

Solved

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 th...
Heatstroke asked 13/8, 2012 at 21:26

2

Solved

While writing some Arbitrary instances, I implemented a couple of functions with the following quite mechanical pattern: type A = Arbitrary -- to cut down on the size of the annotations below shri...
Vallievalliere asked 17/8, 2012 at 23:36

2

I'm trying to run QuickCheck on some nested lists, something that looks like this: type Constraint = Text data Value = Value [Constraint] data Literal = Literal Value [Value] type Formula = [Liter...
Colquitt asked 9/1, 2012 at 12:37

3

I'm porting QuickCheck to Rust, and I've written everything except for_all as I'm not sure what the type signature should be. I know that in general, for_all will accept a property lambda and a co...
Hammock asked 14/2, 2012 at 4:57

1

Solved

I'd like to write tests for a suite of Parsec parsers. Here's a simple example of a parser I want to test with QuickCheck: identifier = do c <- letter cs <- many (alphaNum <|> oneOf ...
Tenuis asked 12/6, 2012 at 16:4

2

Solved

I'm trying to write a QuickCheck property that takes one or more functions as input. To keep things simple, consider a property to check that function composition is equivalent to successive functi...
Jaimeejaimes asked 6/3, 2011 at 4:5

2

Solved

Being a fan of quickCheck, I have a lot of prop_something_something = ... throughout my program. For convenience, to easily run all of them, I define runchecks = do quickCheck prop_something_...
Elytron asked 26/4, 2012 at 18:11

1

Solved

I wrote an algorithm to find a solution to the subset sum problem in Haskell. The signature is subsetSum :: (Ord a, Num a) => [a] -> a -> Maybe [a] QuickCheck seems to be a good fit to...
Natant asked 2/4, 2012 at 13:51

2

Solved

When I want to test pure code using QuickCheck I often have to write an Arbitrary instance. To test monadic code, I can use Test.QuickCheck.Monadic as described in this article. My question is: Is...
Jackfruit asked 25/3, 2012 at 19:53

3

Solved

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...
Agnosia asked 16/3, 2012 at 20:21

2

I have a higher-order function that I want to test, and one of the properties I want to test is what it does with the functions that are passed in. For purposes of illustration, here is a contrived...
Purposeless asked 13/3, 2012 at 15:4

2

Solved

I'm trying to understand how to integrate some quickcheck tests with cabal. This gist suggests that the quickCheck function returns non-zero status on failure, but I am not getting that behavior, s...
Combo asked 23/1, 2012 at 18:14

1

Solved

I wrote a finite state machine module for a little soccer game I'm currently working at. It provides an interface for setting up an FSM (basically its states and transitions). For each state, you c...
Vial asked 17/12, 2011 at 10:41

1

Solved

Lots of commonly useful properties of functions have concise names. For example, associativity, commutativity, transitivity, etc. I am making a library for use with QuickCheck that provides shorth...
Swinson asked 1/12, 2011 at 17:52

2

Solved

When a value fails a QuickCheck'd test, I'd like to use it for debugging. Is there any way I can do something like: let failValue = quickCheck' myTest in someStuff failValue If my data was reada...
Abdel asked 19/11, 2011 at 1:21

1

Solved

The RWH books says that to get ByteString support, I need to add: instance Arbitrary B.ByteString where arbitrary = fmap B.pack arbitrary coarbitrary = coarbitrary . B.unpack But my GHC 7.2 wi...
Loki asked 13/11, 2011 at 18:39

3

Solved

-- 3 (find k"th element of a list) element_at xs x = xs !! x prop_3a xs x = (x < length xs && x >= 0) ==> element_at xs (x::Int) == (xs !! x::Int) When prop_3a is ran through Qui...
Matri asked 8/10, 2011 at 0:4

2

Solved

I have a cabal package that exports a type NBT which might be useful for other developers. I've gone through the trouble of defining an Arbitrary instance for my type, and it would be a shame to no...
Necessary asked 12/8, 2011 at 16:42

1

Solved

When i google for how to integrate unit tests with cabal files, i either find http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program which does not seem to describe the integration of ...
Strapless asked 22/7, 2011 at 8:9

© 2022 - 2024 — McMap. All rights reserved.