Sha256: d2d36d4cbd2d5e9b10f42a065846fcb14b68e80656d3bfde22ff49c5f5f17b2f

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

module Mutant
  class Mutator
    class Node
      class Send
        # Base mutator for index operations
        class Index < self

          # Mutator for index assignments
          class Assign < self

            define_named_child(:value, -1)

            INDEX_RANGE = (2..-2).freeze

          private

            # Perform dispatch
            #
            # @return [undefined]
            #
            # @api private
            def dispatch
              emit_naked_receiver
              emit_value_mutations
              emit_index_read
              emit(value)
              mutate_indices
            end

            # Mutate indices
            #
            # @return [undefined]
            #
            # @api private
            def mutate_indices
              children_indices(INDEX_RANGE).each do |index|
                delete_child(index)
                mutate_child(index)
              end
            end

            # Emit index read
            #
            # @return [undefined]
            #
            # @api private
            def emit_index_read
              emit_type(receiver, :[], *children[INDEX_RANGE])
            end

          end # Assign
        end # Index
      end # Send
    end # Node
  end # Mutator
end # Mutant

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mutant-0.8.8 lib/mutant/mutator/node/send/index.rb
mutant-0.8.7 lib/mutant/mutator/node/send/index.rb
mutant-0.8.6 lib/mutant/mutator/node/send/index.rb
mutant-0.8.5 lib/mutant/mutator/node/send/index.rb
mutant-0.8.4 lib/mutant/mutator/node/send/index.rb
mutant-0.8.3 lib/mutant/mutator/node/send/index.rb
mutant-0.8.2 lib/mutant/mutator/node/send/index.rb
mutant-0.8.1 lib/mutant/mutator/node/send/index.rb