Class: Mutant::Mutation Private

Inherits:
Object
  • Object
show all
Includes:
AbstractType, Adamantium::Flat
Defined in:
lib/mutant/mutation.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

Classes: Evil, Neutral, Noop

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.

(0..4).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject, node) ⇒ Mutation

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.

Returns a new instance of Mutation.



12
13
14
15
16
17
18
19
# File 'lib/mutant/mutation.rb', line 12

def initialize(subject, node)
  super(subject, node)

  @source         = Unparser.unparse(node)
  @code           = sha1[CODE_RANGE]
  @identification = "#{self.class::SYMBOL}:#{subject.identification}:#{code}"
  @monkeypatch    = Unparser.unparse(subject.context.root(node))
end

Instance Attribute Details

#codeString (readonly)

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



24
25
26
# File 'lib/mutant/mutation.rb', line 24

def code
  @code
end

#identificationString (readonly)

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



34
35
36
# File 'lib/mutant/mutation.rb', line 34

def identification
  @identification
end

#monkeypatchString (readonly)

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



39
40
41
# File 'lib/mutant/mutation.rb', line 39

def monkeypatch
  @monkeypatch
end

#sourceString (readonly)

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 mutation source



29
30
31
# File 'lib/mutant/mutation.rb', line 29

def source
  @source
end

Class Method Details

.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



53
54
55
# File 'lib/mutant/mutation.rb', line 53

def self.success?(test_result)
  self::TEST_PASS_SUCCESS.equal?(test_result.passed)
end

Instance Method Details

#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



62
63
64
65
66
67
68
69
70
# File 'lib/mutant/mutation.rb', line 62

def insert(kernel)
  subject.prepare
  Loader.call(
    binding: TOPLEVEL_BINDING,
    kernel:  kernel,
    source:  monkeypatch,
    subject: subject
  )
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



44
45
46
# File 'lib/mutant/mutation.rb', line 44

def original_source
  subject.source
end