@hackage / hedgehog-quickcheck
Use QuickCheck generators in Hedgehog and vice versa.
About
Metadata
- Last updated:
- License: BSD-3-Clause
- Categories: Testing
- Maintained by: Jacob Stanley <jacob@stanley.io>
-
Lottery factor: 5
The number of people with uploader permission on @hackage/hedgehog-quickcheck who have released something to @hackage in the last 2 years (i.e. the number of people likely able to release critical fixes in a timely manner)
Links
Installation
Tested Compilers
- 8.0.2
- 8.2.2
- 8.4.4
- 8.6.5
- 8.8.3
- 8.10.1
Build targets
- JS
- WASM
Uploaders
- Howard Knight
- Warren Griffin
- Sarah Bass
Readme
hedgehog-quickcheck 
Hedgehog will eat all your bugs.
Use QuickCheck generators in Hedgehog and vice versa.
Example
The Hedgehog.Gen.QuickCheck module allows the use of QuickCheck generators inside Hedgehog.
{-# LANGUAGE TemplateHaskell #-}
import Hedgehog
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Gen.QuickCheck as Gen
import qualified Hedgehog.Range as Range
Once you have your imports set up, you can write a property which mixes QuickCheck and Hedgehog generators together:
prop_reverse :: Property
prop_reverse =
property $ do
xs <- forAll $ Gen.list (Range.linear 0 100) (Gen.arbitrary :: Gen Char)
reverse (reverse xs) === xs
And add the Template Haskell splice which will discover your properties:
tests :: IO Bool
tests =
checkParallel $$(discover)
You can then load the module in GHCi, and run it:
λ tests
━━━ Test.Example ━━━
✓ prop_reverse passed 100 tests.