Class: ActiveMutator::Fingerprint
- Inherits:
-
Data
- Object
- Data
- ActiveMutator::Fingerprint
- Defined in:
- lib/active_mutator/fingerprint.rb
Overview
Line-number-independent identity for a mutant, used by the acceptance
ledger. ordinal disambiguates byte-identical mutants within one subject
(e.g. the two > in a > 0 && b > 0) by source order — without it,
accepting one would silently accept both.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#ordinal ⇒ Object
readonly
Returns the value of attribute ordinal.
-
#original_snippet ⇒ Object
readonly
Returns the value of attribute original_snippet.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Class Method Summary collapse
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description
6 7 8 |
# File 'lib/active_mutator/fingerprint.rb', line 6 def description @description end |
#file ⇒ Object (readonly)
Returns the value of attribute file
6 7 8 |
# File 'lib/active_mutator/fingerprint.rb', line 6 def file @file end |
#ordinal ⇒ Object (readonly)
Returns the value of attribute ordinal
6 7 8 |
# File 'lib/active_mutator/fingerprint.rb', line 6 def ordinal @ordinal end |
#original_snippet ⇒ Object (readonly)
Returns the value of attribute original_snippet
6 7 8 |
# File 'lib/active_mutator/fingerprint.rb', line 6 def original_snippet @original_snippet end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject
6 7 8 |
# File 'lib/active_mutator/fingerprint.rb', line 6 def subject @subject end |
Class Method Details
.for_mutations(mutations, root:) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/active_mutator/fingerprint.rb', line 7 def self.for_mutations(mutations, root:) counters = Hash.new(0) mutations.sort_by { |m| [m.subject.name, m.edit.range.begin] }.to_h do |m| key = [m.subject.name, m.description, m.original_snippet] ordinal = counters[key] counters[key] += 1 [m, new(file: m.subject.file.delete_prefix("#{root}/"), subject: m.subject.name, description: m.description, original_snippet: m.original_snippet, ordinal: ordinal)] end end |