2013-07-28 19:03:06 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2013-06-04 17:44:17 -04:00
|
|
|
module Mutant
|
|
|
|
class Mutator
|
|
|
|
class Node
|
2013-06-15 11:13:01 -04:00
|
|
|
# Mutator for arguments node
|
2013-06-04 17:44:17 -04:00
|
|
|
class Arguments < self
|
|
|
|
|
|
|
|
handle(:args)
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Perform dispatch
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def dispatch
|
|
|
|
emit_children_mutations
|
2013-06-14 14:19:53 -04:00
|
|
|
emit_mlhs_expansion
|
|
|
|
end
|
|
|
|
|
|
|
|
# Emit mlhs expansions
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def emit_mlhs_expansion
|
2013-06-15 11:16:34 -04:00
|
|
|
mlhs_childs_with_index.each do |child, index|
|
2013-06-14 14:19:53 -04:00
|
|
|
dup_children = children.dup
|
|
|
|
dup_children.delete_at(index)
|
|
|
|
dup_children.insert(index, *child.children)
|
|
|
|
emit_self(*dup_children)
|
|
|
|
end
|
2013-06-04 17:44:17 -04:00
|
|
|
end
|
|
|
|
|
2013-06-15 11:16:34 -04:00
|
|
|
# Return mlhs childs
|
|
|
|
#
|
|
|
|
# @return [Enumerable<Parser::AST::Node, Fixnum>]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def mlhs_childs_with_index
|
|
|
|
children.each_with_index.select do |child, index|
|
|
|
|
child.type == :mlhs
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-04 17:44:17 -04:00
|
|
|
end # Arguments
|
|
|
|
end # Node
|
|
|
|
end # Mutator
|
|
|
|
end # Mutant
|