Class: Evilution::Mutator::Operator::ConditionalFlip

Inherits:
Base
  • Object
show all
Defined in:
lib/evilution/mutator/operator/conditional_flip.rb

Instance Attribute Summary

Attributes inherited from Base

#mutations

Instance Method Summary collapse

Methods inherited from Base

#call, clear_parse_cache!, #initialize, operator_name, parsed_tree_for

Constructor Details

This class inherits a constructor from Evilution::Mutator::Base

Instance Method Details

#visit_if_node(node) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/evilution/mutator/operator/conditional_flip.rb', line 6

def visit_if_node(node)
  if node.if_keyword == "if" && !elsif?(node)
    add_mutation(
      offset: node.if_keyword_loc.start_offset,
      length: node.if_keyword_loc.length,
      replacement: "unless",
      node: node
    )
  end

  super
end

#visit_unless_node(node) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/evilution/mutator/operator/conditional_flip.rb', line 19

def visit_unless_node(node)
  add_mutation(
    offset: node.keyword_loc.start_offset,
    length: node.keyword_loc.length,
    replacement: "if",
    node: node
  )

  super
end