free_mutant/lib/mutant/mutator/node/literal/regex.rb

36 lines
727 B
Ruby
Raw Normal View History

module Mutant
class Mutator
class Node
class Literal < self
# Mutator for regexp literals
class Regex < self
handle(:regexp)
2013-06-14 18:22:34 +02:00
EMPTY_STRING = ''.freeze
# No input can ever be matched with this
NULL_REGEXP_SOURCE = 'a\A'.freeze
children :source, :options
2013-06-14 18:22:34 +02:00
private
# Emit mutants
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_nil
2013-06-14 18:22:34 +02:00
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