free_mutant/lib/mutant/mutator/node/literal/regex.rb
Dan Kubb 7293386c26 Add magic encoding header to all ruby files
* rubocop still warns about this on ruby 1.9.3, so it was fixed so
  it produces less output on travis.
2013-07-28 16:03:06 -07:00

46 lines
994 B
Ruby

# encoding: utf-8
module Mutant
class Mutator
class Node
class Literal < self
# Mutator for regexp literals
class Regex < self
handle(:regexp)
# No input can ever be matched with this
NULL_REGEXP_SOURCE = 'a\A'.freeze
private
# Return options
#
# @return [Parser::AST::Node]
#
# @api private
#
def options
children.last
end
# Emit mutants
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_nil
children.each_with_index do |child, index|
mutate_child(index) unless child.type == :str
end
emit_self(s(:str, EMPTY_STRING), options)
emit_self(s(:str, NULL_REGEXP_SOURCE), options)
end
end # Regex
end # Literal
end # Node
end # Mutator
end # Mutant