quickcheck-dynamic-1.0.0: A library for stateful property-based testing
Safe HaskellNone
LanguageHaskell2010

Test.QuickCheck.DynamicLogic.Quantify

Description

This module defines Quantifications, which are used together with forAllQ in DynamicLogic. A `Quantification t` can be used to generate a t, shrink a t, and recognise a generated t.

Synopsis

Documentation

data Quantification a Source #

A Quantification over a type a is a generator that can be used with forAllQ to generate random values in DL scenarios. In addition to a QuickCheck generator a Quantification contains a shrinking strategy that ensures that shrunk values stay in the range of the generator.

Instances

Instances details
(Eq a, Show a, Typeable a) => Quantifiable (Quantification a) Source # 
Instance details

Defined in Test.QuickCheck.DynamicLogic.Quantify

Associated Types

type Quantifies (Quantification a) Source #

type Quantifies (Quantification a) Source # 
Instance details

Defined in Test.QuickCheck.DynamicLogic.Quantify

shrinkQ :: Quantification a -> a -> [a] Source #

arbitraryQ :: Arbitrary a => Quantification a Source #

Pack up an Arbitrary instance as a Quantification. Treats all values as being in range.

exactlyQ :: Eq a => a -> Quantification a Source #

Generates exactly the given value. Does not shrink.

elementsQ :: Eq a => [a] -> Quantification a Source #

Pick a random value from a list. Treated as an empty choice if the list is empty:

forAllQ (elementsQ []) == empty

oneofQ :: [Quantification a] -> Quantification a Source #

Choose from a list of quantifications. Same as frequencyQ with all weights the same (and > 0).

frequencyQ :: [(Int, Quantification a)] -> Quantification a Source #

Choose from a weighted list of quantifications. Treated as an empty choice if no quantification has weight > 0.

mapQ :: (a -> b, b -> a) -> Quantification a -> Quantification b Source #

Quantification is not a Functor, since it also keeps track of the range of the generators. However, if you have two functions to :: a -> b from :: b -> a satisfying from . to = id you can go from a quantification over a to one over b. Note that the from function need only be defined on the image of to.

whereQ :: Quantification a -> (a -> Bool) -> Quantification a Source #

Restrict the range of a quantification.

chooseQ :: (Arbitrary a, Random a, Ord a) => (a, a) -> Quantification a Source #

Generate a random value in a given range (inclusive).

withGenQ :: Gen a -> (a -> [a]) -> Quantification a Source #

Wrap a `Gen a` generator in a `Quantification a`. Uses given shrinker.

class (Eq (Quantifies q), Show (Quantifies q), Typeable (Quantifies q)) => Quantifiable q where Source #

Generalization of Quantifications, which lets you treat lists and tuples of quantifications as quantifications. For instance,

  ...
  (die1, die2) <- forAllQ (chooseQ (1, 6), chooseQ (1, 6))
  ...

Associated Types

type Quantifies q Source #

The type of values quantified over.

Quantifies (Quantification a) = a

Methods

quantify :: q -> Quantification (Quantifies q) Source #

Computing the actual Quantification.

Instances

Instances details
Quantifiable a => Quantifiable [a] Source # 
Instance details

Defined in Test.QuickCheck.DynamicLogic.Quantify

Associated Types

type Quantifies [a] Source #

Methods

quantify :: [a] -> Quantification (Quantifies [a]) Source #

(Eq a, Show a, Typeable a) => Quantifiable (Quantification a) Source # 
Instance details

Defined in Test.QuickCheck.DynamicLogic.Quantify

Associated Types

type Quantifies (Quantification a) Source #

(Quantifiable a, Quantifiable b) => Quantifiable (a, b) Source # 
Instance details

Defined in Test.QuickCheck.DynamicLogic.Quantify

Associated Types

type Quantifies (a, b) Source #

Methods

quantify :: (a, b) -> Quantification (Quantifies (a, b)) Source #

(Quantifiable a, Quantifiable b, Quantifiable c) => Quantifiable (a, b, c) Source # 
Instance details

Defined in Test.QuickCheck.DynamicLogic.Quantify

Associated Types

type Quantifies (a, b, c) Source #

Methods

quantify :: (a, b, c) -> Quantification (Quantifies (a, b, c)) Source #

(Quantifiable a, Quantifiable b, Quantifiable c, Quantifiable d) => Quantifiable (a, b, c, d) Source # 
Instance details

Defined in Test.QuickCheck.DynamicLogic.Quantify

Associated Types

type Quantifies (a, b, c, d) Source #

Methods

quantify :: (a, b, c, d) -> Quantification (Quantifies (a, b, c, d)) Source #

(Quantifiable a, Quantifiable b, Quantifiable c, Quantifiable d, Quantifiable e) => Quantifiable (a, b, c, d, e) Source # 
Instance details

Defined in Test.QuickCheck.DynamicLogic.Quantify

Associated Types

type Quantifies (a, b, c, d, e) Source #

Methods

quantify :: (a, b, c, d, e) -> Quantification (Quantifies (a, b, c, d, e)) Source #