Sha256: 9d65c40d93753cb2361303a61a59f4e337ccd39dca6322b451d1f8bd8ee59f7e

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

module Mutant
  class Mutator
    class Node
      class Literal
        # Mutator for hash literals
        class Hash < self

          handle(:hash)

        private

          # Emit mutations
          #
          # @return [undefined]
          #
          # @api private
          def dispatch
            emit_singletons
            emit_type
            mutate_body
          end

          # Mutate body
          #
          # @return [undefined]
          #
          # @api private
          def mutate_body
            children.each_index do |index|
              mutate_child(index)
              dup_children = children.dup
              dup_children.delete_at(index)
              emit_type(*dup_children)
            end
          end

          # Mutator for hash pairs
          class Pair < Node

            handle(:pair)

            children :key, :value

          private

            # Perform dispatch
            #
            # @return [undefined]
            #
            # @api private
            def dispatch
              emit_key_mutations
              emit_value_mutations
            end

          end # Pair
        end # Hash
      end # Literal
    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/literal/hash.rb
mutant-0.8.7 lib/mutant/mutator/node/literal/hash.rb
mutant-0.8.6 lib/mutant/mutator/node/literal/hash.rb
mutant-0.8.5 lib/mutant/mutator/node/literal/hash.rb
mutant-0.8.4 lib/mutant/mutator/node/literal/hash.rb
mutant-0.8.3 lib/mutant/mutator/node/literal/hash.rb
mutant-0.8.2 lib/mutant/mutator/node/literal/hash.rb
mutant-0.8.1 lib/mutant/mutator/node/literal/hash.rb