Class: Mutant::Subject

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

Overview

Subject of a mutation

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextContext (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 context

Returns:



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

def context
  @context
end

#matcherMatcher (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 matcher

Returns:



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

def matcher
  @matcher
end

#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 AST node

Returns:

  • (Rubinius::AST::Node)


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

def node
  @node
end

Instance Method Details

#eachself, Enumerator<Mutation>

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.

Enumerate possible mutations

Returns:

  • (self)

    returns self if block given

  • (Enumerator<Mutation>)

    returns eumerator if no block given



40
41
42
43
44
45
46
47
# File 'lib/mutant/subject.rb', line 40

def each
  return to_enum unless block_given?
  Mutator.each(node) do |mutant|
    yield Mutation.new(self, mutant)
  end

  self
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 subject identicication

Returns:

  • (String)


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

def identification
  source_path = context.source_path
  source_line = node.line
  "#{matcher.identification}:#{source_path}:#{source_line}"
end

#original_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 root AST node for original AST ndoe

Returns:

  • (Rubinius::AST::Node)


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

def original_root
  root(node)
end

#root(node) ⇒ Rubinius::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 root AST for node

Parameters:

  • node (Rubinius::AST::Node)

Returns:

  • (Rubinius::AST::Node)


81
82
83
# File 'lib/mutant/subject.rb', line 81

def root(node)
  context.root(node)
end

#sourceSource

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 representation of ast

Returns:

  • (Source)


68
69
70
# File 'lib/mutant/subject.rb', line 68

def source
  ToSource.to_source(node)
end