class Mutest::Mutator::Node::When

Mutator for when nodes

Private Instance Methods

body() click to toggle source

Body node

@return [Parser::AST::Node]

if body is present

@return [nil]

otherwise
# File lib/mutest/mutator/node/when.rb, line 47
def body
  children.fetch(body_index)
end
body_index() click to toggle source

Index of body node

@return [Integer]

# File lib/mutest/mutator/node/when.rb, line 54
def body_index
  children.length - 1
end
dispatch() click to toggle source

Emit mutations

@return [undefined]

# File lib/mutest/mutator/node/when.rb, line 13
def dispatch
  if body
    mutate_body
  else
    emit_child_update(body_index, N_RAISE)
  end
  mutate_conditions
end
mutate_body() click to toggle source

Emit body mutations

@return [undefined]

# File lib/mutest/mutator/node/when.rb, line 36
def mutate_body
  mutate_child(body_index)
end
mutate_conditions() click to toggle source

Emit condition mutations

@return [undefined]

# File lib/mutest/mutator/node/when.rb, line 25
def mutate_conditions
  conditions = children.length - 1
  children[0..-2].each_index do |index|
    delete_child(index) if conditions > 1
    mutate_child(index)
  end
end