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

exhaustiveTestable prop ⇒ prop → Bool
propertyTestable prop ⇒ prop → Property
morallyDubiousIOPropertyTestable 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 aIO a
data Prop

Constructors

MkProp {unProp ∷ Rose Result}

Member Functions

unPropPropRose Result

access field unProp

data Rose a

Constructors

IORose (IO (Rose a))
MkRose a   [Rose a]
ioRoseIO (Rose Result) → Rose Result
joinRoseRose (Rose a)Rose a
reduceRoseRose ResultIO (Rose Result)
onRose ∷ (a → [Rose a] → Rose a) → Rose aRose a
protectRoseIO (Rose Result)IO (Rose Result)

Wrap a rose tree in an exception handler.

protectResultsRose ResultRose Result

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

data Callback

Different kinds of callbacks

Constructors

PostFinalFailure CallbackKind   (StateResultIO ())

Called with the final failing test-case

PostTest CallbackKind   (StateResultIO ())

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

abortResultBool

access field abort

callbacksResult → [Callback]

access field callbacks

expectResultBool

access field expect

interruptedResultBool

access field interrupted

okResultMaybe Bool

access field ok

reasonResultString

access field reason

stampResult → [(String, Int)]

access field stamp

resultResult
exceptionStringExceptionResult
formatExceptionStringExceptionString
protectResultIO ResultIO Result
succeededResult
failedResult
rejectedResult
liftBoolBoolResult
mapResultTestable prop ⇒ (ResultResult) → prop → Property
mapTotalResultTestable prop ⇒ (ResultResult) → prop → Property
mapRoseResultTestable prop ⇒ (Rose ResultRose Result) → prop → Property
mapPropTestable prop ⇒ (PropProp) → prop → Property
mapSizeTestable prop ⇒ (IntInt) → prop → Property

Changes the maximum test case size for a property.

shrinkingTestable 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.

noShrinkingTestable prop ⇒ prop → Property

Disables shrinking for a property altogether.

callbackTestable prop ⇒ Callback → prop → Property

Adds a callback

printTestCaseTestable prop ⇒ String → prop → Property

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

whenFailTestable prop ⇒ IO () → prop → Property

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

whenFail'Testable prop ⇒ IO () → prop → Property
verboseTestable 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.

expectFailureTestable prop ⇒ prop → Property

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

onceTestable prop ⇒ prop → Property

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

labelTestable 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)   
classifyTestable prop ⇒ BoolString → prop → Property

Conditionally labels test case.

coverTestable prop ⇒ BoolIntString → 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.

withinTestable 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.

conjoinTestable 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.

disjoinTestable 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
joinRose (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

exhaustiveBoolBool
propertyBoolProperty
instance Testable prop ⇒ Testable (Gen prop)

Member Functions

exhaustiveTestable 𝖆 ⇒ Gen 𝖆 → Bool

inherited from Testable.exhaustive

propertyTestable 𝖆 ⇒ Gen 𝖆Property
instance Testable Prop

Member Functions

exhaustivePropBool
propertyPropProperty
instance Testable Result

Member Functions

exhaustiveResultBool
propertyResultProperty

Functions and Values by Type

IO (Rose Result) → IO (Rose Result)

protectRose

IO (Rose Result) → Rose Result

ioRose

IO ResultIO Result

protectResult

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

Result.MkResult

StringExceptionString

formatException

StringExceptionResult

exception

Rose ResultIO (Rose Result)

reduceRose

Rose ResultRose Result

protectResults

Rose ResultProp

Prop.MkProp

BoolProperty

Testable_Bool.property

BoolBool

Testable_Bool.exhaustive

BoolResult

liftBool

CallbackKind → (StateResultIO ()) → Callback

Callback.PostTest, Callback.PostFinalFailure

Prop → (Rose ResultRose Result) → Prop

Prop.chg$unProp

PropRose ResultProp

Prop.upd$unProp

PropProperty

Testable_Prop.property

PropRose Result

Prop.unProp

PropBool

Testable_Prop.exhaustive

Result → (Maybe BoolMaybe Bool) → Result

Result.chg$ok

Result → (StringString) → Result

Result.chg$reason

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

Result.chg$stamp

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

Result.chg$callbacks

Result → (BoolBool) → Result

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

ResultMaybe BoolResult

Result.upd$ok

ResultStringResult

Result.upd$reason

Result → [(String, Int)] → Result

Result.upd$stamp

Result → [Callback] → Result

Result.upd$callbacks

ResultBoolResult

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

ResultMaybe Bool

Result.ok

ResultString

Result.reason

Result → [(String, Int)]

Result.stamp

Result → [Callback]

Result.callbacks

ResultProperty

Testable_Result.property

ResultBool

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 ResultRose Result) → prop → Property

mapRoseResult

Testable prop ⇒ (IntInt) → prop → Property

mapSize

Testable prop ⇒ (PropProp) → prop → Property

mapProp

Testable prop ⇒ (ResultResult) → 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 ⇒ BoolString → prop → Property

classify

Testable prop ⇒ BoolIntString → 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