smartcheck-0.2.1: A smarter QuickCheck.

Safe HaskellNone

Test.SmartCheck

Contents

Description

Interface module.

Synopsis

Main SmartCheck interface.

smartCheck :: (SubTypes a, Generic a, ConNames (Rep a), Testable prop) => ScArgs -> (a -> prop) -> IO ()Source

Main interface function.

User-suppplied counterexample interface.

smartCheckInput :: forall a prop. (SubTypes a, Generic a, ConNames (Rep a), Testable prop, Read a) => ScArgs -> (a -> prop) -> IO ()Source

Run QuickCheck and get a result.

runQC :: forall a prop. (Show a, Arbitrary a, Testable prop) => Args -> (a -> prop) -> IO (Maybe a, a -> Property)Source

Run QuickCheck, to get a counterexamples for each argument, including the one we want to focus on for SmartCheck, which is the first argument. That argument is never shrunk by QuickCheck, but others may be shrunk by QuickCheck. Returns the value (if it exists) and a Property (by applying the property method to the Testable value). In each iteration of runQC, non-SmartCheck arguments are not necessarily held constant

Arguments

Main type class based on Generics.

class (Arbitrary a, Show a, Typeable a) => SubTypes a whereSource

This class covers algebraic datatypes that can be transformed into Trees. subTypes is the main method, placing values into trees.

for a datatype with constructors A and C,

 subTypes (A (C 0) 1)
 [Node {rootLabel = C 0, subForest = []}]

Methods

subTypes :: a -> Forest SubTSource

Turns algebraic data into a forest representation.

baseType :: a -> BoolSource

Base types (e.g., Int, Char) aren't analyzed.

replaceChild :: Typeable b => a -> Forest Subst -> b -> Maybe aSource

Generically replace child i in m with value s. A total function: returns Nothing if you try to replace a child with an ill-typed child s. (Returns Just (the original data) if your index is out of bounds).

toConstr :: a -> StringSource

Get the string representation of the constructor.

showForest :: a -> Forest StringSource

showForest generically shows a value while preserving its structure (in a Tree). Always returns either a singleton list containing the tree (a degenerate forest) or an empty list for baseTypes. An invariant is that the shape of the tree produced by showForest is the same as the one produced by subTypes.

For constructing new instances of SubTypes

gst :: GST f => f a -> Forest SubTSource

grc :: (GST f, Typeable b) => f a -> Forest Subst -> b -> Maybe (f a)Source

gtc :: GST f => f a -> StringSource

gsf :: GST f => f a -> Forest StringSource