Class: Mutant::Mutation Private

Inherits:
Object
  • Object
show all
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

Direct Known Subclasses

Evil, Neutral

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

Instance Method Summary collapse

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

Parameters:

Returns:

  • (Boolean)


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

#codeString

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

Returns:

  • (String)


73
74
75
# File 'lib/mutant/mutation.rb', line 73

def code
  sha1[CODE_RANGE]
end

#diffObject

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

#identificationString

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

Returns:

  • (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

Parameters:

  • kernel (Kernel)

Returns:

  • (Loader::Result)


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

#monkeypatchString

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

Returns:

  • (String)


89
90
91
# File 'lib/mutant/mutation.rb', line 89

def monkeypatch
  Unparser.unparse(subject.context.root(node))
end

#original_sourceString

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

Returns:

  • (String)


97
98
99
# File 'lib/mutant/mutation.rb', line 97

def original_source
  subject.source
end