Class: Henitai::Mutant
- Inherits:
-
Object
- Object
- Henitai::Mutant
- Includes:
- UnparseHelper
- Defined in:
- lib/henitai/mutant.rb,
lib/henitai/mutant/activator.rb,
lib/henitai/mutant/parameter_source.rb,
sig/henitai.rbs
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, ParameterSource
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 ⇒ Array[String]?
Returns the value of attribute covered_by.
-
#description ⇒ String
readonly
Returns the value of attribute description.
-
#duration ⇒ Float?
Returns the value of attribute duration.
-
#from_cache ⇒ Boolean
Returns the value of attribute from_cache.
-
#id ⇒ String
readonly
Returns the value of attribute id.
-
#ignore_reason ⇒ String?
Returns the value of attribute ignore_reason.
-
#killing_test ⇒ String?
Returns the value of attribute killing_test.
-
#location ⇒ Hash[Symbol, untyped]
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 ⇒ String
readonly
Returns the value of attribute operator.
-
#original_node ⇒ Object
readonly
Returns the value of attribute original_node.
-
#precomputed_activation_source ⇒ String?
readonly
Returns the value of attribute precomputed_activation_source.
-
#precomputed_stable_id ⇒ String?
readonly
Returns the value of attribute precomputed_stable_id.
-
#status ⇒ Symbol
Returns the value of attribute status.
-
#subject ⇒ Subject
readonly
Returns the value of attribute subject.
-
#tests_completed ⇒ Integer?
Returns the value of attribute tests_completed.
Instance Method Summary collapse
- #equivalent? ⇒ Boolean
- #from_cache? ⇒ 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
-
#mutated_source ⇒ String
Unparsing is expensive and the value is needed by both the JSON and the terminal reporter — compute once per mutant.
- #pending? ⇒ Boolean
-
#stable_id ⇒ String
rubocop:enable Metrics/ParameterLists.
- #survived? ⇒ Boolean
- #to_s ⇒ String
Methods included from UnparseHelper
#fallback_source, #safe_unparse
Constructor Details
#initialize(subject:, operator:, nodes:, description:, location:, precomputed_stable_id: nil, precomputed_activation_source: nil) ⇒ Mutant
rubocop:disable Metrics/ParameterLists
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/henitai/mutant.rb', line 53 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 = @duration = @covered_by = @tests_completed = @ignore_reason = nil @from_cache = false end |
Instance Attribute Details
#covered_by ⇒ Array[String]?
Returns the value of attribute covered_by.
44 45 46 |
# File 'lib/henitai/mutant.rb', line 44 def covered_by @covered_by end |
#description ⇒ String (readonly)
Returns the value of attribute description.
41 42 43 |
# File 'lib/henitai/mutant.rb', line 41 def description @description end |
#duration ⇒ Float?
Returns the value of attribute duration.
44 45 46 |
# File 'lib/henitai/mutant.rb', line 44 def duration @duration end |
#from_cache ⇒ Boolean
Returns the value of attribute from_cache.
44 45 46 |
# File 'lib/henitai/mutant.rb', line 44 def from_cache @from_cache end |
#id ⇒ String (readonly)
Returns the value of attribute id.
41 42 43 |
# File 'lib/henitai/mutant.rb', line 41 def id @id end |
#ignore_reason ⇒ String?
Returns the value of attribute ignore_reason.
44 45 46 |
# File 'lib/henitai/mutant.rb', line 44 def ignore_reason @ignore_reason end |
#killing_test ⇒ String?
Returns the value of attribute killing_test.
44 45 46 |
# File 'lib/henitai/mutant.rb', line 44 def killing_test @killing_test end |
#location ⇒ Hash[Symbol, untyped] (readonly)
Returns the value of attribute location.
41 42 43 |
# File 'lib/henitai/mutant.rb', line 41 def location @location end |
#mutated_node ⇒ Object (readonly)
Returns the value of attribute mutated_node.
41 42 43 |
# File 'lib/henitai/mutant.rb', line 41 def mutated_node @mutated_node end |
#mutation_type ⇒ Object (readonly)
Returns the value of attribute mutation_type.
41 42 43 |
# File 'lib/henitai/mutant.rb', line 41 def mutation_type @mutation_type end |
#operator ⇒ String (readonly)
Returns the value of attribute operator.
41 42 43 |
# File 'lib/henitai/mutant.rb', line 41 def operator @operator end |
#original_node ⇒ Object (readonly)
Returns the value of attribute original_node.
41 42 43 |
# File 'lib/henitai/mutant.rb', line 41 def original_node @original_node end |
#precomputed_activation_source ⇒ String? (readonly)
Returns the value of attribute precomputed_activation_source.
41 42 43 |
# File 'lib/henitai/mutant.rb', line 41 def precomputed_activation_source @precomputed_activation_source end |
#precomputed_stable_id ⇒ String? (readonly)
Returns the value of attribute precomputed_stable_id.
41 42 43 |
# File 'lib/henitai/mutant.rb', line 41 def precomputed_stable_id @precomputed_stable_id end |
#status ⇒ Symbol
Returns the value of attribute status.
44 45 46 |
# File 'lib/henitai/mutant.rb', line 44 def status @status end |
#subject ⇒ Subject (readonly)
Returns the value of attribute subject.
41 42 43 |
# File 'lib/henitai/mutant.rb', line 41 def subject @subject end |
#tests_completed ⇒ Integer?
Returns the value of attribute tests_completed.
44 45 46 |
# File 'lib/henitai/mutant.rb', line 44 def tests_completed @tests_completed end |
Instance Method Details
#equivalent? ⇒ Boolean
83 |
# File 'lib/henitai/mutant.rb', line 83 def equivalent? = @status == :equivalent |
#from_cache? ⇒ Boolean
79 |
# File 'lib/henitai/mutant.rb', line 79 def from_cache? = @from_cache == true |
#ignored? ⇒ Boolean
82 |
# File 'lib/henitai/mutant.rb', line 82 def ignored? = @status == :ignored |
#killed? ⇒ Boolean
78 |
# File 'lib/henitai/mutant.rb', line 78 def killed? = @status == :killed |
#mutated_source ⇒ String
Unparsing is expensive and the value is needed by both the JSON and the terminal reporter — compute once per mutant.
76 |
# File 'lib/henitai/mutant.rb', line 76 def mutated_source = @mutated_source ||= safe_unparse(mutated_node) |
#pending? ⇒ Boolean
81 |
# File 'lib/henitai/mutant.rb', line 81 def pending? = @status == :pending |
#stable_id ⇒ String
rubocop:enable Metrics/ParameterLists
70 71 72 |
# File 'lib/henitai/mutant.rb', line 70 def stable_id @stable_id ||= @precomputed_stable_id || MutantIdentity.stable_id(self) end |
#survived? ⇒ Boolean
80 |
# File 'lib/henitai/mutant.rb', line 80 def survived? = @status == :survived |
#to_s ⇒ String
85 86 87 |
# File 'lib/henitai/mutant.rb', line 85 def to_s "#{operator}@#{location[:file]}:#{location[:start_line]} — #{description}" end |