free_mutant/lib/mutant/mutator/literal/regex.rb
2012-08-09 23:07:22 +02:00

41 lines
890 B
Ruby

module Mutant
class Mutator
class Literal < self
# Mutator for regexp literal AST nodes
class Regex < self
handle(Rubinius::AST::RegexLiteral)
private
# Emit mutants
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_nil
emit_self('') # match all
emit_self('a\A') # match nothing
emit_new { new_self(Random.hex_string) }
end
# Return new Rubinius::AST::Regex
#
# @param [String] source
#
# @param [Integer] options
# options of regexp, defaults to mutation subject node options
#
# @return [undefined]
#
# @api private
#
def new_self(source,options=nil)
super(source,options || node.options)
end
end
end
end
end