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
4
votes
3 answers

It is a member of the hidden packageQuickCheck-1.2.0.0, How to load hs file

installed QuickCheck, i install again cabal install QuickCheck-1.2.0.0 and load again and has error Could not find module Test.QuickCheck.Batch': It is a member of the hidden packageQuickCheck-1.2.0.0'. It is hidden package, How to do? ghc -o…
Jo0o0
  • 531
  • 2
  • 18
  • 31
4
votes
1 answer

What's the difference between OrderedList and SortedList

Test.QuickCheck.Modifiers provides both OrderedList and SortedList. The documentation for SortedList says: Sorted xs: guarantees that xs is sorted. The documentation for OrderedList says: Ordered xs: guarantees that xs is ordered. (I'm…
pat
  • 12,587
  • 1
  • 23
  • 52
4
votes
1 answer

Hypothesis equivalent of QuickCheck frequency generator?

As a learning project I am translating some Haskell code (which I'm unfamiliar with) into Python (which I know well)... The Haskell library I'm translating has tests which make use of QuickCheck property-based testing. On the Python side I am using…
Anentropic
  • 32,188
  • 12
  • 99
  • 147
4
votes
2 answers

How to write quickCheck on properties of functions?

I'm trying to do one of the Monoid exercises in Haskell Book (Chapter 15, "Monoid, Semigroup") but I'm stuck. The following is given: newtype Combine a b = Combine { unCombine :: (a -> b) } and I'm supposed to write the Monoid instance for…
cmal
  • 2,062
  • 1
  • 18
  • 35
4
votes
2 answers

How to override `doctest` to use my `ghc`?

I have problem using doctest with QuickCheck on NixOS -- code.hs -- -- $setup -- >>> import Test.QuickCheck -- -- | -- This test will pass -- >>> 1 + 1 -- 2 -- -- This test use QuickCheck -- prob> \xs -> reverse xs = reverse . id $ xs -- -- The last…
wizzup
  • 2,361
  • 20
  • 34
4
votes
2 answers

Is it possible to generate arbitrary functions in QuickCheck

I was trying to write a QuickCheck test for the identity f $ y = f y My initial plan was to write an arbitrary generator that returns functions & Integer, having the signature Gen (Int -> Int, Int) and in the prop_DollerDoesNothing test that…
Haleemur Ali
  • 26,718
  • 5
  • 61
  • 85
4
votes
3 answers

How to generate specific random string in QuickCheck?

In Haskell's QuickCheck, how to generate a string such that it contains only the characters ‘S’ and ‘C’, and the position of ‘S’ and ‘C’ is random? For example: "SCCS", "SSSS", "CCCC", "CSSCCS", "" My use case is this: I have two functions…
Leo Zhang
  • 3,040
  • 3
  • 24
  • 38
4
votes
1 answer

Harvesting function outputs (as well as inputs) from Haskell Quickcheck

What is the best way to tuple: 1. QuickCheck inputs to a predicate with 2. the outputs returned by a tested function ? Wanting to test (2 * 350) functions in a couple of other languages (to check for divergence from the behaviour of the Haskell base…
houthakker
  • 688
  • 5
  • 13
4
votes
1 answer

test isolation between pytest-hypothesis runs

I just migrated a pytest test suite from quickcheck to hypothesis. This worked quite well (and immediately uncovered some hidden edge case bugs), but one major difference I see is related to test isolation between the two property…
Bart Van Loon
  • 1,430
  • 8
  • 18
4
votes
0 answers

junit-quickcheck: How to write generators in the idiomatic way

When writing a generator for junit-quickcheck, it's easy to use the Ctor or Fields reflection methods provided. But applying reflection directly on my business models prevents me from restricting the generated data (unless I interleave my business…
Stim
  • 1,455
  • 14
  • 28
4
votes
0 answers

How should I populate arbitrary sets?

The current Arbitrary instance used to test Data.Set is too complicated for my taste. I don't really understand it, so I don't really trust it. I came up with the idea of separating the shape generation from the value generation. Using class Monad m…
dfeuer
  • 48,079
  • 5
  • 63
  • 167
4
votes
0 answers

How to QuickCheck an approximative algorithm?

I am testing an approximative algorithm (FastDTW) against the optimal solution by calculating the relative error and comparing that to the errors given in the paper [1]. Problem is that the errors can get much larger than the ones given in the…
fho
  • 6,787
  • 26
  • 71
4
votes
1 answer

How can QuickCheck test all properties for each sample

...instead of generating 100 new random samples for each property? My testsuite contains the TemplateHaskell hack explained here [1] to test all functions named prop_*. Running the test program prints === prop_foo from tests/lala.lhs:20 === +++ OK,…
stefan
  • 674
  • 1
  • 5
  • 13
4
votes
3 answers

Avoiding build dependency on QuickCheck when declaring an Arbitrary instance

Assume I have a Haskell module named Foo, defined in src/Foo.hs. Assume also that Foo exports a type Bar. Now I want to write unit tests for Bar (for the whole Foo module, actually), so I throw a couple of QuickCheck properties into test/FooTest.hs;…
4
votes
1 answer

How do I test this applicative instance with checkers? (No instance for CoArbitrary (Validation e0 [Char]))

Checkers is a library for reusable QuickCheck properties, particularly for standard type classes How do I write a checkers instance to test whether my applicative instance of Validation is valid? import Test.QuickCheck import…
The Unfun Cat
  • 29,987
  • 31
  • 114
  • 156