Test.SmallCheck.Drivers

smallcheck-1.1.1: A property-based testing library

Copyright | (c) Colin Runciman et al.
License | BSD3
Maintainer | Roman Cheplyaka <roma@ro-che.info>
Safe Haskell | Safe
Language | Haskell98

Test.SmallCheck.Drivers

Description

You should only need this module if you wish to create your own way to run SmallCheck tests

Synopsis

- smallCheck :: Testable IO a => Depth -> a -> IO ()
- smallCheckM :: Testable m a => Depth -> a -> m (Maybe PropertyFailure)
- smallCheckWithHook :: Testable m a => Depth -> (TestQuality -> m ()) -> a -> m (Maybe PropertyFailure)
- test :: Testable m a => a -> Property m
- ppFailure :: PropertyFailure -> String
- data PropertyFailure
  - = NotExist
  - | AtLeastTwo [Argument] PropertySuccess [Argument] PropertySuccess
  - | CounterExample [Argument] PropertyFailure
  - | PropertyFalse (Maybe Reason)
- data PropertySuccess
  - = Exist [Argument] PropertySuccess
  - | ExistUnique [Argument] PropertySuccess
  - | PropertyTrue (Maybe Reason)
  - | Vacuously PropertyFailure
- type Argument = String
- type Reason = String
- data TestQuality
  - = GoodTest
  - | BadTest

# Documentation

smallCheck :: Testable IO a => Depth -> a -> IO () #

A simple driver that runs the test in the `IO` monad and prints the results.

smallCheckM :: Testable m a => Depth -> a -> m (Maybe PropertyFailure) #

Use this if:

- You need to run a test in a monad different from `IO`
- You need to analyse the results rather than just print them

smallCheckWithHook :: Testable m a => Depth -> (TestQuality -> m ()) -> a -> m (Maybe PropertyFailure) #

Like `smallCheckM`, but allows to specify a monadic hook that gets executed after each test is run.

Useful for applications that want to report progress information to the user.

test :: Testable m a => a -> Property m #

ppFailure :: PropertyFailure -> String #

data PropertyFailure #

Constructors

NotExist |
AtLeastTwo [Argument] PropertySuccess [Argument] PropertySuccess |
CounterExample [Argument] PropertyFailure |
PropertyFalse (Maybe Reason) |

Instances

Eq PropertyFailure # |
Methods (==) :: PropertyFailure -> PropertyFailure -> Bool # (/=) :: PropertyFailure -> PropertyFailure -> Bool #
Show PropertyFailure # |
Methods showsPrec :: Int -> PropertyFailure -> ShowS # show :: PropertyFailure -> String # showList :: [PropertyFailure] -> ShowS #

data PropertySuccess #

Constructors

Exist [Argument] PropertySuccess |
ExistUnique [Argument] PropertySuccess |
PropertyTrue (Maybe Reason) |
Vacuously PropertyFailure |

Instances

Eq PropertySuccess # |
Methods (==) :: PropertySuccess -> PropertySuccess -> Bool # (/=) :: PropertySuccess -> PropertySuccess -> Bool #
Show PropertySuccess # |
Methods showsPrec :: Int -> PropertySuccess -> ShowS # show :: PropertySuccess -> String # showList :: [PropertySuccess] -> ShowS #

type Argument = String #

type Reason = String #

An explanation for the test outcome

data TestQuality #

Constructors

GoodTest |
BadTest |

Instances

Enum TestQuality # |
Methods succ :: TestQuality -> TestQuality # pred :: TestQuality -> TestQuality # toEnum :: Int -> TestQuality # fromEnum :: TestQuality -> Int # enumFrom :: TestQuality -> [TestQuality] # enumFromThen :: TestQuality -> TestQuality -> [TestQuality] # enumFromTo :: TestQuality -> TestQuality -> [TestQuality] # enumFromThenTo :: TestQuality -> TestQuality -> TestQuality -> [TestQuality] #
Eq TestQuality # |
Methods (==) :: TestQuality -> TestQuality -> Bool # (/=) :: TestQuality -> TestQuality -> Bool #
Ord TestQuality # |
Methods compare :: TestQuality -> TestQuality -> Ordering # (<) :: TestQuality -> TestQuality -> Bool # (<=) :: TestQuality -> TestQuality -> Bool # (>) :: TestQuality -> TestQuality -> Bool # (>=) :: TestQuality -> TestQuality -> Bool # max :: TestQuality -> TestQuality -> TestQuality # min :: TestQuality -> TestQuality -> TestQuality #
Show TestQuality # |
Methods showsPrec :: Int -> TestQuality -> ShowS # show :: TestQuality -> String # showList :: [TestQuality] -> ShowS #