nw-pbt-haskell

Solid

Haskell property-based testing with QuickCheck and Hedgehog frameworks

Testing & QA 526 stars 55 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 95/100

Stars 20%
91
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# PBT Haskell -- QuickCheck + Hedgehog ## Framework Selection | Framework | Shrinking | Stateful | Choose When | |-----------|-----------|----------|-------------| | QuickCheck | Type-based (manual) | Limited (open-source) | Default for most projects. Universal ecosystem support. | | Hedgehog | Integrated (automatic) | Yes (parallel too) | Need automatic shrinking composition or parallel stateful testing | QuickCheck is the original PBT framework (2000). Hedgehog is the modern alternative with better shrinking. ## Quick Start (QuickCheck) ```haskell import Test.QuickCheck prop_reverse_involutory :: [Int] -> Bool prop_reverse_involutory xs = reverse (reverse xs) == xs -- Run: quickCheck prop_reverse_involutory -- Or in test suite: testProperty "reverse" prop_reverse_involutory ``` ## Generator Cheat Sheet (QuickCheck) ### Via Arbitrary Type Class ```haskell arbitrary :: Gen Int -- any Int arbitrary :: Gen String -- any String arbitrary :: Gen [Int] -- any list of Ints arbitrary :: Gen Bool -- Custom Arbitrary data Color = Red | Green | Blue deriving (Show, Eq) instance Arbitrary Color where arbitrary = elements [Red, Green, Blue] shrink Red = [] shrink _ = [Red] ``` ### Gen Combinators ```haskell choose (0, 100) -- bounded int elements [1, 2, 3] -- pick from list oneof [gen1, gen2] -- union frequency [(80, gen1), (20, gen2)] -- weighted listOf arbitrary -- list listOf1 arbitrary -- non-e...

Details

Author
nWave-ai
Repository
nWave-ai/nWave
Created
3 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category