mutator

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package mutator provides mutation types, statuses, and interfaces for mutation testing.

Index

Constants

This section is empty.

Variables

Types allows to iterate over Type.

Functions

This section is empty.

Types

type Mutator

type Mutator interface {
	// Type returns the Type of the Mutator.
	Type() Type

	// SetType sets the Type of the Mutator.
	SetType(mt Type)

	// Status returns the Status of the Mutator.
	Status() Status

	// SetStatus sets the Status of the Mutator.
	SetStatus(s Status)

	// Position returns the token.Position for the Mutator.
	// token.Position consumes more space than token.Pos, and in the future
	// we can consider a refactoring to remove its use and only use Mutator.Pos.
	Position() token.Position

	// Pos returns the token.Pos of the Mutator.
	Pos() token.Pos

	// Pkg returns the package where the Mutator is fount.
	Pkg() string

	// SetWorkdir sets the working directory which contains the source code on
	// which the Mutator will apply its mutations.
	SetWorkdir(p string)

	// Workdir returns the current working dir in which the Mutator will apply its mutations
	Workdir() string

	// Apply applies the mutation on the actual source code.
	Apply() error

	// Rollback removes the mutation from the source code and sets it back to
	// its original status.
	Rollback() error
}

Mutator represents a possible mutation of the source code.

type Status

type Status int

Status represents the status of a given TokenMutant.

  • NotCovered means that a TokenMutant has been identified, but is not covered by tests.
  • Runnable means that a TokenMutant has been identified and is covered by tests, which means it can be executed.
  • Lived means that the TokenMutant has been tested, but the tests did pass, which means the test suite is not effective in catching it.
  • Killed means that the TokenMutant has been tested and the tests failed, which means they are effective in covering this regression.
const (
	NotCovered Status = iota
	Runnable
	Skipped
	Lived
	Killed
	NotViable
	TimedOut
)

Currently supported MutantStatus.

func (Status) String

func (ms Status) String() string

type Type

type Type int

Type represents the category of the TokenMutant.

A single token.Token can be mutated in various ways depending on the specific mutation being tested. For example `<` can be mutated to `<=` in case of ConditionalsBoundary or `>=` in case of ConditionalsNegation.

const (
	ArithmeticBase Type = iota
	ConditionalsBoundary
	ConditionalsNegation
	IncrementDecrement
	InvertAssignments
	InvertBitwise
	InvertBitwiseAssignments
	InvertLogical
	InvertLoopCtrl
	InvertNegatives
	RemoveSelfAssignments
)

The currently supported Type in Gremlins.

func (Type) String

func (mt Type) String() string

Jump to

Keyboard shortcuts

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