Module Test.QuickCheckProperty

Imports

Table of Content

Definitions

type Property = Gen Prop

The things quick check is testing

class Testable prop

The class of things which can be tested, i.e. turned into a property.

Known Instances

Bool, ->, Prop, QuickCheckGen.Gen, Result

Member Functions

exhaustive ∷ Testable prop ⇒ prop → Bool
property ∷ Testable prop ⇒ prop → Property
morallyDubiousIOProperty ∷ Testable prop ⇒ IO prop → Property

Do I/O inside a property. This can obviously lead to unrepeatable testcases, so use with care.

protect ∷ (Exception → a) → IO a → IO a
data Prop

Constructors

MkProp {unProp ∷ Rose Result}

Member Functions

unProp ∷ Prop → Rose Result

access field unProp

data Rose a

Constructors

IORose (IO (Rose a))
MkRose a   [Rose a]
ioRose ∷ IO (Rose Result) → Rose Result
joinRose ∷ Rose (Rose a) → Rose a
reduceRose ∷ Rose Result → IO (Rose Result)
onRose ∷ (a → [Rose a] → Rose a) → Rose a → Rose a
protectRose ∷ IO (Rose Result) → IO (Rose Result)

Wrap a rose tree in an exception handler.

protectResults ∷ Rose Result → Rose Result

Wrap all the Results in a rose tree in exception handlers.

data Callback

Different kinds of callbacks

Constructors

PostFinalFailure CallbackKind   (State → Result → IO ())

Called with the final failing test-case

PostTest CallbackKind   (State → Result → IO ())

Called just after a test

data CallbackKind

Constructors

Counterexample

Affected by the verbose combinator

NotCounterexample

Not affected by the verbose combinator

data Result

Constructors

MkResult {ok ∷ Maybe Bool, expect ∷ Bool, reason ∷ String, interrupted ∷ Bool, abort ∷ Bool, stamp ∷ [(String, Int)], callbacks ∷ [Callback]}

Member Functions

abort ∷ Result → Bool

access field abort

callbacks ∷ Result → [Callback]

access field callbacks

expect ∷ Result → Bool

access field expect

interrupted ∷ Result → Bool

access field interrupted

ok ∷ Result → Maybe Bool

access field ok

reason ∷ Result → String

access field reason

stamp ∷ Result → [(String, Int)]

access field stamp

result ∷ Result
exception ∷ String → Exception → Result
formatException ∷ String → Exception → String
protectResult ∷ IO Result → IO Result
succeeded ∷ Result
failed ∷ Result
rejected ∷ Result
liftBool ∷ Bool → Result
mapResult ∷ Testable prop ⇒ (Result → Result) → prop → Property
mapTotalResult ∷ Testable prop ⇒ (Result → Result) → prop → Property
mapRoseResult ∷ Testable prop ⇒ (Rose Result → Rose Result) → prop → Property
mapProp ∷ Testable prop ⇒ (Prop → Prop) → prop → Property
mapSize ∷ Testable prop ⇒ (Int → Int) → prop → Property

Changes the maximum test case size for a property.

shrinking ∷ Testable prop ⇒ (a → [a]) → a → (a → prop) → Property

Shrinks the argument to property if it fails. Shrinking is done automatically for most types. This is only needed when you want to override the default behavior.

noShrinking ∷ Testable prop ⇒ prop → Property

Disables shrinking for a property altogether.

callback ∷ Testable prop ⇒ Callback → prop → Property

Adds a callback

printTestCase ∷ Testable prop ⇒ String → prop → Property

Prints a message to the terminal as part of the counterexample.

whenFail ∷ Testable prop ⇒ IO () → prop → Property

Performs an IO action after the last failure of a property.

whenFail' ∷ Testable prop ⇒ IO () → prop → Property
verbose ∷ Testable prop ⇒ prop → Property

Prints out the generated testcase every time the property is tested, like "verboseCheck" from QuickCheck 1. Only variables quantified over inside the verbose are printed.

expectFailure ∷ Testable prop ⇒ prop → Property

Modifies a property so that it is expected to fail for some test cases.

once ∷ Testable prop ⇒ prop → Property

Modifies a property so that it only will be tested once.

label ∷ Testable prop ⇒ String → prop → Property

Attaches a label to a property.

This is used for reporting test case distribution.

collect ∷ (Show a, Testable prop) ⇒ a → prop → Property

Labels a property with a value:

 collect x = label (show x)   
classify ∷ Testable prop ⇒ Bool → String → prop → Property

Conditionally labels test case.

cover ∷ Testable prop ⇒ Bool → Int → String → prop → Property

Checks that at least the given proportion of the test cases belong to the given class.

==> ∷ Testable prop ⇒ Bool → prop → Property
infixr  1

Implication for properties: The resulting property holds if the first argument is false (in which case the test case is discarded), or if the given property holds.

within ∷ Testable prop ⇒ Int → prop → Property
forAll ∷ (Show a, Testable prop) ⇒ Gen a → (a → prop) → Property

Explicit universal quantification: uses an explicitly given test case generator.

forAllShrink ∷ (Show a, Testable prop) ⇒ Gen a → (a → [a]) → (a → prop) → Property

Like forAll, but tries to shrink the argument for failing test cases.

.&. ∷ (Testable prop1, Testable prop2) ⇒ prop1 → prop2 → Property
infixr  2

Nondeterministic choice: p1 .&. p2 picks randomly one of p1 and p2 to test. If you test the property 100 times it makes 100 random choices.

.&&. ∷ (Testable prop1, Testable prop2) ⇒ prop1 → prop2 → Property
infixr  2

Conjunction: p1 .&&. p2 passes if both p1 and p2 pass.

conjoin ∷ Testable prop ⇒ [prop] → Property

Take the conjunction of several properties.

.||. ∷ (Testable prop1, Testable prop2) ⇒ prop1 → prop2 → Property
infixr  2

Disjunction: p1 .||. p2 passes unless p1 and p2 simultaneously fail.

disjoin ∷ Testable prop ⇒ [prop] → Property

Take the disjunction of several properties.

Instances

instance Functor Rose

Member Functions

fmap ∷ (𝖆 → 𝖇) → Rose 𝖆 → Rose 𝖇
infixl  4
instance Monad Rose

Member Functions

*> ∷ Rose 𝖆 → Rose 𝖇 → Rose 𝖇
infixl  4

inherited from Applicative.*>

<* ∷ Rose 𝖆 → Rose 𝖇 → Rose 𝖆
infixl  4

inherited from Applicative.<*

<*> ∷ Rose (𝖆→𝖇) → Rose 𝖆 → Rose 𝖇
infixl  4

inherited from Monad.<*>

>> ∷ Rose 𝖆 → Rose 𝖇 → Rose 𝖇
infixl  3

inherited from Monad.>>

>>= ∷ Rose 𝖆 → (𝖆 → Rose 𝖇) → Rose 𝖇
infixl  3
join ∷ Rose (Rose 𝖆) → Rose 𝖆

inherited from Monad.join

pure ∷ 𝖆 → Rose 𝖆
instance (Arbitrary a, Show a, Testable prop) ⇒ Testable (a→prop)

Member Functions

exhaustive ∷ (Arbitrary 𝖇, Show 𝖇, Testable 𝖆) ⇒ (𝖇→𝖆) → Bool

inherited from Testable.exhaustive

property ∷ (Arbitrary 𝖇, Show 𝖇, Testable 𝖆) ⇒ (𝖇→𝖆) → Property
instance Testable Bool

Member Functions

exhaustive ∷ Bool → Bool
property ∷ Bool → Property
instance Testable prop ⇒ Testable (Gen prop)

Member Functions

exhaustive ∷ Testable 𝖆 ⇒ Gen 𝖆 → Bool

inherited from Testable.exhaustive

property ∷ Testable 𝖆 ⇒ Gen 𝖆 → Property
instance Testable Prop

Member Functions

exhaustive ∷ Prop → Bool
property ∷ Prop → Property
instance Testable Result

Member Functions

exhaustive ∷ Result → Bool
property ∷ Result → Property

Functions and Values by Type

IO (Rose Result) → IO (Rose Result)

protectRose

IO (Rose Result) → Rose Result

ioRose

IO Result → IO Result

protectResult

Maybe Bool → Bool → String → Bool → Bool → [(String, Int)] → [Callback] → Result

Result.MkResult

String → Exception → String

formatException

String → Exception → Result

exception

Rose Result → IO (Rose Result)

reduceRose

Rose Result → Rose Result

protectResults

Rose Result → Prop

Prop.MkProp

Bool → Property

Testable_Bool.property

Bool → Bool

Testable_Bool.exhaustive

Bool → Result

liftBool

CallbackKind → (State → Result → IO ()) → Callback

Callback.PostTest, Callback.PostFinalFailure

Prop → (Rose Result→Rose Result) → Prop

Prop.chg$unProp

Prop → Rose Result → Prop

Prop.upd$unProp

Prop → Property

Testable_Prop.property

Prop → Rose Result

Prop.unProp

Prop → Bool

Testable_Prop.exhaustive

Result → (Maybe Bool→Maybe Bool) → Result

Result.chg$ok

Result → (String→String) → Result

Result.chg$reason

Result → ([(String, Int)]→[(String, Int)]) → Result

Result.chg$stamp

Result → ([Callback]→[Callback]) → Result

Result.chg$callbacks

Result → (Bool→Bool) → Result

Result.chg$expect, Result.chg$interrupted, Result.chg$abort

Result → Maybe Bool → Result

Result.upd$ok

Result → String → Result

Result.upd$reason

Result → [(String, Int)] → Result

Result.upd$stamp

Result → [Callback] → Result

Result.upd$callbacks

Result → Bool → Result

Result.upd$expect, Result.upd$abort, Result.upd$interrupted

Result → Maybe Bool

Result.ok

Result → String

Result.reason

Result → [(String, Int)]

Result.stamp

Result → [Callback]

Result.callbacks

Result → Property

Testable_Result.property

Result → Bool

Testable_Result.exhaustive, Result.interrupted, Result.expect, Result.abort

CallbackKind

CallbackKind.Counterexample, CallbackKind.NotCounterexample

Result

failed, rejected, result, succeeded

(Exception → a) → IO a → IO a

protect

(a → [Rose a] → Rose a) → Rose a → Rose a

onRose

IO (Rose a) → Rose a

Rose.IORose

Rose (Rose a) → Rose a

joinRose

Rose (Rose 𝖆) → Rose 𝖆

Monad_Rose.join

a → [Rose a] → Rose a

Rose.MkRose

𝖆 → Rose 𝖆

Monad_Rose.pure

𝖆 → Bool

Prop.has$unProp, Result.has$reason, Result.has$interrupted, Result.has$ok, Result.has$stamp, Result.has$abort, Result.has$callbacks, Result.has$expect

Testable prop ⇒ (Rose Result → Rose Result) → prop → Property

mapRoseResult

Testable prop ⇒ (Int → Int) → prop → Property

mapSize

Testable prop ⇒ (Prop → Prop) → prop → Property

mapProp

Testable prop ⇒ (Result → Result) → prop → Property

mapResult, mapTotalResult

Testable prop ⇒ IO () → prop → Property

whenFail, whenFail'

Testable prop ⇒ IO prop → Property

morallyDubiousIOProperty

Testable prop ⇒ String → prop → Property

label, printTestCase

Testable prop ⇒ [prop] → Property

conjoin, disjoin

Testable prop ⇒ Bool → String → prop → Property

classify

Testable prop ⇒ Bool → Int → String → prop → Property

cover

Testable prop ⇒ Bool → prop → Property

==>

Testable prop ⇒ Int → prop → Property

within

Testable prop ⇒ Callback → prop → Property

callback

Testable prop ⇒ prop → Property

expectFailure, noShrinking, once, verbose, Testable.property

Testable prop ⇒ prop → Bool

Testable.exhaustive

Testable 𝖆 ⇒ Gen 𝖆 → Property

Testable_Gen.property

Testable 𝖆 ⇒ Gen 𝖆 → Bool

Testable_Gen.exhaustive

(𝖆 → 𝖇) → Rose 𝖆 → Rose 𝖇

Functor_Rose.fmap

Rose (𝖆→𝖇) → Rose 𝖆 → Rose 𝖇

Monad_Rose.<*>

Rose 𝖆 → (𝖆 → Rose 𝖇) → Rose 𝖇

Monad_Rose.>>=

Rose 𝖆 → Rose 𝖇 → Rose 𝖆

Monad_Rose.<*

Rose 𝖆 → Rose 𝖇 → Rose 𝖇

Monad_Rose.>>, Monad_Rose.*>

(Show a, Testable prop) ⇒ Gen a → (a → [a]) → (a → prop) → Property

forAllShrink

(Show a, Testable prop) ⇒ Gen a → (a → prop) → Property

forAll

(Show a, Testable prop) ⇒ a → prop → Property

collect

(Arbitrary 𝖇, Show 𝖇, Testable 𝖆) ⇒ (𝖇→𝖆) → Property

Testable_->.property

(Arbitrary 𝖇, Show 𝖇, Testable 𝖆) ⇒ (𝖇→𝖆) → Bool

Testable_->.exhaustive

Testable prop ⇒ (a → [a]) → a → (a → prop) → Property

shrinking

(Testable prop1, Testable prop2) ⇒ prop1 → prop2 → Property

.&&., .&., .||.

Valid HTML 4.01 Strict