| Safe Haskell | Trustworthy |
|---|---|
| Language | Haskell2010 |
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.
Note: the contents of this module are re-exported by Test.QuickCheck. You do not need to import it directly.
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
Synopsis
- newtype Blind a = Blind {
- getBlind :: a
- newtype Fixed a = Fixed {
- getFixed :: a
- newtype OrderedList a = Ordered {
- getOrdered :: [a]
- newtype NonEmptyList a = NonEmpty {
- getNonEmpty :: [a]
- data InfiniteList a = InfiniteList {
- getInfiniteList :: [a]
- infiniteListInternalData :: InfiniteListInternalData a
- newtype SortedList a = Sorted {
- getSorted :: [a]
- newtype Positive a = Positive {
- getPositive :: a
- newtype Negative a = Negative {
- getNegative :: a
- newtype NonZero a = NonZero {
- getNonZero :: a
- newtype NonNegative a = NonNegative {
- getNonNegative :: a
- newtype NonPositive a = NonPositive {
- getNonPositive :: a
- newtype Large a = Large {
- getLarge :: a
- newtype Small a = Small {
- getSmall :: a
- data Smart a = Smart Int a
- newtype Shrink2 a = Shrink2 {
- getShrink2 :: a
- data Shrinking s a = Shrinking s a
- class ShrinkState s a where
- shrinkInit :: a -> s
- shrinkState :: a -> s -> [(a, s)]
- newtype ASCIIString = ASCIIString {}
- newtype UnicodeString = UnicodeString {}
- newtype PrintableString = PrintableString {}
Type-level modifiers for changing generator behavior
Blind x: as x, but x does not have to be in the Show class.
Instances
Fixed x: as x, but will not be shrunk.
Instances
newtype OrderedList a Source #
Ordered xs: guarantees that xs is ordered.
Constructors
| Ordered | |
Fields
| |
Instances
newtype NonEmptyList a Source #
NonEmpty xs: guarantees that xs is non-empty.
Constructors
| NonEmpty | |
Fields
| |
Instances
data InfiniteList a Source #
InfiniteList xs _: guarantees that xs is an infinite list.
When a counterexample is found, only prints the prefix of xs
that was used by the program.
Here is a contrived example property:
prop_take_10 :: InfiniteList Char -> Bool prop_take_10 (InfiniteList xs _) = or [ x == 'a' | x <- take 10 xs ]
In the following counterexample, the list must start with "bbbbbbbbbb" but
the remaining (infinite) part can contain anything:
>>>quickCheck prop_take_10*** Failed! Falsified (after 1 test and 14 shrinks): "bbbbbbbbbb" ++ ...
Constructors
| InfiniteList | |
Fields
| |
Instances
| Arbitrary a => Arbitrary (InfiniteList a) Source # | |
Defined in Test.QuickCheck.Modifiers Methods arbitrary :: Gen (InfiniteList a) Source # shrink :: InfiniteList a -> [InfiniteList a] Source # | |
| Show a => Show (InfiniteList a) Source # | |
Defined in Test.QuickCheck.Modifiers | |
newtype SortedList a Source #
Sorted xs: guarantees that xs is sorted.
Instances
Positive x: guarantees that x > 0.
Constructors
| Positive | |
Fields
| |
Instances
Negative x: guarantees that x < 0.
Constructors
| Negative | |
Fields
| |
Instances
NonZero x: guarantees that x /= 0.
Constructors
| NonZero | |
Fields
| |
Instances
| Functor NonZero Source # | |
| (Num a, Eq a, Arbitrary a) => Arbitrary (NonZero a) Source # | |
| Enum a => Enum (NonZero a) Source # | |
Defined in Test.QuickCheck.Modifiers Methods succ :: NonZero a -> NonZero a Source # pred :: NonZero a -> NonZero a Source # toEnum :: Int -> NonZero a Source # fromEnum :: NonZero a -> Int Source # enumFrom :: NonZero a -> [NonZero a] Source # enumFromThen :: NonZero a -> NonZero a -> [NonZero a] Source # enumFromTo :: NonZero a -> NonZero a -> [NonZero a] Source # enumFromThenTo :: NonZero a -> NonZero a -> NonZero a -> [NonZero a] Source # | |
| Read a => Read (NonZero a) Source # | |
| Show a => Show (NonZero a) Source # | |
| Eq a => Eq (NonZero a) Source # | |
| Ord a => Ord (NonZero a) Source # | |
Defined in Test.QuickCheck.Modifiers | |
newtype NonNegative a Source #
NonNegative x: guarantees that x >= 0.
Constructors
| NonNegative | |
Fields
| |
Instances
newtype NonPositive a Source #
NonPositive x: guarantees that x <= 0.
Constructors
| NonPositive | |
Fields
| |
Instances
Large x: by default, QuickCheck generates Ints drawn from a small
range. Large Int gives you values drawn from the entire range instead.
Instances
Small x: generates values of x drawn from a small range.
The opposite of Large.
Instances
Smart _ x: tries a different order when shrinking.
Shrink2 x: allows 2 shrinking steps at the same time when shrinking x
Constructors
| Shrink2 | |
Fields
| |
Instances
Shrinking _ x: allows for maintaining a state during shrinking.
Constructors
| Shrinking s a |
class ShrinkState s a where Source #
newtype ASCIIString Source #
ASCIIString: generates an ASCII string.
Constructors
| ASCIIString | |
Fields | |
Instances
| Arbitrary ASCIIString Source # | |
Defined in Test.QuickCheck.Modifiers | |
| Read ASCIIString Source # | |
Defined in Test.QuickCheck.Modifiers | |
| Show ASCIIString Source # | |
Defined in Test.QuickCheck.Modifiers | |
| Eq ASCIIString Source # | |
Defined in Test.QuickCheck.Modifiers Methods (==) :: ASCIIString -> ASCIIString -> Bool Source # (/=) :: ASCIIString -> ASCIIString -> Bool Source # | |
| Ord ASCIIString Source # | |
Defined in Test.QuickCheck.Modifiers Methods compare :: ASCIIString -> ASCIIString -> Ordering Source # (<) :: ASCIIString -> ASCIIString -> Bool Source # (<=) :: ASCIIString -> ASCIIString -> Bool Source # (>) :: ASCIIString -> ASCIIString -> Bool Source # (>=) :: ASCIIString -> ASCIIString -> Bool Source # max :: ASCIIString -> ASCIIString -> ASCIIString Source # min :: ASCIIString -> ASCIIString -> ASCIIString Source # | |
newtype UnicodeString Source #
UnicodeString: generates a unicode String.
The string will not contain surrogate pairs.
Constructors
| UnicodeString | |
Fields | |
Instances
| Arbitrary UnicodeString Source # | |
Defined in Test.QuickCheck.Modifiers | |
| Read UnicodeString Source # | |
Defined in Test.QuickCheck.Modifiers | |
| Show UnicodeString Source # | |
Defined in Test.QuickCheck.Modifiers | |
| Eq UnicodeString Source # | |
Defined in Test.QuickCheck.Modifiers Methods (==) :: UnicodeString -> UnicodeString -> Bool Source # (/=) :: UnicodeString -> UnicodeString -> Bool Source # | |
| Ord UnicodeString Source # | |
Defined in Test.QuickCheck.Modifiers Methods compare :: UnicodeString -> UnicodeString -> Ordering Source # (<) :: UnicodeString -> UnicodeString -> Bool Source # (<=) :: UnicodeString -> UnicodeString -> Bool Source # (>) :: UnicodeString -> UnicodeString -> Bool Source # (>=) :: UnicodeString -> UnicodeString -> Bool Source # max :: UnicodeString -> UnicodeString -> UnicodeString Source # min :: UnicodeString -> UnicodeString -> UnicodeString Source # | |
newtype PrintableString Source #
PrintableString: generates a printable unicode String.
The string will not contain surrogate pairs.
Constructors
| PrintableString | |
Fields | |