Sha256: 4a01266f39d5ede3ff4431a703160ded608d8a87eed7c222bc0527b067a72e71

Contents?: true

Size: 1.29 KB

Versions: 16

Compression:

Stored size: 1.29 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

16 entries across 16 versions & 1 rubygems

Version Path
mutant-0.8.0 lib/mutant/mutator/node/send/index.rb
mutant-0.7.9 lib/mutant/mutator/node/send/index.rb
mutant-0.7.8 lib/mutant/mutator/node/send/index.rb
mutant-0.7.7 lib/mutant/mutator/node/send/index.rb
mutant-0.7.6 lib/mutant/mutator/node/send/index.rb
mutant-0.7.5 lib/mutant/mutator/node/send/index.rb
mutant-0.7.4 lib/mutant/mutator/node/send/index.rb
mutant-0.7.3 lib/mutant/mutator/node/send/index.rb
mutant-0.7.2 lib/mutant/mutator/node/send/index.rb
mutant-0.7.1 lib/mutant/mutator/node/send/index.rb
mutant-0.6.7 lib/mutant/mutator/node/send/index.rb
mutant-0.6.6 lib/mutant/mutator/node/send/index.rb
mutant-0.6.5 lib/mutant/mutator/node/send/index.rb
mutant-0.6.4 lib/mutant/mutator/node/send/index.rb
mutant-0.6.3 lib/mutant/mutator/node/send/index.rb
mutant-0.6.2 lib/mutant/mutator/node/send/index.rb