class Mutiny::Mutants::Mutation::Method::Helpers::OperatorReplacement

Public Instance Methods

pattern() click to toggle source
# File lib/mutiny/mutants/mutation/method/helpers/operator_replacement.rb, line 9
def pattern
  builder.either!(
    *operators.map { |ot| ot.build_pattern(builder) }
  )
end
replacement() click to toggle source
# File lib/mutiny/mutants/mutation/method/helpers/operator_replacement.rb, line 15
def replacement
  builder.derivation! :left, :right, :& do |left, right, root|
    builder.either!(*mutations_for(left, operator_name_from(root), right))
  end
end

Private Instance Methods

infix_operator_root() click to toggle source
# File lib/mutiny/mutants/mutation/method/helpers/operator_replacement.rb, line 40
def infix_operator_root
  :send
end
mutations_for(left, original_operator, right) click to toggle source
# File lib/mutiny/mutants/mutation/method/helpers/operator_replacement.rb, line 29
def mutations_for(left, original_operator, right)
  operators
    .reject { |o| o.name == original_operator.name }
    .map { |o| o.build_literal(builder, left, right) }
end
operator_name_from(root) click to toggle source
# File lib/mutiny/mutants/mutation/method/helpers/operator_replacement.rb, line 23
def operator_name_from(root)
  # the operator is the root element when prefix (2 children)
  # and is the middle child when infix (3 children)
  root.children.size == 2 ? root : root.children[1]
end
operators() click to toggle source
# File lib/mutiny/mutants/mutation/method/helpers/operator_replacement.rb, line 35
def operators
  infix_operator_names.map { |op| InfixOperator.new(op, infix_operator_root) } +
    prefix_operator_names.map { |op| PrefixOperator.new(op) }
end