Move reporter stats into own file and cleanup 18 spec
This commit is contained in:
parent
217aa9183c
commit
e0df644a7a
5 changed files with 76 additions and 38 deletions
|
@ -96,5 +96,6 @@ require 'mutant/cli'
|
|||
require 'mutant/color'
|
||||
require 'mutant/differ'
|
||||
require 'mutant/reporter'
|
||||
require 'mutant/reporter/stats'
|
||||
require 'mutant/reporter/null'
|
||||
require 'mutant/reporter/cli'
|
||||
|
|
|
@ -23,6 +23,16 @@ module Mutant
|
|||
#
|
||||
abstract_method :mutation
|
||||
|
||||
# Report notice
|
||||
#
|
||||
# @param [String] notice
|
||||
#
|
||||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
abstract_method :notice
|
||||
|
||||
# Report killer
|
||||
#
|
||||
# @param [Killer] killer
|
||||
|
|
|
@ -4,36 +4,6 @@ module Mutant
|
|||
class CLI < self
|
||||
include Equalizer.new(:io)
|
||||
|
||||
class Stats
|
||||
attr_reader :subject
|
||||
attr_reader :mutation
|
||||
attr_reader :kill
|
||||
attr_reader :time
|
||||
|
||||
def initialize
|
||||
@start = Time.now
|
||||
@subject = @mutation = @kill = @time = 0
|
||||
end
|
||||
|
||||
def runtime
|
||||
Time.now - @start
|
||||
end
|
||||
|
||||
def subject
|
||||
@subject +=1
|
||||
end
|
||||
|
||||
def alive
|
||||
@mutation - @kill
|
||||
end
|
||||
|
||||
def killer(killer)
|
||||
@mutation +=1
|
||||
@kill +=1 unless killer.fail?
|
||||
@time += killer.runtime
|
||||
end
|
||||
end
|
||||
|
||||
# Reporter subject
|
||||
#
|
||||
# @param [Subject] subject
|
||||
|
|
64
lib/mutant/reporter/stats.rb
Normal file
64
lib/mutant/reporter/stats.rb
Normal file
|
@ -0,0 +1,64 @@
|
|||
module Mutant
|
||||
class Reporter
|
||||
|
||||
# Stats gathered while reporter is running
|
||||
class Stats
|
||||
|
||||
# Return subject count
|
||||
#
|
||||
# @return [Fixnum]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :subject
|
||||
|
||||
# Return mutation count
|
||||
#
|
||||
# @return [Fixnum]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :mutation
|
||||
|
||||
# Return kill count
|
||||
#
|
||||
# @return [Fixnum]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :kill
|
||||
|
||||
# Return mutation runtime
|
||||
#
|
||||
# @return [Float]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :time
|
||||
|
||||
def initialize
|
||||
@start = Time.now
|
||||
@subject = @mutation = @kill = @time = 0
|
||||
end
|
||||
|
||||
def runtime
|
||||
Time.now - @start
|
||||
end
|
||||
|
||||
def subject
|
||||
@subject +=1
|
||||
end
|
||||
|
||||
def alive
|
||||
@mutation - @kill
|
||||
end
|
||||
|
||||
def killer(killer)
|
||||
@mutation +=1
|
||||
@kill +=1 unless killer.fail?
|
||||
@time += killer.runtime
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -9,14 +9,7 @@ describe Mutant::Mutator, 'if statement' do
|
|||
# mutations of condition
|
||||
mutants << 'if condition; true; else false; end'
|
||||
|
||||
# Invert condition
|
||||
if Mutant::Helper.on_18?
|
||||
# Explicitly define ast as 18-mode does swap if and else on parsing when negation condition is
|
||||
# present in condition.
|
||||
mutants << [:if, [:not, [:call, [:self], :condition, [:arglist]]], [:true], [:false]]
|
||||
else
|
||||
mutants << 'if !self.condition; true; else false; end'
|
||||
end
|
||||
mutants << 'if !self.condition; true; else false; end'
|
||||
|
||||
# Deleted else branch
|
||||
mutants << 'if self.condition; true end'
|
||||
|
|
Loading…
Add table
Reference in a new issue