class Mutest::Mutation

Represent a mutated node with its subject

Constants

CODE_DELIMITER
CODE_RANGE

Public Class Methods

success?(test_result) click to toggle source

Test if mutation is killed by test reports

@param [Result::Test] test_result

@return [Boolean]

# File lib/mutest/mutation.rb, line 47
def self.success?(test_result)
  self::TEST_PASS_SUCCESS.equal?(test_result.passed)
end

Public Instance Methods

code() click to toggle source

Mutation code

@return [String]

# File lib/mutest/mutation.rb, line 22
def code
  sha1[CODE_RANGE]
end
identification() click to toggle source

Identification string

@return [String]

# File lib/mutest/mutation.rb, line 14
def identification
  "#{self.class::SYMBOL}:#{subject.identification}:#{code}"
end
insert(kernel) click to toggle source

Insert mutated node

@param kernel [Kernel]

@return [self]

# File lib/mutest/mutation.rb, line 56
def insert(kernel)
  subject.prepare
  Loader.call(
    binding: TOPLEVEL_BINDING,
    kernel:  kernel,
    node:    root,
    subject: subject
  )
  self
end
original_source() click to toggle source

Normalized original source

@return [String]

# File lib/mutest/mutation.rb, line 38
def original_source
  subject.source
end
source() click to toggle source

Normalized mutation source

@return [String]

# File lib/mutest/mutation.rb, line 30
def source
  Unparser.unparse(node)
end

Private Instance Methods

root() click to toggle source

Mutated root node

@return [Parser::AST::Node]

# File lib/mutest/mutation.rb, line 80
def root
  subject.context.root(node)
end
sha1() click to toggle source

SHA1 sum of source and subject identification

@return [String]

# File lib/mutest/mutation.rb, line 72
def sha1
  Digest::SHA1.hexdigest(subject.identification + CODE_DELIMITER + source)
end