Test.QuickCheck.Modifiers
Description
Modifiers for test data.
These types do things such as restricting the kind of test data that can be generated. They can be pattern-matched on in properties as a stylistic alternative to using explicit quantification.
Examples:
-- Functions cannot be shown (but see Test.QuickCheck.Function) prop_TakeDropWhile (Blind
p) (xs :: [A
]) = takeWhile p xs ++ dropWhile p xs == xs
prop_TakeDrop (NonNegative
n) (xs :: [A
]) = take n xs ++ drop n xs == xs
-- cycle does not work for empty lists prop_Cycle (NonNegative
n) (NonEmpty
(xs :: [A
])) = take n (cycle xs) == take n (xs ++ cycle xs)
-- Instead offorAll
orderedList
prop_Sort (Ordered
(xs :: [OrdA
])) = sort xs == xs
- newtype Blind a = Blind a
- newtype Fixed a = Fixed a
- newtype OrderedList a = Ordered [a]
- newtype NonEmptyList a = NonEmpty [a]
- newtype Positive a = Positive a
- newtype NonZero a = NonZero a
- newtype NonNegative a = NonNegative a
- data Smart a = Smart Int a
- newtype Shrink2 a = Shrink2 a
- data Shrinking s a = Shrinking s a
- class ShrinkState s a where
- shrinkInit :: a -> s
- shrinkState :: a -> s -> [(a, s)]
Type-level modifiers for changing generator behavior
Shrink2 x
: allows 2 shrinking steps at the same time when shrinking x
Constructors
Shrink2 a |
Shrinking _ x
: allows for maintaining a state during shrinking.
Constructors
Shrinking s a |
class ShrinkState s a whereSource