Class: Mutant::Mutation

Inherits:
Object
  • Object
show all
Includes:
AbstractType, Adamantium::Flat
Defined in:
lib/mutant/mutation.rb

Overview

Represent a mutated node with its subject

Direct Known Subclasses

Evil, Neutral

Defined Under Namespace

Classes: Evil, Neutral, Noop

Constant Summary collapse

CODE_DELIMITER =
"\0".freeze
CODE_RANGE =
(0..4).freeze

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:

  • test_reports (Array<Report::Test>)

Returns:

  • (Boolean)


56
57
58
# File 'lib/mutant/mutation.rb', line 56

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 code

Returns:

  • (String)


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

def code
  sha1[CODE_RANGE]
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)


15
16
17
# File 'lib/mutant/mutation.rb', line 15

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

#insertself

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

Returns:

  • (self)


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

def insert
  subject.prepare
  Loader::Eval.call(root, subject)
  self
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)


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

def original_source
  subject.source
end

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

Returns:

  • (String)


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

def source
  Unparser.unparse(node)
end