Class: Mutant::Mutation

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

Overview

Represent a mutated node with its subject

Direct Known Subclasses

Evil, Neutral

Defined Under Namespace

Classes: Evil, Neutral

Constant Summary collapse

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

Instance Method Summary collapse

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)


64
65
66
# File 'lib/mutant/mutation.rb', line 64

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)


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

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)


41
42
43
44
45
# File 'lib/mutant/mutation.rb', line 41

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


86
87
88
# File 'lib/mutant/mutation.rb', line 86

def original_source
  subject.source
end

#rootParser::AST::Node

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 mutated root node

Returns:

  • (Parser::AST::Node)


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

def root
  subject.root(node)
end

#should_fail?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 test should fail under mutation

Returns:

  • (Boolean)


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

def should_fail?
  self.class::SHOULD_FAIL
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)


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

def source
  Unparser.unparse(node)
end

#success?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 killer is successful

Parameters:

Returns:

  • (Boolean)


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

abstract_method :success?