free_mutant/lib/mutant/mutator/node/literal/hash.rb

54 lines
1 KiB
Ruby
Raw Normal View History

module Mutant
class Mutator
class Node
class Literal
# Mutator for hash literals
class Hash < self
handle(:hash)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_nil
2013-06-12 19:23:48 +02:00
emit_self
children.each_index do |index|
mutate_child(index)
dup_children = children.dup
dup_children.delete_at(index)
emit_self(*dup_children)
end
2012-12-06 22:30:57 +01:00
end
2013-06-12 19:23:48 +02:00
class Pair < Node
2013-06-12 19:23:48 +02:00
handle(:pair)
2013-06-12 19:23:48 +02:00
KEY_INDEX, VALUE_INDEX = 0, 1
2013-06-12 19:23:48 +02:00
private
2013-06-12 19:23:48 +02:00
# Perform dispatch
#
# @return [undefined]
#
# @api private
#
def dispatch
mutate_child(KEY_INDEX)
mutate_child(VALUE_INDEX)
end
2013-06-12 19:23:48 +02:00
end # Pair
end # Hash
end # Literal
end # Node
end # Mutator
end # Mutant