mutator

package
v0.0.0-...-a33683f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(m Mutator)

Register adds a mutator to the registry.

Types

type Candidate

type Candidate struct {
	ID      string
	Mutator Mutator
	Node    ast.Node
}

Candidate represents a potential mutation.

func Scan

func Scan(file *ast.File, fset *token.FileSet, mutators []Mutator) []Candidate

Scan finds all mutation candidates in a file.

type Comparison

type Comparison struct{}

Comparison swaps relational operators with their logical opposites.

func (*Comparison) Apply

func (m *Comparison) Apply(node ast.Node)

func (*Comparison) Check

func (m *Comparison) Check(node ast.Node) bool

func (*Comparison) Name

func (m *Comparison) Name() string

func (*Comparison) Position

func (m *Comparison) Position(node ast.Node) token.Pos

type Logical

type Logical struct{}

Logical swaps logical operators (&& <-> ||).

func (*Logical) Apply

func (m *Logical) Apply(node ast.Node)

func (*Logical) Check

func (m *Logical) Check(node ast.Node) bool

func (*Logical) Name

func (m *Logical) Name() string

func (*Logical) Position

func (m *Logical) Position(node ast.Node) token.Pos

type Mutator

type Mutator interface {
	Name() string
	Check(node ast.Node) bool
	Apply(node ast.Node)
	Position(node ast.Node) token.Pos
}

Mutator defines the interface for AST mutations.

func All

func All() []Mutator

All returns all registered mutators.

func Get

func Get(name string) (Mutator, bool)

Get returns a mutator by name.

type ReverseIfCond

type ReverseIfCond struct{}

ReverseIfCond negates boolean expressions in if statements.

func (*ReverseIfCond) Apply

func (m *ReverseIfCond) Apply(node ast.Node)

func (*ReverseIfCond) Check

func (m *ReverseIfCond) Check(node ast.Node) bool

func (*ReverseIfCond) Name

func (m *ReverseIfCond) Name() string

func (*ReverseIfCond) Position

func (m *ReverseIfCond) Position(node ast.Node) token.Pos

type SwapArithmetic

type SwapArithmetic struct{}

SwapArithmetic swaps arithmetic operators.

func (*SwapArithmetic) Apply

func (m *SwapArithmetic) Apply(node ast.Node)

func (*SwapArithmetic) Check

func (m *SwapArithmetic) Check(node ast.Node) bool

func (*SwapArithmetic) Name

func (m *SwapArithmetic) Name() string

func (*SwapArithmetic) Position

func (m *SwapArithmetic) Position(node ast.Node) token.Pos

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL