free_mutant/lib/mutant/mutator/node/begin.rb

52 lines
982 B
Ruby
Raw Normal View History

# encoding: utf-8
2013-06-04 16:16:04 -04:00
module Mutant
class Mutator
class Node
2013-06-21 09:05:27 -04:00
2013-06-04 16:16:04 -04:00
# 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)
2013-06-21 09:05:27 -04:00
end
2013-07-25 14:23:30 -04:00
children.each_with_index do |child, index|
mutate_child(index)
2013-06-21 09:05:27 -04:00
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
2013-06-04 16:16:04 -04:00
end
end # Block
end # Node
end # Mutator
end # Mutant