Mutation Operators

Mutagoph includes 23 mutation operators organized by category.

Arithmetic Operators

Operator Description Example
arithmetic_replace Replace arithmetic operators a + ba - b
arithmetic_delete Remove one operand a + ba

Comparison Operators

Operator Description Example
comparison_replace Replace comparison operators a == ba != b
comparison_boundary Modify boundary conditions a < ba <= b

Logical Operators

Operator Description Example
logical_replace Replace logical operators a && ba \|\| b

Bitwise Operators

Operator Description Example
bitwise_replace Replace bitwise operators a & ba \| b
bitwise_assign Replace bitwise assignment a &= ba \|= b

Literal Mutations

Operator Description Example
literal_replace Replace numeric literals 01, 4243
bool_replace Flip boolean literals truefalse
string_replace Replace string literals "hello"""

Statement Mutations

Operator Description Example
statement_delete Delete statement x = 5 → (removed)
return_replace Replace return with zero value return xreturn 0

Assignment Mutations

Operator Description Example
assign_replace Replace assignment operators x += 1x -= 1

Conditional Mutations

Operator Description Example
condition_negate Negate condition if x > 0if !(x > 0)
condition_remove Remove conditional if x { body }body
else_remove Remove else branch if x {} else { y }if x {}

Loop Mutations

Operator Description Example
loop_break Swap break/continue breakcontinue
loop_condition Modify loop condition for i < nfor true
loop_range_break Add break to range loop for range x { body }for range x { body; break }

Expression Mutations

Operator Description Example
call_silence Silence function call f()_ = f()
return_remove Remove return statement return x, err → (removed)
slice_boundary Modify slice boundaries s[:2]s[:1]

Switch Mutations

Operator Description Example
switch_case Remove or swap switch cases case body removed

Operator Categories

Mutations target different aspects of code:

  • Arithmetic/Comparison - Mathematical and logical correctness
  • Literals - Constant values and boundaries
  • Control Flow - Branches, loops, returns
  • Statements - Side effects and assignments

A high mutation score indicates your tests verify all these aspects thoroughly.