class Mutest::Subject

Subject of a mutation

Public Instance Methods

identification() click to toggle source

Identification string

@return [String]

# File lib/mutest/subject.rb, line 55
def identification
  "#{expression.syntax}:#{source_path}:#{source_line}"
end
mutations() click to toggle source

Mutations for this subject

@return [Enumerable<Mutation>] @return [undefined]

# File lib/mutest/subject.rb, line 13
def mutations
  [neutral_mutation].concat(
    Mutator.mutate(node, context.method(:ignore?)).map do |mutant|
      Mutation::Evil.new(self, wrap_node(mutant))
    end
  )
end
prepare() click to toggle source

Prepare subject for insertion of mutation

@return [self]

# File lib/mutest/subject.rb, line 32
def prepare
  self
end
source() click to toggle source

Source representation of AST

@return [String]

# File lib/mutest/subject.rb, line 63
def source
  Unparser.unparse(wrap_node(node))
end
source_line() click to toggle source

First source line

@return [Integer]

# File lib/mutest/subject.rb, line 48
def source_line
  source_lines.begin
end
source_lines() click to toggle source

Source line range

@return [Range<Integer>]

# File lib/mutest/subject.rb, line 39
def source_lines
  expression = node.location.expression
  expression.line..expression.source_buffer.decompose_position(expression.end_pos).first
end
source_path() click to toggle source

Source path

@return [Pathname]

# File lib/mutest/subject.rb, line 25
def source_path
  context.source_path
end

Private Instance Methods

neutral_mutation() click to toggle source

Neutral mutation

@return [Mutation::Neutral]

# File lib/mutest/subject.rb, line 83
def neutral_mutation
  Mutation::Neutral.new(self, wrap_node(node))
end
wrap_node(node) click to toggle source

Wrap node into subject specific container

@param [Parser::AST::Node] node

@return [Parser::AST::Node]

# File lib/mutest/subject.rb, line 92
def wrap_node(node)
  node
end