2012-12-06 15:30:28 -05:00
|
|
|
module Mutant
|
|
|
|
class Mutator
|
|
|
|
class Node
|
|
|
|
class Literal < self
|
|
|
|
# Mutator for array literals
|
|
|
|
class Array < self
|
|
|
|
|
2013-06-04 04:25:13 -04:00
|
|
|
handle(:array)
|
2012-12-06 15:30:28 -05:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Emit mutations
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def dispatch
|
2012-12-06 16:30:57 -05:00
|
|
|
emit_nil
|
2013-06-12 13:07:42 -04:00
|
|
|
emit_self
|
2013-06-15 11:16:34 -04:00
|
|
|
mutate_body
|
|
|
|
end
|
|
|
|
|
|
|
|
# Mutate body
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def mutate_body
|
2013-06-12 13:07:42 -04:00
|
|
|
children.each_index do |index|
|
|
|
|
dup_children = children.dup
|
|
|
|
dup_children.delete_at(index)
|
|
|
|
emit_self(*dup_children)
|
|
|
|
mutate_child(index)
|
|
|
|
end
|
|
|
|
emit_self(s(:nil), *children)
|
2012-12-06 15:30:28 -05:00
|
|
|
end
|
2013-06-04 04:25:13 -04:00
|
|
|
|
|
|
|
end # Array
|
2013-06-12 13:07:42 -04:00
|
|
|
end # Literal
|
2013-06-04 04:25:13 -04:00
|
|
|
end # Node
|
|
|
|
end # Mutator
|
|
|
|
end # Mutant
|