HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulequickcheck-assertions-0.3.0Haskell98

Test.QuickCheck.Assertions

Module provides convenient functions to do some assertions in QuickCheck properties with pretty printed reasons. For example you can do something like that:

module Main where

import Test.Hspec
import Test.Hspec.QuickCheck
import Test.QuickCheck.Assertions
import Test.QuickCheck.Property

someProp :: Int -> Int -> Result
someProp a b = (a ?> b)

someOtherProp :: Double -> Double -> Result
someOtherProp a b = (a ?== b)

main = hspec $ describe "failing test" $ do
  prop "must fail" $ someProp
  prop "must fail again" $ someOtherProp

And receive pretty printed fail message when testing:

failing test
  - must fail FAILED [1]
  - must fail again FAILED [2]

1) failing test must fail FAILED
*** Failed! (after 1 test):
>>>>>>>>>>>>>> the value
0
>>>>>>>>>>>>>> should be greater than value
0
0
0


2) failing test must fail again FAILED
*** Failed! (after 2 tests and 4 shrinks):
>>>>>>>>>>>>>> expected
0.0
>>>>>>>>>>>>>> but got
1.0
0.0
1.0

Ok, not very well printed, but better than nothing.

  • 1 type
  • 15 values

Assertions

15 declarations
value(?==) :: (Eq a, Show a) => a -> a -> Result
#

Left argument should be equal to right

value(==?) :: (Eq a, Show a) => a -> a -> Result
#

Right argument should be equal to left

value(/=?) :: (Eq a, Show a) => a -> a -> Result
#

Right argument should not equal to left

value(?/=) :: (Eq a, Show a) => a -> a -> Result
#

Left argument should not equal to right

value(>?) :: (Show a, Ord a) => a -> a -> Result
#

Right argument is less then left

value(<?) :: (Show a, Ord a) => a -> a -> Result
#

Right argument is greater than left

value(?>) :: (Show a, Ord a) => a -> a -> Result
#

Left argument is greater than right

value(?<) :: (Show a, Ord a) => a -> a -> Result
#

Left argument is less then right

value(>=?) :: (Show a, Ord a) => a -> a -> Result
#

Right argument is less or equal to left

value(<=?) :: (Show a, Ord a) => a -> a -> Result
#

Right argument is greater or equal to left

value(?>=) :: (Show a, Ord a) => a -> a -> Result
#

Left argument is greater or equal to right

value(?<=) :: (Show a, Ord a) => a -> a -> Result
#

Left argument is less or equal to right

value(~==?) :: (AEq a, Show a) => a -> a -> Result
#

Right value is almost equal to left

value(?~==) :: (AEq a, Show a) => a -> a -> Result
#

Left value is almost equal to right

Reexports

1 declaration
datadata Result
#

The result of a single test.

Instances1Testable
  • Testable ResultDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Property