free_mutant/lib/mutant/mutator/node/begin.rb
Markus Schirp 212831b107 Refactor mutation emitter to support unparser 0.1.0
Cleans up the body mutator and fix blind spot.
2013-09-06 01:43:17 +02:00

51 lines
982 B
Ruby

# encoding: utf-8
module Mutant
class Mutator
class Node
# Mutator for begin nodes
class Begin < self
handle(:begin)
private
# Emit mutants
#
# @return [undefined]
#
# @api private
#
def dispatch
Util::Array.each(children, self) do |children|
emit_child_subset(children)
end
children.each_with_index do |child, index|
mutate_child(index)
emit(child)
end
end
# Emit child subset
#
# @param [Array<Parser::AST::Node>] nodes
#
# @return [undefined]
#
# @api private
#
def emit_child_subset(children)
case children.length
when 0
when 1
emit(children.first)
else
emit_self(*children)
end
end
end # Block
end # Node
end # Mutator
end # Mutant