From 79e8cd2b9c25b73d07af5f9dd47f8b88d8d1ac38 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Fri, 21 Jun 2013 15:06:39 +0200 Subject: [PATCH] Use child nameing in while mutator and fix edge cases --- lib/mutant/mutator/node/while.rb | 6 ++++-- spec/unit/mutant/mutator/node/while/mutation_spec.rb | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/mutant/mutator/node/while.rb b/lib/mutant/mutator/node/while.rb index f57a8e63..1b79845f 100644 --- a/lib/mutant/mutator/node/while.rb +++ b/lib/mutant/mutator/node/while.rb @@ -9,6 +9,8 @@ module Mutant CONDITION_INDEX, BODY_INDEX = 0, 1 + children :condition, :body + private # Emit mutations @@ -18,8 +20,8 @@ module Mutant # @api private # def dispatch - mutate_child(CONDITION_INDEX) - mutate_child(BODY_INDEX) + emit_condition_mutations + emit_body_mutations end end # While diff --git a/spec/unit/mutant/mutator/node/while/mutation_spec.rb b/spec/unit/mutant/mutator/node/while/mutation_spec.rb index 065f8e56..e4d9ddd7 100644 --- a/spec/unit/mutant/mutator/node/while/mutation_spec.rb +++ b/spec/unit/mutant/mutator/node/while/mutation_spec.rb @@ -9,9 +9,9 @@ describe Mutant::Mutator::Node::While do mutations = [] mutations << 'while true; bar; end' mutations << 'while true; foo; end' - mutations << 'while true; nil; end' + mutations << 'while true; end' mutations << 'while false; foo; bar; end' - mutations << 'while nil; foo; bar; end' + mutations << 'while nil; foo; bar; end' end it_should_behave_like 'a mutator'