Use child nameing in assignment mutator
This commit is contained in:
parent
1f447dc456
commit
667e79316d
1 changed files with 7 additions and 7 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue