free_mutant/lib/mutant/mutator/node/literal/array.rb
Markus Schirp 017ccc1044 Add expression => self mutation
Also reorganizes parts of meta to align filenames to node name better.

Closes #191
2014-06-05 17:48:39 +00:00

48 lines
971 B
Ruby

# encoding: utf-8
module Mutant
class Mutator
class Node
class Literal < self
# Mutator for array literals
class Array < self
handle(:array)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_singletons
emit_type
mutate_body
if children.one?
emit(children.first)
end
end
# Mutate body
#
# @return [undefined]
#
# @api private
#
def mutate_body
children.each_index do |index|
dup_children = children.dup
dup_children.delete_at(index)
emit_type(*dup_children)
mutate_child(index)
end
end
end # Array
end # Literal
end # Node
end # Mutator
end # Mutant