Class: Evilution::Mutator::Operator::MultipleAssignment

Inherits:
Base
  • Object
show all
Defined in:
lib/evilution/mutator/operator/multiple_assignment.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_multi_write_node(node) ⇒ Object



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

def visit_multi_write_node(node)
  lefts = node.lefts
  values = node.value.is_a?(Prism::ArrayNode) ? node.value.elements : nil

  if values && lefts.length == values.length && lefts.length >= 2 && node.rest.nil?
    mutate_target_removal(node, lefts, values)
    mutate_swap(node, lefts, values) if lefts.length == 2
  end

  super
end