Documentation
¶
Overview ¶
Package mutator defines the Mutator function type and the registration mechanism used by all built-in and third-party mutation operators.
Implementing a custom operator requires three steps:
- Write a function with the Mutator signature.
- Call Register from an init() function so it is available at startup.
- Import your package (blank import) in a fork of cmd/go-mutesting/main.go.
Example:
func init() {
mutator.Register("mypkg/flip-sign", flipSign)
}
func flipSign(_ *types.Package, _ *types.Info, node ast.Node) []mutator.Mutation {
n, ok := node.(*ast.UnaryExpr)
if !ok || n.Op != token.SUB {
return nil
}
return []mutator.Mutation{
{Change: func() { n.Op = token.ADD }, Reset: func() { n.Op = token.SUB }},
}
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Mutation ¶
type Mutation struct {
// Change is called before executing the exec command.
Change func()
// Reset is called after executing the exec command.
Reset func()
}
Mutation defines the behavior of one mutation
Click to show internal directories.
Click to hide internal directories.