From 3ae411bb7f1cdf50ab676c42a7905c7007ff5a45 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Sat, 22 Jun 2013 00:23:03 +0200 Subject: [PATCH] Fix math in reporters --- lib/mutant/reporter/cli/printer/config.rb | 3 ++- lib/mutant/reporter/cli/printer/subject.rb | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/mutant/reporter/cli/printer/config.rb b/lib/mutant/reporter/cli/printer/config.rb index 5eed02a2..9fbd6b35 100644 --- a/lib/mutant/reporter/cli/printer/config.rb +++ b/lib/mutant/reporter/cli/printer/config.rb @@ -151,7 +151,8 @@ module Mutant # @api private # def coverage - amount_kills / amount_mutations * 100 + return 0 if amount_mutations.zero? + Rational(amount_kills, amount_mutations) * 100 end # Return amount of alive mutations diff --git a/lib/mutant/reporter/cli/printer/subject.rb b/lib/mutant/reporter/cli/printer/subject.rb index 00720feb..d739d353 100644 --- a/lib/mutant/reporter/cli/printer/subject.rb +++ b/lib/mutant/reporter/cli/printer/subject.rb @@ -64,6 +64,7 @@ module Mutant # @api private # def print_stats + p coverage status('(%02d/%02d) %3d%% - %0.02fs', amount_kills, amount_mutations, coverage, time) end @@ -116,7 +117,8 @@ module Mutant # @api private # def coverage - coverage = amount_kills.to_f / amount_mutations * 100 + return 0 if amount_mutations.zero? + Rational(amount_kills, amount_mutations) * 100 end # Detailed subject printer