Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
QuickCheck utilities
Synopsis
- checkGenerator ∷ (Arbitrary a, Show a) ⇒ (a → Property) → Property
- checkInvariant ∷ (a → Except String ()) → a → Property
- checkShrinker ∷ ∀ a. (Arbitrary a, Show a) ⇒ (a → Property) → Property
- expectRight ∷ (Show a, Show b, Eq b) ⇒ b → Either a b → Property
- ge ∷ (Ord a, Show a) ⇒ a → a → Property
- gt ∷ (Ord a, Show a) ⇒ a → a → Property
- le ∷ (Ord a, Show a) ⇒ a → a → Property
- lt ∷ (Ord a, Show a) ⇒ a → a → Property
- strictlyIncreasing ∷ ∀ a. (Show a, Ord a) ⇒ [a] → Property
- isSubmapOfBy ∷ (Ord k, Show k, Show a, Show b) ⇒ (a → b → Property) → Map k a → Map k b → Property
- elements ∷ HasCallStack ⇒ [a] → Gen a
- (=:=) ∷ (Eq a, Condense a) ⇒ a → a → Property
- cshrinkNP ∷ ∀ proxy c f g xs. 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]
- shrinkNP ∷ (∀ a. f a → g a) → (∀ a. f a → [g a]) → NP f xs → [NP g xs]
- collects ∷ Show a ⇒ [a] → Property → Property
- forAllGenRunShrinkCheck ∷ Testable prop ⇒ Gen input → (input → output) → (input → output → [input]) → (input → output → prop) → Property
- implies ∷ Testable prop ⇒ Bool → prop → Property
- prop_lawfulEqAndTotalOrd ∷ ∀ a. (Show a, Ord a) ⇒ a → a → a → Property
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.
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.
Comparing maps
isSubmapOfBy ∷ (Ord k, Show k, Show a, Show b) ⇒ (a → b → Property) → Map k a → Map k b → Property Source #
Improved variants
elements ∷ HasCallStack ⇒ [a] → Gen a Source #
Generates one of the given values. The input list must be non-empty.
NOTE unlike the standard elements
, this variant has a HasCallStack
constraint, which makes debugging the error
much easier.
SOP
cshrinkNP ∷ ∀ proxy c f g xs. 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 #
Convenience
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.