Sha256: cb309237515672f174f432948eb0b8b6403258136bc0307772b38c66f99414aa

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Mutant
  module Meta
    class Example
      include Adamantium

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

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

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

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

      # Context of mutation
      #
      # @return [Context]
      def context
        Context.new(
          Object,
          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,
          node:   node
        ).map do |node|
          Mutation::Evil.new(self, 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.18 lib/mutant/meta/example.rb
mutant-0.11.17 lib/mutant/meta/example.rb
mutant-0.11.16 lib/mutant/meta/example.rb
mutant-0.11.15 lib/mutant/meta/example.rb
mutant-0.11.14 lib/mutant/meta/example.rb
mutant-0.11.13 lib/mutant/meta/example.rb
mutant-0.11.12 lib/mutant/meta/example.rb