class Mutest::Mutator::Node::Literal::Regex
Mutator
for regexp literals
Constants
- NULL_REGEXP_SOURCE
No input can ever be matched with this
Private Instance Methods
body()
click to toggle source
Children of regexp node which compose regular expression source
@return [Array<Parser::AST::Node>]
# File lib/mutest/mutator/node/literal/regex.rb, line 69 def body children.slice(0...-1) end
body_ast()
click to toggle source
AST
representation of regexp body
@return [Parser::AST::Node]
# File lib/mutest/mutator/node/literal/regex.rb, line 54 def body_ast AST::Regexp.to_ast(body_expression) end
body_expression()
click to toggle source
Expression
representation of regexp body
@return [Regexp::Expression::Base]
# File lib/mutest/mutator/node/literal/regex.rb, line 61 def body_expression AST::Regexp.parse(body.map(&:children).join) end
dispatch()
click to toggle source
Emit mutations
@return [undefined]
# File lib/mutest/mutator/node/literal/regex.rb, line 24 def dispatch mutate_body emit_singletons unless parent_node children.each_with_index do |child, index| mutate_child(index) unless n_str?(child) end emit_type(options) emit_type(s(:str, NULL_REGEXP_SOURCE), options) end
mutate_body()
click to toggle source
Mutate regexp body
@note will only mutate parts of regexp body if the body is composed of only strings. Regular expressions with interpolation are skipped
@return [undefined]
# File lib/mutest/mutator/node/literal/regex.rb, line 41 def mutate_body return unless body.all?(&method(:n_str?)) return unless AST::Regexp.supported?(body_expression) mutate(body_ast).each do |mutation| source = AST::Regexp.to_expression(mutation).to_s emit_type(s(:str, source), options) end end
options()
click to toggle source
Original regexp options
@return [Parser::AST::Node]
# File lib/mutest/mutator/node/literal/regex.rb, line 17 def options children.last end