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

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
# File 'lib/mutant/mutation.rb', line 73

def code = sha1[CODE_RANGE]

#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.



111
# File 'lib/mutant/mutation.rb', line 111

def diff = Unparser::Diff.build(original_source, source)

#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)


79
# File 'lib/mutant/mutation.rb', line 79

def identification = "#{self.class::SYMBOL}:#{subject.identification}:#{code}"

#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)


98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/mutant/mutation.rb', line 98

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)


85
# File 'lib/mutant/mutation.rb', line 85

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

#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)


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

def original_source = subject.source