Class: Mutant::Subject

Inherits:
Object
  • Object
show all
Includes:
AbstractType, Adamantium::Flat, Enumerable
Defined in:
lib/mutant/subject.rb,
lib/mutant/subject/method.rb,
lib/mutant/subject/method/instance.rb,
lib/mutant/subject/method/singleton.rb

Overview

Subject of a mutation

Direct Known Subclasses

Method

Defined Under Namespace

Classes: Method

Instance Method Summary collapse

Instance Method Details

#expressionExpression

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.

Match expression

Returns:



85
# File 'lib/mutant/subject.rb', line 85

abstract_method :expression

#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)


65
66
67
# File 'lib/mutant/subject.rb', line 65

def identification
  "#{expression.syntax}:#{source_path}:#{source_line}"
end

#match_expressionsEnumerable<Expression>

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.

Match expressions

Returns:



92
# File 'lib/mutant/subject.rb', line 92

abstract_method :match_expressions

#mutationsEnumerable<Mutation>, undefined

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.

Mutations for this subject

Returns:



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

def mutations
  mutations = [neutral_mutation]
  Mutator.each(node) do |mutant|
    mutations << Mutation::Evil.new(self, wrap_node(mutant))
  end
  mutations
end

#prepareself

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.

Prepare subject for insertion of mutation

Returns:

  • (self)


36
37
38
# File 'lib/mutant/subject.rb', line 36

def prepare
  self
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.

Source representation of AST

Returns:

  • (String)


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

def source
  Unparser.unparse(wrap_node(node))
end

#source_lineFixnum

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.

First source line

Returns:

  • (Fixnum)


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

def source_line
  source_lines.begin
end

#source_linesRange<Fixnum>

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.

Source line range

Returns:

  • (Range<Fixnum>)


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

def source_lines
  expression = node.location.expression
  expression.line..expression.source_buffer.decompose_position(expression.end_pos).first
end

#source_pathPathname

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.

Source path

Returns:

  • (Pathname)


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

def source_path
  context.source_path
end