testing-feat-1.0.1.0: Functional Enumeration of Algebraic Types

Safe HaskellNone
LanguageHaskell98

Test.Feat

Contents

Description

This module contains a (hopefully) manageable subset of the functionality of Feat. The rest resides only in the Test.Feat.* modules.

Synopsis

Testing driver

test :: Enumerable a => (a -> Bool) -> IO (Result a) Source #

Test with default options (defOptions).

testOptions :: Enumerable a => Options -> (a -> Bool) -> IO (Result a) Source #

Test with basic options.

data Options Source #

Basic options for executing a test. Unlike FlexibleOptions this type has Show/Read instances.

Constructors

Options 

Fields

defOptions :: Options Source #

60 seconds timeout, maximum size of 100, bound of 100000 tests per size

The type class

data Enumerate a Source #

A functional enumeration of type t is a partition of t into finite numbered sets called Parts. Each parts contains values of a certain cost (typically the size of the value).

Instances

Functor Enumerate Source #

Only use fmap with bijective functions (e.g. data constructors)

Methods

fmap :: (a -> b) -> Enumerate a -> Enumerate b #

(<$) :: a -> Enumerate b -> Enumerate a #

Applicative Enumerate Source #

Pure is singleton and <*> corresponds to cartesian product (as with lists)

Methods

pure :: a -> Enumerate a #

(<*>) :: Enumerate (a -> b) -> Enumerate a -> Enumerate b #

liftA2 :: (a -> b -> c) -> Enumerate a -> Enumerate b -> Enumerate c #

(*>) :: Enumerate a -> Enumerate b -> Enumerate b #

(<*) :: Enumerate a -> Enumerate b -> Enumerate a #

Alternative Enumerate Source # 

Methods

empty :: Enumerate a #

(<|>) :: Enumerate a -> Enumerate a -> Enumerate a #

some :: Enumerate a -> Enumerate [a] #

many :: Enumerate a -> Enumerate [a] #

Sized Enumerate Source # 
Semigroup (Enumerate a) Source # 

Methods

(<>) :: Enumerate a -> Enumerate a -> Enumerate a #

sconcat :: NonEmpty (Enumerate a) -> Enumerate a #

stimes :: Integral b => b -> Enumerate a -> Enumerate a #

Monoid (Enumerate a) Source #

The mappend is (disjoint) union

class Typeable * a => Enumerable a where #

Minimal complete definition

enumerate

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f a #

Instances

Enumerable Bool 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Bool #

Enumerable Char

ASCII characters

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Char #

Enumerable Double

Not a proper injection

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Double #

Enumerable Float

Not a proper injection

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Float #

Enumerable Int 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Int #

Enumerable Int8 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Int8 #

Enumerable Int16 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Int16 #

Enumerable Int32 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Int32 #

Enumerable Int64 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Int64 #

Enumerable Integer 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Integer #

Enumerable Ordering 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Ordering #

Enumerable Word 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Word #

Enumerable Word8 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Word8 #

Enumerable Word16 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Word16 #

Enumerable Word32 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Word32 #

Enumerable Word64 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Word64 #

Enumerable ()

The unit constructor is free

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f () #

Enumerable Unicode 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Unicode #

Enumerable Printable 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f Printable #

Enumerable a => Enumerable [a] 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f [a] #

Enumerable a => Enumerable (Maybe a) 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f (Maybe a) #

Infinite a => Enumerable (Ratio a) 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f (Ratio a) #

Infinite integer => Enumerable (Nat integer) 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f (Nat integer) #

Enumerable a => Enumerable (NonEmpty a) 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f (NonEmpty a) #

(CoEnumerable a, Enumerable b) => Enumerable (a -> b) 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f (a -> b) #

(Enumerable a, Enumerable b) => Enumerable (Either a b) 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f (Either a b) #

(Enumerable a, Enumerable b) => Enumerable (a, b) 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f (a, b) #

(Enumerable a, Enumerable b, Enumerable c) => Enumerable (a, b, c) 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f (a, b, c) #

(Enumerable a, Enumerable b, Enumerable c, Enumerable d) => Enumerable (a, b, c, d) 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f (a, b, c, d) #

(Enumerable a, Enumerable b, Enumerable c, Enumerable d, Enumerable e) => Enumerable (a, b, c, d, e) 

Methods

enumerate :: (Typeable (* -> *) f, Sized f) => Shared f (a, b, c, d, e) #

datatype :: (Typeable * a, Sized f, Typeable (* -> *) f) => [Shareable f a] -> Shared f a #

Builds an enumeration of a data type from a list of constructors (see c0-c7)

c0 :: Sized f => a -> Shareable f a #

Takes a constructor with arity 0 (a pure value)

c1 :: (Enumerable a, Sized f, Typeable (* -> *) f) => (a -> x) -> Shareable f x #

Takes a constructor of arity 1

c2 :: (Enumerable a, Enumerable b, Sized f, Typeable (* -> *) f) => (a -> b -> x) -> Shareable f x #

c3 :: (Enumerable a, Enumerable b, Enumerable c, Sized f, Typeable (* -> *) f) => (a -> b -> c -> x) -> Shareable f x #

c4 :: (Enumerable a, Enumerable b, Enumerable c, Enumerable d, Sized f, Typeable (* -> *) f) => (a -> b -> c -> d -> x) -> Shareable f x #

c5 :: (Enumerable a, Enumerable b, Enumerable c, Enumerable d, Enumerable e, Sized f, Typeable (* -> *) f) => (a -> b -> c -> d -> e -> x) -> Shareable f x #

c6 :: (Enumerable a, Enumerable b, Enumerable c, Enumerable d, Enumerable e, Enumerable g, Sized f, Typeable (* -> *) f) => (a -> b -> c -> d -> e -> g -> x) -> Shareable f x #

c7 :: (Enumerable a, Enumerable b, Enumerable c, Enumerable d, Enumerable e, Enumerable g, Enumerable h, Sized f, Typeable (* -> *) f) => (a -> b -> c -> d -> e -> g -> h -> x) -> Shareable f x #

Automatic derivation

Accessing data

optimal :: Enumerable a => Enumerate a Source #

Memoised enumeration. Note that all cardinalities are kept in memory until your program terminates.

index :: Enumerable a => Integer -> a Source #

Index into an enumeration. Mainly used for party tricks (give it a really large number), since usually you want to distinguish values by size.

select :: Enumerable a => Int -> Index -> a Source #

A more fine grained version of index that takes a size and an index into the values of that size. select p i is only defined for i within bounds (meaning i < fst (values !! p)).

values :: Enumerable a => [(Integer, [a])] Source #

All values of the enumeration by increasing cost (which is the number of constructors for most types). Also contains the length of each list.

uniform :: Enumerable a => Int -> Gen a Source #

Compatibility with QuickCheck. Distribution is uniform generator over values bounded by the given size. Typical use: sized uniform.