skeletest
Safe HaskellNone
LanguageGHC2021

Skeletest.Prop.Internal

Synopsis

Documentation

type Property = PropertyM () Source #

A property to run, with optional configuration settings specified up front.

Settings should be specified before any other Property calls; any settings specified afterwards are ignored.

data PropertyM a Source #

Instances

Instances details
MonadIO PropertyM Source # 
Instance details

Defined in Skeletest.Prop.Internal

Methods

liftIO :: IO a -> PropertyM a #

Applicative PropertyM Source # 
Instance details

Defined in Skeletest.Prop.Internal

Methods

pure :: a -> PropertyM a #

(<*>) :: PropertyM (a -> b) -> PropertyM a -> PropertyM b #

liftA2 :: (a -> b -> c) -> PropertyM a -> PropertyM b -> PropertyM c #

(*>) :: PropertyM a -> PropertyM b -> PropertyM b #

(<*) :: PropertyM a -> PropertyM b -> PropertyM a #

Functor PropertyM Source # 
Instance details

Defined in Skeletest.Prop.Internal

Methods

fmap :: (a -> b) -> PropertyM a -> PropertyM b #

(<$) :: a -> PropertyM b -> PropertyM a #

Monad PropertyM Source # 
Instance details

Defined in Skeletest.Prop.Internal

Methods

(>>=) :: PropertyM a -> (a -> PropertyM b) -> PropertyM b #

(>>) :: PropertyM a -> PropertyM b -> PropertyM b #

return :: a -> PropertyM a #

Testable PropertyM Source # 
Instance details

Defined in Skeletest.Prop.Internal

Test

Configuring properties

Coverage

classify :: HasCallStack => String -> Bool -> Property Source #

Record the propotion of tests which satisfy a given condition

xs <- forAll $ Gen.list (Range.linear 0 100) $ Gen.int (Range.linear 0 100)
for_ xs $ x -> do
  classify "newborns" $ x == 0
  classify "children" $ x > 0 && x < 13
  classify "teens" $ x > 12 && x < 20

cover :: HasCallStack => Double -> String -> Bool -> Property Source #

Require a certain percentage of the tests to be covered by the classifier.

In the following example, if the condition does not have at least 30% coverage, the test will fail.

match <- forAll Gen.bool
cover 30 "true" $ match
cover 30 "false" $ not match

label :: HasCallStack => String -> Property Source #

Add a label for each test run. It produces a table showing the percentage of test runs that produced each label.

collect :: (Show a, HasCallStack) => a -> Property Source #

Like label, but uses Show to render its argument for display.

CLI flags