Sha256: 9950a7f7c8441f69f82a4d6be4ec552943d64c54f73f639435b86c785bad8758

Contents?: true

Size: 1.06 KB

Versions: 30

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Mutant
  class Mutator
    class Node

      # Mutator for required arguments
      class Argument < self
        handle(:arg, :kwarg)

        UNDERSCORE = '_'

        children :name

      private

        def dispatch
          emit_name_mutation
        end

        def emit_name_mutation
          return if skip?
          emit_name(:"#{UNDERSCORE}#{name}")
        end

        def skip?
          name.start_with?(UNDERSCORE)
        end

        # Mutator for optional arguments
        class Optional < self

          TYPE_MAP = {
            optarg:   :arg,
            kwoptarg: :kwarg
          }.freeze

          handle(:optarg, :kwoptarg)

          children :name, :default

        private

          def dispatch
            emit_name_mutation
            emit_required_mutation
            emit_default_mutations
          end

          def emit_required_mutation
            emit(s(TYPE_MAP.fetch(node.type), name))
          end

        end # Optional
      end # Argument
    end # Node
  end # Mutator
end # Mutant

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
mutant-0.12.4 lib/mutant/mutator/node/argument.rb
mutant-0.12.3 lib/mutant/mutator/node/argument.rb
mutant-0.12.2 lib/mutant/mutator/node/argument.rb
mutant-0.12.0 lib/mutant/mutator/node/argument.rb
mutant-0.11.34 lib/mutant/mutator/node/argument.rb
mutant-0.11.33 lib/mutant/mutator/node/argument.rb
mutant-0.11.32 lib/mutant/mutator/node/argument.rb
mutant-0.11.31 lib/mutant/mutator/node/argument.rb
mutant-0.11.30 lib/mutant/mutator/node/argument.rb
mutant-0.11.29 lib/mutant/mutator/node/argument.rb
mutant-0.11.28 lib/mutant/mutator/node/argument.rb
mutant-0.11.27 lib/mutant/mutator/node/argument.rb
mutant-0.11.26 lib/mutant/mutator/node/argument.rb
mutant-0.11.25 lib/mutant/mutator/node/argument.rb
mutant-0.11.24 lib/mutant/mutator/node/argument.rb
mutant-0.11.23 lib/mutant/mutator/node/argument.rb
mutant-0.11.22 lib/mutant/mutator/node/argument.rb
mutant-0.11.21 lib/mutant/mutator/node/argument.rb
mutant-0.11.20 lib/mutant/mutator/node/argument.rb
mutant-0.11.19 lib/mutant/mutator/node/argument.rb