Sha256: 72a64d7528e5098f20ef826f37f24e335161257e1cc4d7c58f07f525e84bd023

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

module Mutant
  module Meta
    class Example
      include Adamantium

      include Anima.new(
        :expected,
        :location,
        :lvars,
        :node,
        :operators,
        :original_source,
        :types
      )

      class Expected
        include Anima.new(:original_source, :node)
      end

      # Verification instance for example
      #
      # @return [Verification]
      def verification
        Verification.new(example: self, mutations: generated)
      end
      memoize :verification

      # Example identification
      #
      # @return [String]
      def identification
        location.to_s
      end

      # Context of mutation
      #
      # @return [Context]
      def context
        Context.new(
          scope:       Object,
          source_path: location.path
        )
      end

      # Original source as generated by unparser
      #
      # @return [String]
      def original_source_generated
        Unparser.unparse(node)
      end
      memoize :original_source_generated

      # Generated mutations on example source
      #
      # @return [Enumerable<Mutant::Mutation>]
      def generated
        Mutator::Node.mutate(
          config: Mutation::Config::DEFAULT.with(operators: operators),
          node:   node
        ).map do |node|
          Mutation::Evil.new(subject: self, node: node)
        end
      end
      memoize :generated

    end # Example
  end # Meta
end # Mutant

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mutant-0.11.28 lib/mutant/meta/example.rb
mutant-0.11.27 lib/mutant/meta/example.rb
mutant-0.11.26 lib/mutant/meta/example.rb
mutant-0.11.25 lib/mutant/meta/example.rb
mutant-0.11.24 lib/mutant/meta/example.rb
mutant-0.11.23 lib/mutant/meta/example.rb
mutant-0.11.22 lib/mutant/meta/example.rb