class Mutest::Mutator::Node::OpAsgn

OpAsgn mutator

Private Instance Methods

dispatch() click to toggle source

Emit mutations

@return [undefined]

# File lib/mutest/mutator/node/op_asgn.rb, line 15
def dispatch
  emit_singletons
  emit_left_mutations do |node|
    !n_self?(node)
  end
  emit_right_mutations
  emit_compound_assignment_mutations
end
emit_compound_assignment_mutations() click to toggle source

Mutate compound assignments like `+=` to `+` and `=`

# File lib/mutest/mutator/node/op_asgn.rb, line 25
def emit_compound_assignment_mutations
  case left.type
  when :lvasgn then emit_lvar_mutation
  when :ivasgn then emit_ivar_mutation
  when :send   then emit_send_mutation
  end
end
emit_ivar_mutation() click to toggle source
# File lib/mutest/mutator/node/op_asgn.rb, line 38
def emit_ivar_mutation
  emit(s(:send, s(:ivar, *left), operation, right))
  emit(s(:ivasgn, *left, right))
end
emit_lvar_mutation() click to toggle source
# File lib/mutest/mutator/node/op_asgn.rb, line 33
def emit_lvar_mutation
  emit(s(:send, s(:send, nil, *left), operation, right))
  emit(s(:lvasgn, *left, right))
end
emit_send_mutation() click to toggle source
# File lib/mutest/mutator/node/op_asgn.rb, line 43
def emit_send_mutation
  emit(s(:send, left, operation, right))
  emit(s(:send, left.children.first, :"#{left.children.last}=", right))
end