ouroboros-consensus:unstable-consensus-testlib
Safe HaskellNone
LanguageHaskell2010

Test.Util.QuickCheck

Description

QuickCheck utilities

Synopsis

Generic QuickCheck utilities

checkGenerator ∷ (Arbitrary a, Show a) ⇒ (a → Property) → Property Source #

Test the generator

Uses explicit forAll as we don't want to assume a correct shrinker.

checkInvariant ∷ (a → Except String ()) → a → Property Source #

Check invariant

checkShrinker ∷ (Arbitrary a, Show a) ⇒ (a → Property) → Property Source #

Test the shrinker

Comparison functions

expectRight ∷ (Show a, Show b, Eq b) ⇒ b → Either a b → Property Source #

Check that we have the expected Right value

expectRight b ab is roughly equivalent to Right b === ab, but avoids an equality constraint on a.

ge ∷ (Ord a, Show a) ⇒ a → a → Property infix 4 Source #

Like >=, but prints a counterexample when it fails.

gt ∷ (Ord a, Show a) ⇒ a → a → Property infix 4 Source #

Like >, but prints a counterexample when it fails.

le ∷ (Ord a, Show a) ⇒ a → a → Property infix 4 Source #

Like <=, but prints a counterexample when it fails.

lt ∷ (Ord a, Show a) ⇒ a → a → Property infix 4 Source #

Like <, but prints a counterexample when it fails.

strictlyIncreasing ∷ (Show a, Ord a) ⇒ [a] → Property Source #

Gen variants that allow transformers

frequency' ∷ (MonadTrans t, Monad (t Gen)) ⇒ [(Int, t Gen a)] → t Gen a Source #

Variant of frequency that allows for transformers of Gen

oneof' ∷ (MonadTrans t, Monad (t Gen)) ⇒ [t Gen a] → t Gen a Source #

Sampling from distributions

geometric ∷ Double → Gen Int Source #

Sample from a geometric distribution

Comparing maps

isSubmapOfBy ∷ (Ord k, Show k, Show a, Show b) ⇒ (a → b → Property) → Map k a → Map k b → Property Source #

Improved variants

(=:=) ∷ (Eq a, Condense a) ⇒ a → a → Property infix 4 Source #

Like ===, but uses Condense instead of Show when it fails.

SOP

cshrinkNP ∷ ∀ proxy c f g (xs ∷ [Type]). All c xs ⇒ proxy c → (∀ a. c a ⇒ f a → g a) → (∀ a. c a ⇒ f a → [g a]) → NP f xs → [NP g xs] Source #

shrinkNP ∷ ∀ f g (xs ∷ [Type]). (∀ a. f a → g a) → (∀ a. f a → [g a]) → NP f xs → [NP g xs] Source #

Convenience

collects ∷ Show a ⇒ [a] → Property → Property Source #

forAllGenRunShrinkCheck ∷ Testable prop ⇒ Gen input → (input → output) → (input → output → [input]) → (input → output → prop) → Property Source #

Explicit quantification using the “gen-run-shrink-check” pattern.

Instead of the usual two stages where one generates an input and then checks the property for that input, we rely on three stages: one generates an input, then transforms it into an output, and then checks the output.

When adding a shrinker to the mix, we can allow it to inspect the output value as well, which increases its expressivity. This makes sense if the “run” phase is particularly expensive.

implies ∷ Testable prop ⇒ Bool → prop → Property infixr 0 Source #

QuickCheck's ==> discards the test if p1 fails; this is sometimes not what we want, for example if we have other properties that do not depend on p1 being true.

Typeclass laws

prop_lawfulEqAndTotalOrd ∷ (Show a, Ord a) ⇒ a → a → a → Property Source #

Deprecated symbols

withNumTests ∷ Testable prop ⇒ Int → prop → Property Source #