Class: Mutant::Mutation

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/mutant/mutation.rb,
lib/mutant/mutation/filter.rb,
lib/mutant/mutation/filter/code.rb,
lib/mutant/mutation/filter/regexp.rb,
lib/mutant/mutation/filter/whitelist.rb

Overview

Represent a mutated node with its subject

Defined Under Namespace

Classes: Filter

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nodeRubinius::AST::Node (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.

Return mutated node

Returns:

  • (Rubinius::AST::Node)


20
21
22
# File 'lib/mutant/mutation.rb', line 20

def node
  @node
end

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

Return mutation subject

Returns:



12
13
14
# File 'lib/mutant/mutation.rb', line 12

def subject
  @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.

Return mutation code

Returns:

  • (String)


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

def code
  sha1[0..4]
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)


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

def identification
  "#{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)


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

def insert
  Loader::Eval.run(root)
  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)


94
95
96
# File 'lib/mutant/mutation.rb', line 94

def original_source
  subject.source
end

#rootRubinius::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:

  • (Rubinius::AST::Node)


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

def root
  subject.root(node)
end

#sha1String

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 sha1 sum of source and subject identification

Returns:

  • (String)


72
73
74
# File 'lib/mutant/mutation.rb', line 72

def sha1
  Digest::SHA1.hexdigest(subject.identification + 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)


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

def source
  ToSource.to_source(node)
end