Class: Mutant::Mutation Private
- Inherits:
-
Object
- Object
- Mutant::Mutation
- Includes:
- Unparser::AbstractType, Unparser::Adamantium
- Defined in:
- lib/mutant/mutation.rb,
lib/mutant/mutation/config.rb,
lib/mutant/mutation/runner.rb,
lib/mutant/mutation/operators.rb,
lib/mutant/mutation/runner/sink.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represent a mutated node with its subject
Defined Under Namespace
Modules: Runner Classes: Config, Evil, GenerationError, Neutral, Noop, Operators
Constant Summary collapse
- CODE_DELIMITER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"\0"- CODE_RANGE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
(..4)
Class Method Summary collapse
-
.from_node(subject:, node:) ⇒ Object
private
GenerationError.
-
.success?(test_result) ⇒ Boolean
private
Test if mutation is killed by test reports.
Instance Method Summary collapse
-
#code ⇒ String
private
Mutation identification code.
- #diff ⇒ Object private
-
#identification ⇒ String
private
Identification string.
-
#insert(kernel) ⇒ Loader::Result
private
Insert mutated node.
-
#monkeypatch ⇒ String
private
The monkeypatch to insert the mutation.
-
#original_source ⇒ String
private
Normalized original source.
Class Method Details
.from_node(subject:, node:) ⇒ Object
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.
GenerationError
61 62 63 64 65 66 67 68 |
# File 'lib/mutant/mutation.rb', line 61 def self.from_node(subject:, node:) ast = Unparser::AST.from_node(node:) Unparser .unparse_validate_ast_either(ast:) .lmap { |unparser_validation| GenerationError.new(subject:, node:, unparser_validation:) } .fmap { |source| new(node:, source:, subject:) } end |
.success?(test_result) ⇒ Boolean
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 mutation is killed by test reports
106 107 108 |
# File 'lib/mutant/mutation.rb', line 106 def self.success?(test_result) self::TEST_PASS_SUCCESS.equal?(test_result.passed) end |
Instance Method Details
#code ⇒ String
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.
Mutation identification code
73 74 75 |
# File 'lib/mutant/mutation.rb', line 73 def code sha1[CODE_RANGE] end |
#diff ⇒ Object
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.
128 129 130 |
# File 'lib/mutant/mutation.rb', line 128 def diff Unparser::Diff.build(original_source, source) end |
#identification ⇒ String
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.
Identification string
81 82 83 |
# File 'lib/mutant/mutation.rb', line 81 def identification "#{self.class::SYMBOL}:#{subject.identification}:#{code}" end |
#insert(kernel) ⇒ Loader::Result
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.
Insert mutated node
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/mutant/mutation.rb', line 115 def insert(kernel) subject.prepare Loader.call( binding: TOPLEVEL_BINDING, kernel:, source: monkeypatch, subject: ).fmap do subject.post_insert nil end end |
#monkeypatch ⇒ String
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.
The monkeypatch to insert the mutation
89 90 91 |
# File 'lib/mutant/mutation.rb', line 89 def monkeypatch Unparser.unparse(subject.context.root(node)) end |
#original_source ⇒ String
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.
Normalized original source
97 98 99 |
# File 'lib/mutant/mutation.rb', line 97 def original_source subject.source end |