QuickCheck-2.14.2: Automatic testing of Haskell programs
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 (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 of forAll orderedList
prop_Sort (Ordered (xs :: [OrdA])) =
  sort xs == xs
Synopsis

Type-level modifiers for changing generator behavior

newtype Blind a Source #

Blind x : as x, but x does not have to be in the Show class.

Constructors

Blind

Fields

Instances

Instances details
Functor Blind Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Enum a => Enum ( Blind a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( Blind a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Integral a => Integral ( Blind a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Num a => Num ( Blind a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( Blind a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Real a => Real ( Blind a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show ( Blind a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Arbitrary a => Arbitrary ( Blind a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

newtype Fixed a Source #

Fixed x : as x, but will not be shrunk.

Constructors

Fixed

Fields

Instances

Instances details
Functor Fixed Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Enum a => Enum ( Fixed a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( Fixed a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Integral a => Integral ( Fixed a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Num a => Num ( Fixed a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( Fixed a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( Fixed a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Real a => Real ( Fixed a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( Fixed a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Arbitrary a => Arbitrary ( Fixed a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

newtype OrderedList a Source #

Ordered xs : guarantees that xs is ordered.

Constructors

Ordered

Fields

Instances

Instances details
Functor OrderedList Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( OrderedList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( OrderedList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( OrderedList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( OrderedList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

( Ord a, Arbitrary a) => Arbitrary ( OrderedList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

newtype NonEmptyList a Source #

NonEmpty xs : guarantees that xs is non-empty.

Constructors

NonEmpty

Fields

Instances

Instances details
Functor NonEmptyList Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( NonEmptyList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( NonEmptyList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( NonEmptyList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( NonEmptyList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Arbitrary a => Arbitrary ( NonEmptyList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

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

newtype SortedList a Source #

Sorted xs : guarantees that xs is sorted.

Constructors

Sorted

Fields

Instances

Instances details
Functor SortedList Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( SortedList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( SortedList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( SortedList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( SortedList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

( Arbitrary a, Ord a) => Arbitrary ( SortedList a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

newtype Positive a Source #

Positive x : guarantees that x > 0 .

Constructors

Positive

Fields

Instances

Instances details
Functor Positive Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Enum a => Enum ( Positive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( Positive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( Positive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( Positive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( Positive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

( Num a, Ord a, Arbitrary a) => Arbitrary ( Positive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

newtype Negative a Source #

Negative x : guarantees that x < 0 .

Constructors

Negative

Fields

Instances

Instances details
Functor Negative Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Enum a => Enum ( Negative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( Negative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( Negative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( Negative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( Negative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

( Num a, Ord a, Arbitrary a) => Arbitrary ( Negative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

newtype NonZero a Source #

NonZero x : guarantees that x /= 0 .

Constructors

NonZero

Fields

Instances

Instances details
Functor NonZero Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Enum a => Enum ( NonZero a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( NonZero a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( NonZero a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( NonZero a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( NonZero a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

( Num a, Eq a, Arbitrary a) => Arbitrary ( NonZero a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

newtype NonNegative a Source #

NonNegative x : guarantees that x >= 0 .

Constructors

NonNegative

Fields

Instances

Instances details
Functor NonNegative Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Enum a => Enum ( NonNegative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( NonNegative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( NonNegative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( NonNegative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( NonNegative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

( Num a, Ord a, Arbitrary a) => Arbitrary ( NonNegative a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

newtype NonPositive a Source #

NonPositive x : guarantees that x <= 0 .

Constructors

NonPositive

Fields

Instances

Instances details
Functor NonPositive Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Enum a => Enum ( NonPositive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( NonPositive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( NonPositive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( NonPositive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( NonPositive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

( Num a, Ord a, Arbitrary a) => Arbitrary ( NonPositive a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

newtype Large a Source #

Large x : by default, QuickCheck generates Int s drawn from a small range. Large Int gives you values drawn from the entire range instead.

Constructors

Large

Fields

Instances

Instances details
Functor Large Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Enum a => Enum ( Large a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( Large a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Integral a => Integral ( Large a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Num a => Num ( Large a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( Large a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( Large a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Real a => Real ( Large a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( Large a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ix a => Ix ( Large a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

( Integral a, Bounded a) => Arbitrary ( Large a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

newtype Small a Source #

Small x : generates values of x drawn from a small range. The opposite of Large .

Constructors

Small

Fields

Instances

Instances details
Functor Small Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Enum a => Enum ( Small a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( Small a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Integral a => Integral ( Small a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Num a => Num ( Small a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( Small a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( Small a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Real a => Real ( Small a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( Small a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ix a => Ix ( Small a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Integral a => Arbitrary ( Small a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

newtype Shrink2 a Source #

Shrink2 x : allows 2 shrinking steps at the same time when shrinking x

Constructors

Shrink2

Fields

Instances

Instances details
Functor Shrink2 Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Enum a => Enum ( Shrink2 a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Eq a => Eq ( Shrink2 a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Integral a => Integral ( Shrink2 a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Num a => Num ( Shrink2 a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord a => Ord ( Shrink2 a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read a => Read ( Shrink2 a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Real a => Real ( Shrink2 a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show a => Show ( Shrink2 a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Arbitrary a => Arbitrary ( Shrink2 a) Source #
Instance details

Defined in Test.QuickCheck.Modifiers

class ShrinkState s a where Source #

Methods

shrinkInit :: a -> s Source #

shrinkState :: a -> s -> [(a, s)] Source #

newtype UnicodeString Source #

UnicodeString : generates a unicode String. The string will not contain surrogate pairs.

newtype PrintableString Source #

PrintableString : generates a printable unicode String. The string will not contain surrogate pairs.

Instances

Instances details
Eq PrintableString Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Ord PrintableString Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Read PrintableString Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Show PrintableString Source #
Instance details

Defined in Test.QuickCheck.Modifiers

Arbitrary PrintableString Source #
Instance details

Defined in Test.QuickCheck.Modifiers