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)

61
62
63
# File 'lib/mutant/mutation.rb', line 61

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.

Return mutation code

Returns:

  • (String)

27
28
29
# File 'lib/mutant/mutation.rb', line 27

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.

Return identification

Returns:

  • (String)

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

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

FIXME: Cache subject visibility in a better way! Ideally dont mutate it

implicitly. Also subject.public? should NOT be a public interface it
is a detail of method mutations.

Returns:

  • (self)

75
76
77
78
79
80
# File 'lib/mutant/mutation.rb', line 75

def insert
  subject.public?
  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.

Return original source

Returns:

  • (String)

49
50
51
# File 'lib/mutant/mutation.rb', line 49

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.

Return source

Returns:

  • (String)

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

def source
  Unparser.unparse(node)
end