class Mutest::Mutator::Node::Index

Base mutator for index operations

Constants

NO_VALUE_RANGE
SEND_REPLACEMENTS

Private Instance Methods

dispatch() click to toggle source

Emit mutations

@return [undefined]

# File lib/mutest/mutator/node/index.rb, line 20
def dispatch
  emit_singletons
  emit_receiver_mutations { |node| !n_nil?(node) }
  emit(receiver)
  emit_send_forms
  emit_drop_mutation
  mutate_indices
end
emit_drop_mutation() click to toggle source

Emit mutation `foo` -> `foo.drop(n)`

@return [undefined]

# File lib/mutest/mutator/node/index.rb, line 43
def emit_drop_mutation
  return unless indices.one? && n_irange?(Mutest::Util.one(indices))

  start, ending = *indices.first

  return unless ending.eql?(s(:int, -1))

  emit(s(:send, receiver, :drop, start))
end
emit_send_forms() click to toggle source

Emit send forms

@return [undefined]

# File lib/mutest/mutator/node/index.rb, line 32
def emit_send_forms
  return if asgn_left?

  SEND_REPLACEMENTS.each do |selector|
    emit(s(:send, receiver, selector, *indices))
  end
end
indices() click to toggle source

The index nodes

@return [Enumerable<Parser::AST::Node>]

# File lib/mutest/mutator/node/index.rb, line 67
def indices
  children[index_range]
end
mutate_indices() click to toggle source

Mutate indices

@return [undefined]

# File lib/mutest/mutator/node/index.rb, line 56
def mutate_indices
  children_indices(index_range).each do |index|
    emit_propagation(children.fetch(index)) unless asgn_left?
    delete_child(index)
    mutate_child(index)
  end
end