Safe Haskell | Trustworthy |
---|---|
Language | Haskell98 |
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
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]
- newtype Positive a = Positive {
- getPositive :: a
- newtype NonZero a = NonZero {
- getNonZero :: a
- newtype NonNegative a = NonNegative {
- getNonNegative :: 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)]
Type-level modifiers for changing generator behavior
Blind x
: as x, but x does not have to be in the Show
class.
Instances
Functor Blind # | |
Enum a => Enum (Blind a) # | |
Eq a => Eq (Blind a) # | |
Integral a => Integral (Blind a) # | |
Defined in Test.QuickCheck.Modifiers | |
Num a => Num (Blind a) # | |
Ord a => Ord (Blind a) # | |
Defined in Test.QuickCheck.Modifiers | |
Real a => Real (Blind a) # | |
Defined in Test.QuickCheck.Modifiers Methods toRational :: Blind a -> Rational # | |
Show (Blind a) # | |
Arbitrary a => Arbitrary (Blind a) # | |
Fixed x
: as x, but will not be shrunk.
Instances
Functor Fixed # | |
Enum a => Enum (Fixed a) # | |
Eq a => Eq (Fixed a) # | |
Integral a => Integral (Fixed a) # | |
Defined in Test.QuickCheck.Modifiers | |
Num a => Num (Fixed a) # | |
Ord a => Ord (Fixed a) # | |
Defined in Test.QuickCheck.Modifiers | |
Read a => Read (Fixed a) # | |
Real a => Real (Fixed a) # | |
Defined in Test.QuickCheck.Modifiers Methods toRational :: Fixed a -> Rational # | |
Show a => Show (Fixed a) # | |
Arbitrary a => Arbitrary (Fixed a) # | |
newtype OrderedList a #
Ordered xs
: guarantees that xs is ordered.
Constructors
Ordered | |
Fields
|
Instances
newtype NonEmptyList a #
NonEmpty xs
: guarantees that xs is non-empty.
Constructors
NonEmpty | |
Fields
|
Instances
Positive x
: guarantees that x > 0
.
Constructors
Positive | |
Fields
|
Instances
Functor Positive # | |
Enum a => Enum (Positive a) # | |
Defined in Test.QuickCheck.Modifiers Methods succ :: Positive a -> Positive a # pred :: Positive a -> Positive a # fromEnum :: Positive a -> Int # enumFrom :: Positive a -> [Positive a] # enumFromThen :: Positive a -> Positive a -> [Positive a] # enumFromTo :: Positive a -> Positive a -> [Positive a] # enumFromThenTo :: Positive a -> Positive a -> Positive a -> [Positive a] # | |
Eq a => Eq (Positive a) # | |
Ord a => Ord (Positive a) # | |
Defined in Test.QuickCheck.Modifiers | |
Read a => Read (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
Functor NonZero # | |
Enum a => Enum (NonZero a) # | |
Defined in Test.QuickCheck.Modifiers Methods succ :: NonZero a -> NonZero a # pred :: NonZero a -> NonZero a # fromEnum :: NonZero a -> Int # enumFrom :: NonZero a -> [NonZero a] # enumFromThen :: NonZero a -> NonZero a -> [NonZero a] # enumFromTo :: NonZero a -> NonZero a -> [NonZero a] # enumFromThenTo :: NonZero a -> NonZero a -> NonZero a -> [NonZero a] # | |
Eq a => Eq (NonZero a) # | |
Ord a => Ord (NonZero a) # | |
Read a => Read (NonZero a) # | |
Show a => Show (NonZero a) # | |
(Num a, Eq a, Arbitrary a) => Arbitrary (NonZero a) # | |
newtype NonNegative a #
NonNegative x
: guarantees that x >= 0
.
Constructors
NonNegative | |
Fields
|
Instances
Large x
: by default, QuickCheck generates Int
s drawn from a small
range. Large Int
gives you values drawn from the entire range instead.
Instances
Functor Large # | |
Enum a => Enum (Large a) # | |
Eq a => Eq (Large a) # | |
Integral a => Integral (Large a) # | |
Defined in Test.QuickCheck.Modifiers | |
Num a => Num (Large a) # | |
Ord a => Ord (Large a) # | |
Defined in Test.QuickCheck.Modifiers | |
Read a => Read (Large a) # | |
Real a => Real (Large a) # | |
Defined in Test.QuickCheck.Modifiers Methods toRational :: Large a -> Rational # | |
Show a => Show (Large a) # | |
(Integral a, Bounded a) => Arbitrary (Large a) # | |
Small x
: generates values of x
drawn from a small range.
The opposite of Large
.
Instances
Functor Small # | |
Enum a => Enum (Small a) # | |
Eq a => Eq (Small a) # | |
Integral a => Integral (Small a) # | |
Defined in Test.QuickCheck.Modifiers | |
Num a => Num (Small a) # | |
Ord a => Ord (Small a) # | |
Defined in Test.QuickCheck.Modifiers | |
Read a => Read (Small a) # | |
Real a => Real (Small a) # | |
Defined in Test.QuickCheck.Modifiers Methods toRational :: Small a -> Rational # | |
Show a => Show (Small a) # | |
Integral a => Arbitrary (Small a) # | |
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 #