Sha256: 2752e9e5e2a1b288ef4380e5d027beb68bae72c72362f2c6f23c8333cb0baf8a

Contents?: true

Size: 1.8 KB

Versions: 17

Compression:

Stored size: 1.8 KB

Contents

module Mutant
  # Represent a mutated node with its subject
  class Mutation
    include AbstractType, Adamantium::Flat, Concord::Public.new(:subject, :node)

    # Return mutated root node
    #
    # @return [Parser::AST::Node]
    #
    # @api private
    #
    def root
      subject.root(node)
    end
    memoize :root

    # Test if killer is successful
    #
    # @param [Killer] killer
    #
    # @return [true]
    #   if killer is successful
    #
    # @return [false]
    #   otherwise
    #
    # @api private
    #
    abstract_method :success?

    # Insert mutated node
    #
    # FIXME:
    #   Cache subject visibility in a better way! Ideally dont mutate it implicitly.
    #   Also subject.public? should NOT be a public interface it is a detail of method
    #   mutations.
    #
    # @return [self]
    #
    # @api private
    #
    def insert
      subject.public?
      Loader::Eval.run(root, subject)
      self
    end

    # Return identification
    #
    # @return [String]
    #
    # @api private
    #
    def identification
      "#{subject.identification}:#{code}"
    end
    memoize :identification

    # Return mutation code
    #
    # @return [String]
    #
    # @api private
    #
    def code
      sha1[0..4]
    end
    memoize :code

    # Return sha1 sum of source and subject identification
    #
    # @return [String]
    #
    # @api private
    #
    def sha1
      Digest::SHA1.hexdigest(subject.identification + 0.chr + source)
    end
    memoize :sha1

    # Return source
    #
    # @return [String]
    #
    # @api private
    #
    def source
      Unparser.unparse(node)
    end
    memoize :source

    # Return original source
    #
    # @return [String]
    #
    # @api private
    #
    def original_source
      subject.source
    end

  end # Mutation
end # Mutant

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mutant-0.3.0.beta21 lib/mutant/mutation.rb
mutant-0.3.0.beta20 lib/mutant/mutation.rb
mutant-0.3.0.beta19 lib/mutant/mutation.rb
mutant-0.3.0.beta18 lib/mutant/mutation.rb
mutant-0.3.0.beta17 lib/mutant/mutation.rb
mutant-0.3.0.beta16 lib/mutant/mutation.rb
mutant-0.3.0.beta15 lib/mutant/mutation.rb
mutant-0.3.0.beta14 lib/mutant/mutation.rb
mutant-0.3.0.beta13 lib/mutant/mutation.rb
mutant-0.3.0.beta12 lib/mutant/mutation.rb
mutant-0.3.0.beta11 lib/mutant/mutation.rb
mutant-0.3.0.beta10 lib/mutant/mutation.rb
mutant-0.3.0.beta9 lib/mutant/mutation.rb
mutant-0.3.0.beta8 lib/mutant/mutation.rb
mutant-0.3.0.beta7 lib/mutant/mutation.rb
mutant-0.3.0.beta6 lib/mutant/mutation.rb
mutant-0.3.0.beta5 lib/mutant/mutation.rb