Class: Henitai::Mutant
- Inherits:
-
Object
- Object
- Henitai::Mutant
- Defined in:
- lib/henitai/mutant.rb,
lib/henitai/mutant/activator.rb
Overview
Represents a single syntactic mutation applied to a Subject.
A Mutant holds:
- the original and mutated AST nodes
- the operator that generated it
- the source location of the mutation
- its current status in the pipeline
Statuses follow the Stryker mutation-testing-report-schema vocabulary:
:pending, :killed, :survived, :timeout, :compile_error, :runtime_error,
:ignored, :no_coverage
Defined Under Namespace
Classes: Activator
Constant Summary collapse
- STATUSES =
Status-Vokabular folgt dem Stryker mutation-testing-report-schema. :equivalent ist ein Henitai-interner Status (wird im JSON als “Ignored” serialisiert, aber in der Scoring-Berechnung separat behandelt: confirmed equivalent mutants werden aus dem Nenner der MS-Berechnung herausgenommen).
%i[ pending killed survived timeout compile_error runtime_error ignored no_coverage equivalent ].freeze
Instance Attribute Summary collapse
-
#covered_by ⇒ Object
Returns the value of attribute covered_by.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#killing_test ⇒ Object
Returns the value of attribute killing_test.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#mutated_node ⇒ Object
readonly
Returns the value of attribute mutated_node.
-
#mutation_type ⇒ Object
readonly
Returns the value of attribute mutation_type.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#original_node ⇒ Object
readonly
Returns the value of attribute original_node.
-
#precomputed_activation_source ⇒ Object
readonly
Returns the value of attribute precomputed_activation_source.
-
#precomputed_stable_id ⇒ Object
readonly
Returns the value of attribute precomputed_stable_id.
-
#status ⇒ Object
Returns the value of attribute status.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#tests_completed ⇒ Object
Returns the value of attribute tests_completed.
Instance Method Summary collapse
- #equivalent? ⇒ Boolean
- #ignored? ⇒ Boolean
-
#initialize(subject:, operator:, nodes:, description:, location:, precomputed_stable_id: nil, precomputed_activation_source: nil) ⇒ Mutant
constructor
rubocop:disable Metrics/ParameterLists.
- #killed? ⇒ Boolean
- #pending? ⇒ Boolean
-
#stable_id ⇒ Object
rubocop:enable Metrics/ParameterLists.
- #survived? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(subject:, operator:, nodes:, description:, location:, precomputed_stable_id: nil, precomputed_activation_source: nil) ⇒ Mutant
rubocop:disable Metrics/ParameterLists
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/henitai/mutant.rb', line 48 def initialize(subject:, operator:, nodes:, description:, location:, precomputed_stable_id: nil, precomputed_activation_source: nil) @id = SecureRandom.uuid @subject = subject @operator = operator @original_node = nodes.fetch(:original) @mutated_node = nodes.fetch(:mutated) @description = description @location = location @precomputed_stable_id = precomputed_stable_id @precomputed_activation_source = precomputed_activation_source @status = :pending @killing_test = nil @duration = nil @covered_by = nil @tests_completed = nil end |
Instance Attribute Details
#covered_by ⇒ Object
Returns the value of attribute covered_by.
40 41 42 |
# File 'lib/henitai/mutant.rb', line 40 def covered_by @covered_by end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
37 38 39 |
# File 'lib/henitai/mutant.rb', line 37 def description @description end |
#duration ⇒ Object
Returns the value of attribute duration.
40 41 42 |
# File 'lib/henitai/mutant.rb', line 40 def duration @duration end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
37 38 39 |
# File 'lib/henitai/mutant.rb', line 37 def id @id end |
#killing_test ⇒ Object
Returns the value of attribute killing_test.
40 41 42 |
# File 'lib/henitai/mutant.rb', line 40 def killing_test @killing_test end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
37 38 39 |
# File 'lib/henitai/mutant.rb', line 37 def location @location end |
#mutated_node ⇒ Object (readonly)
Returns the value of attribute mutated_node.
37 38 39 |
# File 'lib/henitai/mutant.rb', line 37 def mutated_node @mutated_node end |
#mutation_type ⇒ Object (readonly)
Returns the value of attribute mutation_type.
37 38 39 |
# File 'lib/henitai/mutant.rb', line 37 def mutation_type @mutation_type end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
37 38 39 |
# File 'lib/henitai/mutant.rb', line 37 def operator @operator end |
#original_node ⇒ Object (readonly)
Returns the value of attribute original_node.
37 38 39 |
# File 'lib/henitai/mutant.rb', line 37 def original_node @original_node end |
#precomputed_activation_source ⇒ Object (readonly)
Returns the value of attribute precomputed_activation_source.
37 38 39 |
# File 'lib/henitai/mutant.rb', line 37 def precomputed_activation_source @precomputed_activation_source end |
#precomputed_stable_id ⇒ Object (readonly)
Returns the value of attribute precomputed_stable_id.
37 38 39 |
# File 'lib/henitai/mutant.rb', line 37 def precomputed_stable_id @precomputed_stable_id end |
#status ⇒ Object
Returns the value of attribute status.
40 41 42 |
# File 'lib/henitai/mutant.rb', line 40 def status @status end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
37 38 39 |
# File 'lib/henitai/mutant.rb', line 37 def subject @subject end |
#tests_completed ⇒ Object
Returns the value of attribute tests_completed.
40 41 42 |
# File 'lib/henitai/mutant.rb', line 40 def tests_completed @tests_completed end |
Instance Method Details
#equivalent? ⇒ Boolean
75 |
# File 'lib/henitai/mutant.rb', line 75 def equivalent? = @status == :equivalent |
#ignored? ⇒ Boolean
74 |
# File 'lib/henitai/mutant.rb', line 74 def ignored? = @status == :ignored |
#killed? ⇒ Boolean
71 |
# File 'lib/henitai/mutant.rb', line 71 def killed? = @status == :killed |
#pending? ⇒ Boolean
73 |
# File 'lib/henitai/mutant.rb', line 73 def pending? = @status == :pending |
#stable_id ⇒ Object
rubocop:enable Metrics/ParameterLists
67 68 69 |
# File 'lib/henitai/mutant.rb', line 67 def stable_id @stable_id ||= @precomputed_stable_id || MutantIdentity.stable_id(self) end |
#survived? ⇒ Boolean
72 |
# File 'lib/henitai/mutant.rb', line 72 def survived? = @status == :survived |
#to_s ⇒ Object
77 78 79 |
# File 'lib/henitai/mutant.rb', line 77 def to_s "#{operator}@#{location[:file]}:#{location[:start_line]} — #{description}" end |