mutagen-0.1.0.0: Property-based testing framework for Haskell using type-preserving mutations.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Mutagen.Mutation

Description

Mutations as transformations of values into mutants.

Synopsis

Mutable types

type Pos = [Int] Source #

Breadcrumbs used to place mutations inside of values.

type Mutation a = a -> [Mutant a] Source #

Mutations as transformations of values into mutants.

class Typeable a => Mutable a where Source #

Mutable types that can be mutated by into similar values with small changes.

Minimal complete definition

Nothing

Methods

positions :: a -> Tree Pos Source #

List all the possible positions within a value that accept mutations.

def :: a Source #

Default value of this type to be used when "growing" a value.

This is used when mutating from a "smaller" instance to a "larger" data constructor; for example, when mutating from Nothing to 'Just a'. In those cases, def is used to fill the missing gaps deterministically.

mutate :: Mutation a Source #

Top-level mutation accepted by this value.

NOTE: this should only return the mutations that change the value at the top level; deeper mutations happening inside the value will be created on demand by Mutagen via inside during the testing loop.

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation a Source #

Apply a top-level mutation inside a value at the given position.

Note that the input mutation uses a higher-rank type to ensure that the mutation being applied is valid for the type at the given position, which is not necessarily the same as the one at the top-level.

Instances

Instances details
Mutable Word16 Source # 
Instance details

Defined in Test.Mutagen.Mutation

Mutable Word32 Source # 
Instance details

Defined in Test.Mutagen.Mutation

Mutable Word64 Source # 
Instance details

Defined in Test.Mutagen.Mutation

Mutable Word8 Source # 
Instance details

Defined in Test.Mutagen.Mutation

Mutable Args Source # 
Instance details

Defined in Test.Mutagen.Property

Mutable () Source # 
Instance details

Defined in Test.Mutagen.Mutation

Methods

positions :: () -> Tree Pos Source #

def :: () Source #

mutate :: Mutation () Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation () Source #

Mutable Bool Source # 
Instance details

Defined in Test.Mutagen.Mutation

Mutable Char Source # 
Instance details

Defined in Test.Mutagen.Mutation

Mutable Double Source # 
Instance details

Defined in Test.Mutagen.Mutation

Mutable Float Source # 
Instance details

Defined in Test.Mutagen.Mutation

Mutable Int Source # 
Instance details

Defined in Test.Mutagen.Mutation

(Arbitrary a, Typeable a) => Mutable (Immutable a) Source # 
Instance details

Defined in Test.Mutagen.Mutation

Mutable a => Mutable (Maybe a) Source # 
Instance details

Defined in Test.Mutagen.Mutation

Methods

positions :: Maybe a -> Tree Pos Source #

def :: Maybe a Source #

mutate :: Mutation (Maybe a) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (Maybe a) Source #

Mutable a => Mutable [a] Source # 
Instance details

Defined in Test.Mutagen.Mutation

Methods

positions :: [a] -> Tree Pos Source #

def :: [a] Source #

mutate :: Mutation [a] Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation [a] Source #

(Mutable v, Typeable k) => Mutable (Map k v) Source # 
Instance details

Defined in Test.Mutagen.Mutation

Methods

positions :: Map k v -> Tree Pos Source #

def :: Map k v Source #

mutate :: Mutation (Map k v) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (Map k v) Source #

(Mutable a, Mutable b) => Mutable (Either a b) Source # 
Instance details

Defined in Test.Mutagen.Mutation

Methods

positions :: Either a b -> Tree Pos Source #

def :: Either a b Source #

mutate :: Mutation (Either a b) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (Either a b) Source #

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

Defined in Test.Mutagen.Mutation

Methods

positions :: (a, b) -> Tree Pos Source #

def :: (a, b) Source #

mutate :: Mutation (a, b) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (a, b) Source #

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

Defined in Test.Mutagen.Mutation

Methods

positions :: (a, b, c) -> Tree Pos Source #

def :: (a, b, c) Source #

mutate :: Mutation (a, b, c) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (a, b, c) Source #

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

Defined in Test.Mutagen.Mutation

Methods

positions :: (a, b, c, d) -> Tree Pos Source #

def :: (a, b, c, d) Source #

mutate :: Mutation (a, b, c, d) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (a, b, c, d) Source #

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

Defined in Test.Mutagen.Mutation

Methods

positions :: (a, b, c, d, e) -> Tree Pos Source #

def :: (a, b, c, d, e) Source #

mutate :: Mutation (a, b, c, d, e) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (a, b, c, d, e) Source #

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

Defined in Test.Mutagen.Mutation

Methods

positions :: (a, b, c, d, e, f) -> Tree Pos Source #

def :: (a, b, c, d, e, f) Source #

mutate :: Mutation (a, b, c, d, e, f) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (a, b, c, d, e, f) Source #

(Mutable a, Mutable b, Mutable c, Mutable d, Mutable e, Mutable f, Mutable g) => Mutable (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Test.Mutagen.Mutation

Methods

positions :: (a, b, c, d, e, f, g) -> Tree Pos Source #

def :: (a, b, c, d, e, f, g) Source #

mutate :: Mutation (a, b, c, d, e, f, g) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (a, b, c, d, e, f, g) Source #

(Mutable a, Mutable b, Mutable c, Mutable d, Mutable e, Mutable f, Mutable g, Mutable h) => Mutable (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Test.Mutagen.Mutation

Methods

positions :: (a, b, c, d, e, f, g, h) -> Tree Pos Source #

def :: (a, b, c, d, e, f, g, h) Source #

mutate :: Mutation (a, b, c, d, e, f, g, h) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (a, b, c, d, e, f, g, h) Source #

(Mutable a, Mutable b, Mutable c, Mutable d, Mutable e, Mutable f, Mutable g, Mutable h, Mutable i) => Mutable (a, b, c, d, e, f, g, h, i) Source # 
Instance details

Defined in Test.Mutagen.Mutation

Methods

positions :: (a, b, c, d, e, f, g, h, i) -> Tree Pos Source #

def :: (a, b, c, d, e, f, g, h, i) Source #

mutate :: Mutation (a, b, c, d, e, f, g, h, i) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (a, b, c, d, e, f, g, h, i) Source #

(Mutable a, Mutable b, Mutable c, Mutable d, Mutable e, Mutable f, Mutable g, Mutable h, Mutable i, Mutable j) => Mutable (a, b, c, d, e, f, g, h, i, j) Source # 
Instance details

Defined in Test.Mutagen.Mutation

Methods

positions :: (a, b, c, d, e, f, g, h, i, j) -> Tree Pos Source #

def :: (a, b, c, d, e, f, g, h, i, j) Source #

mutate :: Mutation (a, b, c, d, e, f, g, h, i, j) Source #

inside :: Pos -> (forall x. Mutable x => Mutation x) -> Mutation (a, b, c, d, e, f, g, h, i, j) Source #

mutateEverywhere :: Mutable a => Mutation a Source #

A mutation that acts everywhere inside a mutable value.

Useful mostly for testing purposes.

wrap :: [Mutant a] -> (a -> b) -> [Mutant b] Source #

Wrap mutants with a constructor.

node :: [(Int, Tree Pos)] -> Tree Pos Source #

Construct a position tree node from its indexed children.

invalidPosition :: Pos -> a Source #

Report an invalid position error

invalidPositionShow :: Show a => Pos -> a -> b Source #

Report an invalid position error, showing also the value being mutated.

Immutable wrapper

newtype Immutable a Source #

A mutable wrapper that produces no mutations.

This useful for constraining certain parts of a data structure to be immutable while still fulfilling the Mutable interface.

Constructors

Immutable 

Fields

Instances

Instances details
Arbitrary a => Arbitrary (Immutable a) Source # 
Instance details

Defined in Test.Mutagen.Mutation

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

Defined in Test.Mutagen.Mutation

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

Defined in Test.Mutagen.Mutation

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

Defined in Test.Mutagen.Mutation

Methods

(==) :: Immutable a -> Immutable a -> Bool #

(/=) :: Immutable a -> Immutable a -> Bool #

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

Defined in Test.Mutagen.Mutation

(Arbitrary a, Typeable a) => Mutable (Immutable a) Source # 
Instance details

Defined in Test.Mutagen.Mutation

Mutation order

type MutationOrder = forall a. Tree a -> [a] Source #

Order in which to traverse the mutation positions of a value.

preorder :: MutationOrder Source #

Pre-order traversal.

postorder :: MutationOrder Source #

Post-order traversal.

levelorder :: MutationOrder Source #

Level-order traversal.