| Safe Haskell | None |
|---|
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 (Blindp) (xs :: [A]) = takeWhile p xs ++ dropWhile p xs == xs
prop_TakeDrop (NonNegativen) (xs :: [A]) = take n xs ++ drop n xs == xs
-- cycle does not work for empty lists prop_Cycle (NonNegativen) (NonEmpty(xs :: [A])) = take n (cycle xs) == take n (xs ++ cycle xs)
-- Instead offorAllorderedListprop_Sort (Ordered(xs :: [OrdA])) = sort xs == xs
- newtype Blind a = Blind a
- newtype Fixed a = Fixed a
- newtype OrderedList a = Ordered {
- getOrdered :: [a]
- newtype NonEmptyList a = NonEmpty {
- getNonEmpty :: [a]
- newtype Positive a = Positive {
- getPositive :: a
- newtype NonZero a = NonZero {
- getNonZero :: a
- newtype NonNegative a = NonNegative {
- getNonNegative :: 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
Fixed x: as x, but will not be shrunk.
Constructors
| Fixed a |
Instances
| Enum a => Enum (Fixed a) | |
| Eq a => Eq (Fixed a) | |
| (Real (Fixed a), Enum (Fixed a), Integral a) => Integral (Fixed a) | |
| Num a => Num (Fixed a) | |
| (Eq (Fixed a), Ord a) => Ord (Fixed a) | |
| Read a => Read (Fixed a) | |
| (Num (Fixed a), Ord (Fixed a), Real a) => Real (Fixed a) | |
| Show a => Show (Fixed a) | |
| Arbitrary a => Arbitrary (Fixed a) |
newtype OrderedList a Source
Ordered xs: guarantees that xs is ordered.
Constructors
| Ordered | |
Fields
| |
Instances
| Eq a => Eq (OrderedList a) | |
| (Eq (OrderedList a), Ord a) => Ord (OrderedList a) | |
| Read a => Read (OrderedList a) | |
| Show a => Show (OrderedList a) | |
| (Ord a, Arbitrary a) => Arbitrary (OrderedList a) |
newtype NonEmptyList a Source
NonEmpty xs: guarantees that xs is non-empty.
Constructors
| NonEmpty | |
Fields
| |
Instances
| Eq a => Eq (NonEmptyList a) | |
| (Eq (NonEmptyList a), Ord a) => Ord (NonEmptyList a) | |
| Read a => Read (NonEmptyList a) | |
| Show a => Show (NonEmptyList a) | |
| Arbitrary a => Arbitrary (NonEmptyList a) |
Positive x: guarantees that x > 0.
Constructors
| Positive | |
Fields
| |
Instances
| Enum a => Enum (Positive a) | |
| Eq a => Eq (Positive a) | |
| (Real (Positive a), Enum (Positive a), Integral a) => Integral (Positive a) | |
| Num a => Num (Positive a) | |
| (Eq (Positive a), Ord a) => Ord (Positive a) | |
| Read a => Read (Positive a) | |
| (Num (Positive a), Ord (Positive a), Real a) => Real (Positive a) | |
| Show a => Show (Positive a) | |
| (Num a, Ord a, Arbitrary a) => Arbitrary (Positive a) |
NonZero x: guarantees that x /= 0.
Constructors
| NonZero | |
Fields
| |
Instances
| Enum a => Enum (NonZero a) | |
| Eq a => Eq (NonZero a) | |
| (Real (NonZero a), Enum (NonZero a), Integral a) => Integral (NonZero a) | |
| Num a => Num (NonZero a) | |
| (Eq (NonZero a), Ord a) => Ord (NonZero a) | |
| Read a => Read (NonZero a) | |
| (Num (NonZero a), Ord (NonZero a), Real a) => Real (NonZero a) | |
| Show a => Show (NonZero a) | |
| (Num a, Ord a, Arbitrary a) => Arbitrary (NonZero a) |
newtype NonNegative a Source
NonNegative x: guarantees that x >= 0.
Constructors
| NonNegative | |
Fields
| |
Instances
| Enum a => Enum (NonNegative a) | |
| Eq a => Eq (NonNegative a) | |
| (Real (NonNegative a), Enum (NonNegative a), Integral a) => Integral (NonNegative a) | |
| Num a => Num (NonNegative a) | |
| (Eq (NonNegative a), Ord a) => Ord (NonNegative a) | |
| Read a => Read (NonNegative a) | |
| (Num (NonNegative a), Ord (NonNegative a), Real a) => Real (NonNegative a) | |
| Show a => Show (NonNegative a) | |
| (Num a, Ord a, Arbitrary a) => Arbitrary (NonNegative a) |
Smart _ x: tries a different order when shrinking.
Shrink2 x: allows 2 shrinking steps at the same time when shrinking x
Constructors
| Shrink2 a |
Instances
| Enum a => Enum (Shrink2 a) | |
| Eq a => Eq (Shrink2 a) | |
| (Real (Shrink2 a), Enum (Shrink2 a), Integral a) => Integral (Shrink2 a) | |
| Num a => Num (Shrink2 a) | |
| (Eq (Shrink2 a), Ord a) => Ord (Shrink2 a) | |
| Read a => Read (Shrink2 a) | |
| (Num (Shrink2 a), Ord (Shrink2 a), Real a) => Real (Shrink2 a) | |
| Show a => Show (Shrink2 a) | |
| Arbitrary a => Arbitrary (Shrink2 a) |
Shrinking _ x: allows for maintaining a state during shrinking.
Constructors
| Shrinking s a |
class ShrinkState s a whereSource