Class: Mutant::Runner::Config

Inherits:
Mutant::Runner show all
Defined in:
lib/mutant/runner/config.rb

Overview

Runner for object config

Constant Summary collapse

COVERAGE_PRECISION =
1

Constants inherited from Mutant::Runner

REGISTRY

Instance Attribute Summary collapse

Attributes inherited from Mutant::Runner

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mutant::Runner

#initialize, #reporter, #runtime, #stop?

Constructor Details

This class inherits a constructor from Mutant::Runner

Instance Attribute Details

#subjectsEnumerable<Runner::Subject> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return subject runners

Returns:



30
31
32
# File 'lib/mutant/runner/config.rb', line 30

def subjects
  @subjects
end

Class Method Details

.run(config) ⇒ Runner

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run runner for object

Parameters:

  • config (Config)
  • object (Object)

Returns:



19
20
21
22
# File 'lib/mutant/runner/config.rb', line 19

def self.run(config)
  handler = lookup(config.class)
  handler.new(config)
end

Instance Method Details

#amount_killsFixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return amount of kills

Returns:

  • (Fixnum)


88
89
90
# File 'lib/mutant/runner/config.rb', line 88

def amount_kills
  mutations.select(&:success?).length
end

#amount_mutationsFixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return amount of mutations

Returns:

  • (Fixnum)


110
111
112
# File 'lib/mutant/runner/config.rb', line 110

def amount_mutations
  mutations.length
end

#coverageFloat

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return coverage

Returns:

  • (Float)


76
77
78
79
# File 'lib/mutant/runner/config.rb', line 76

def coverage
  return 0.0 if amount_mutations.zero?
  Rational(amount_kills, amount_mutations) * 100
end

#failed_subjectsEnumerable<Subject>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return failed subjects

Returns:



38
39
40
# File 'lib/mutant/runner/config.rb', line 38

def failed_subjects
  subjects.reject(&:success?)
end

#mutationsArray<Mutation>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return mutations

Returns:



99
100
101
# File 'lib/mutant/runner/config.rb', line 99

def mutations
  subjects.map(&:mutations).flatten
end

#strategyStrategy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return strategy

Returns:



66
67
68
# File 'lib/mutant/runner/config.rb', line 66

def strategy
  config.strategy
end

#success?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test if run was successful

Returns:

  • (true)

    if run was successful

  • (false)

    otherwise



55
56
57
# File 'lib/mutant/runner/config.rb', line 55

def success?
  coverage.round(COVERAGE_PRECISION) == config.expected_coverage.round(COVERAGE_PRECISION)
end