free_mutant/lib/mutant/mutator/node/literal/array.rb

45 lines
907 B
Ruby
Raw Normal View History

module Mutant
class Mutator
class Node
class Literal < self
# Mutator for array literals
class Array < self
handle(:array)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
2012-12-06 16:30:57 -05:00
emit_nil
2013-06-12 13:07:42 -04:00
emit_self
2013-06-15 11:16:34 -04:00
mutate_body
end
# Mutate body
#
# @return [undefined]
#
# @api private
#
def mutate_body
2013-06-12 13:07:42 -04:00
children.each_index do |index|
dup_children = children.dup
dup_children.delete_at(index)
emit_self(*dup_children)
mutate_child(index)
end
emit_self(s(:nil), *children)
end
end # Array
2013-06-12 13:07:42 -04:00
end # Literal
end # Node
end # Mutator
end # Mutant