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

44 lines
879 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 12:22:34 -04:00
EMPTY_STRING = ''.freeze
# No input can ever be matched with this
NULL_REGEXP_SOURCE = 'a\A'.freeze
SOURCE_INDEX, OPTIONS_INDEX = 0, 1
private
# Emit mutants
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_nil
2013-06-14 12:22:34 -04:00
emit_self(s(:str, EMPTY_STRING), options)
emit_self(s(:str, NULL_REGEXP_SOURCE), options)
end
2013-06-14 12:22:34 -04:00
def options
children[OPTIONS_INDEX]
end
def source
children[SOURCE_INDEX]
end
end # Regex
end # Literal
end # Node
end # Mutator
end # Mutant