2013-07-28 19:03:06 -04:00
|
|
|
# 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
|
2013-06-24 16:10:40 -04:00
|
|
|
Util::Array.each(children, self) do |children|
|
2013-09-05 19:43:17 -04:00
|
|
|
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
|
2013-06-24 16:10:40 -04:00
|
|
|
end
|
|
|
|
|
2013-09-05 19:43:17 -04:00
|
|
|
# Emit child subset
|
2013-06-24 16:10:40 -04:00
|
|
|
#
|
2013-09-05 19:43:17 -04:00
|
|
|
# @param [Array<Parser::AST::Node>] nodes
|
2013-06-24 16:10:40 -04:00
|
|
|
#
|
2013-09-05 19:43:17 -04:00
|
|
|
# @return [undefined]
|
2013-06-24 16:10:40 -04:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-09-05 19:43:17 -04:00
|
|
|
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
|