hspec-leancheck

LeanCheck support for the Hspec test framework.

https://github.com/rudymatela/hspec-leancheck#readme

Version on this page:0.0.4
LTS Haskell 22.14:0.0.6
Stackage Nightly 2024-03-28:0.0.6
Latest on Hackage:0.0.6

See all snapshots hspec-leancheck appears in

BSD-3-Clause licensed and maintained by Rudy Matela
This version can be pinned in stack with:hspec-leancheck-0.0.4@sha256:04df66a458c8e7d9821ac8ea3146f78f3b671a79cf778003a2a197477bf054a5,2427

Module documentation for 0.0.4

hspec-leancheck: LeanCheck support for Hspec

hspec-leancheck’s Build Status hspec-leancheck on Hackage hspec-leancheck on Stackage LTS hspec-leancheck on Stackage Nightly

LeanCheck support for the Hspec test framework.

Installing

$ cabal install hspec-leancheck

Example

Here’s how your spec.hs might look like:

import Test.Hspec
import Test.Hspec.LeanCheck as LC

import Data.List (sort)

main :: IO ()
main = hspec spec

spec :: Spec
spec = do
  describe "sort" $ do
    it "is idempotent" $
      LC.property $ \xs -> sort (sort xs :: [Int]) == sort xs
    it "is identity" $ -- not really
      LC.property $ \xs -> sort (xs :: [Int]) == xs

And here is the output for the above program:

$ ./eg/minimal

sort
  is idempotent
  is identity FAILED [1]

Failures:

  eg/minimal.hs:17:5: 
  1) sort is identity
       [1,0]

  To rerun use: --match "/sort/is identity/"

Randomized with seed 44182769

Finished in 0.0008 seconds
2 examples, 1 failure

Options

Use propertyWith to configure the number of tests.

Further reading

Changes

Changelog for hspec-leancheck

0.0.4

  • improve build scripts

0.0.3

  • export the prop function;
  • export the Property type;
  • improvements in Haddock documentation;
  • improve tests of hspec-leancheck itself;
  • add this changelog.

0.0.2

  • propertyWith -> propertyFor;
  • improvements in documentation.

0.0.1

1st release on Hackage