Sha256: 268300169891b9504ab1019274c21a72f594873896d677303a7fcb8b69dc047c

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8

module Mutant
  class Mutator
    class Node
      module NamedValue

        # Mutation emitter to handle variable assignment nodes
        class VariableAssignment < Node

          children :name, :value

          MAP = IceNine.deep_freeze(
            :gvasgn => '$',
            :cvasgn => '@@',
            :ivasgn => '@',
            :lvasgn => ''
          )

          handle(*MAP.keys)

        private

          # Perform dispatch
          #
          # @return [undefined]
          #
          # @api private
          #
          def dispatch
            mutate_name
            emit_value_mutations if value # mlhs!
          end

          # Emit name mutations
          #
          # @return [undefined]
          #
          # @api private
          #
          def mutate_name
            prefix = MAP.fetch(node.type)
            Mutator::Util::Symbol.each(name, self) do |name|
              emit_name(prefix + name.to_s)
            end
          end

        end # VariableAssignment
      end # NamedValue
    end # Node
  end # Mutator
end # Mutant

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mutant-0.3.0.rc1 lib/mutant/mutator/node/named_value/variable_assignment.rb
mutant-0.3.0.beta22 lib/mutant/mutator/node/named_value/variable_assignment.rb