Use child nameing in assignment mutator

This commit is contained in:
Markus Schirp 2013-06-21 15:26:41 +02:00
parent 1f447dc456
commit 667e79316d

View file

@ -6,8 +6,8 @@ module Mutant
# Mutator for variable assignment # Mutator for variable assignment
class Variable < self class Variable < self
NAME_INDEX = 0
VALUE_INDEX = 1 children :name, :value
MAP = IceNine.deep_freeze( MAP = IceNine.deep_freeze(
:gvasgn => '$', :gvasgn => '$',
@ -27,8 +27,8 @@ module Mutant
# @api private # @api private
# #
def dispatch def dispatch
emit_name_mutations mutate_name
mutate_child(VALUE_INDEX) emit_value_mutations
end end
# Emit name mutations # Emit name mutations
@ -37,10 +37,10 @@ module Mutant
# #
# @api private # @api private
# #
def emit_name_mutations def mutate_name
name = children[NAME_INDEX] prefix = MAP.fetch(node.type)
Mutator::Util::Symbol.each(name) do |name| Mutator::Util::Symbol.each(name) do |name|
emit_child_update(NAME_INDEX, "#{MAP.fetch(node.type)}#{name}") emit_name("#{prefix}#{name}")
end end
end end