free_mutant/lib/mutant/mutator/node/resbody.rb
Markus Schirp 3ae85ea0f9 Refactor and consolidate node type checks in to private methods
* Before Symbol#==, Symbol#eql?, and Symbol#equal? where used
  inconsistently
* Lots of redundant foo.type.equal?(:symbol)
2014-06-10 02:06:00 +00:00

44 lines
888 B
Ruby

# encoding: UTF-8
module Mutant
class Mutator
class Node
# Mutator for resbody nodes
class Resbody < self
handle(:resbody)
children :captures, :assignment, :body
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_assignment(nil)
emit_body_mutations if body
mutate_captures
end
# Mutate captures
#
# @return [undefined]
#
# @api private
#
def mutate_captures
return unless captures
Util::Array::Element.each(captures.children, self) do |matchers|
next if matchers.any?(&method(:n_nil?))
emit_captures(s(:array, *matchers))
end
end
end # Resbody
end # Node
end # Mutator
end # Mutant