From 8e2f244838e46b64822612386d6144073b202e5b Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Mon, 10 Jun 2013 09:19:31 +0200 Subject: [PATCH] Simplify boolean literal mutators --- lib/mutant/mutator/node/literal/boolean.rb | 25 +++++++--------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/lib/mutant/mutator/node/literal/boolean.rb b/lib/mutant/mutator/node/literal/boolean.rb index a9463a8f..1baa8396 100644 --- a/lib/mutant/mutator/node/literal/boolean.rb +++ b/lib/mutant/mutator/node/literal/boolean.rb @@ -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