Simplify boolean literal mutators

This commit is contained in:
Markus Schirp 2013-06-10 09:19:31 +02:00
parent ade67b304f
commit 8e2f244838

View file

@ -5,8 +5,15 @@ module Mutant
# Abstract mutator for boolean literals
class Boolean < self
handle :true, :false
private
MAP = {
:true => :false,
:false => :true
}.freeze
# Emit mutants
#
# @return [undefined]
@ -15,26 +22,10 @@ module Mutant
#
def dispatch
emit_nil
emit(s(self.class::INVERSE_TYPE))
end
# Mutator for true literals
class TrueLiteral < self
INVERSE_TYPE = :false
handle(:true)
end
# Mutator for false literals
class FalseLiteral < self
INVERSE_TYPE = :true
handle(:false)
emit(s(MAP.fetch(node.type)))
end
end # Boolean
end # Literal
end # Node
end # Mutatork