Sha256: 5d152a56f6afe97e992127d5c6d5fc3c4bef596abe9dd3bce248a193e577c1fe

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

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

            # Emit mutations
            #
            # @return [undefined]
            def dispatch
              emit_naked_receiver
              emit_value_mutations
              emit_index_read
              emit(value)
              mutate_indices
            end

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

            # Emit index read
            #
            # @return [undefined]
            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

6 entries across 6 versions & 1 rubygems

Version Path
mutant-0.8.16 lib/mutant/mutator/node/send/index.rb
mutant-0.8.15 lib/mutant/mutator/node/send/index.rb
mutant-0.8.14 lib/mutant/mutator/node/send/index.rb
mutant-0.8.13 lib/mutant/mutator/node/send/index.rb
mutant-0.8.12 lib/mutant/mutator/node/send/index.rb
mutant-0.8.11 lib/mutant/mutator/node/send/index.rb