| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Test.Mutagen.Mutation
Description
Mutations as transformations of values into mutants.
Synopsis
- type Pos = [Int]
- type Mutation a = a -> [Mutant a]
- class Typeable a => Mutable a where
- mutateEverywhere :: Mutable a => Mutation a
- wrap :: [Mutant a] -> (a -> b) -> [Mutant b]
- node :: [(Int, Tree Pos)] -> Tree Pos
- invalidPosition :: Pos -> a
- invalidPositionShow :: Show a => Pos -> a -> b
- newtype Immutable a = Immutable {
- unImmutabe :: a
- type MutationOrder = forall a. Tree a -> [a]
- preorder :: MutationOrder
- postorder :: MutationOrder
- levelorder :: MutationOrder
Mutable types
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.
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.
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
mutateEverywhere :: Mutable a => Mutation a Source #
A mutation that acts everywhere inside a mutable value.
Useful mostly for testing purposes.
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
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
| Arbitrary a => Arbitrary (Immutable a) Source # | |
| Read a => Read (Immutable a) Source # | |
| Show a => Show (Immutable a) Source # | |
| Eq a => Eq (Immutable a) Source # | |
| Ord a => Ord (Immutable a) Source # | |
Defined in Test.Mutagen.Mutation | |
| (Arbitrary a, Typeable a) => Mutable (Immutable a) Source # | |
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.