Sha256: 9eba6fa3f3c868d5148fd75af463210dc90e8c5773ad356374934be00f3ad4a1

Contents?: true

Size: 1.87 KB

Versions: 16

Compression:

Stored size: 1.87 KB

Contents

# encoding: utf-8

module Mutant
  class Subject
    class Method
      # Instance method subjects
      class Instance < self

        NAME_INDEX = 0
        SYMBOL = '#'.freeze

        # Test if method is public
        #
        # @return [true]
        #   if method is public
        #
        # @return [false]
        #   otherwise
        #
        # @api private
        #
        def public?
          scope.public_method_defined?(name)
        end
        memoize :public?

      private

        # Mutator for memoized instance methods
        class Memoized < self
          include NodeHelpers

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

        private

          # Return mutations
          #
          # @param [#<<] emitter
          #
          # @return [undefined]
          #
          # @api private
          #
          def generate_mutations(emitter)
            emitter << noop_mutation
            Mutator.each(node) do |mutant|
              emitter << Mutation::Evil.new(self, memoizer_node(mutant))
            end
          end

          # Return neutral mutation
          #
          # @return [Mutation::Neutral]
          #
          # @api private
          #
          def noop_mutation
            Mutation::Neutral::Noop.new(self, memoizer_node(node))
          end

          # Return memoizer node for mutant
          #
          # @param [Parser::AST::Node] mutant
          #
          # @return [Parser::AST::Node]
          #
          # @api private
          #
          def memoizer_node(mutant)
            s(:begin, mutant, s(:send, nil, :memoize, s(:args, s(:sym, name))))
          end

        end # Memoized
      end # Instance
    end # Method
  end # Subject
end # Mutant

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mutant-0.5.6 lib/mutant/subject/method/instance.rb
mutant-0.5.5 lib/mutant/subject/method/instance.rb
mutant-0.5.4 lib/mutant/subject/method/instance.rb
mutant-0.5.3 lib/mutant/subject/method/instance.rb
mutant-0.5.2 lib/mutant/subject/method/instance.rb
mutant-0.5.1 lib/mutant/subject/method/instance.rb
mutant-0.5.0 lib/mutant/subject/method/instance.rb
mutant-0.3.6 lib/mutant/subject/method/instance.rb
mutant-0.3.5 lib/mutant/subject/method/instance.rb
mutant-0.3.4 lib/mutant/subject/method/instance.rb
mutant-0.3.3 lib/mutant/subject/method/instance.rb
mutant-0.3.2 lib/mutant/subject/method/instance.rb
mutant-0.3.1 lib/mutant/subject/method/instance.rb
mutant-0.3.0 lib/mutant/subject/method/instance.rb
mutant-0.3.0.rc5 lib/mutant/subject/method/instance.rb
mutant-0.3.0.rc4 lib/mutant/subject/method/instance.rb