Class: Necropsy::Bench::SafetyMutationHarness

Inherits:
Object
  • Object
show all
Defined in:
lib/necropsy/bench/safety_mutation_harness.rb

Defined Under Namespace

Classes: Result

Constant Summary collapse

HEALTH_RANK =
{ invalid: 0, degraded: 1, complete: 2 }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(baseline:) ⇒ SafetyMutationHarness

Returns a new instance of SafetyMutationHarness.



9
10
11
# File 'lib/necropsy/bench/safety_mutation_harness.rb', line 9

def initialize(baseline:)
  @baseline = baseline
end

Instance Method Details

#assert_all_detected!(mutants) ⇒ Object

Raises:



20
21
22
23
24
25
26
# File 'lib/necropsy/bench/safety_mutation_harness.rb', line 20

def assert_all_detected!(mutants)
  results = evaluate(mutants)
  survivors = results.values.reject(&:detected).map(&:name)
  raise Error, "Safety mutations survived: #{survivors.join(', ')}" if survivors.any?

  results
end

#evaluate(mutants) ⇒ Object



13
14
15
16
17
18
# File 'lib/necropsy/bench/safety_mutation_harness.rb', line 13

def evaluate(mutants)
  Hash(mutants).sort.to_h do |name, report|
    violations = violations_for(report)
    [name.to_s, Result.new(name: name.to_s, detected: violations.any?, violations: violations.freeze)]
  end
end