Sha256: 7666fba2c37a169048d0f740eed7e91ded75c6346a173cd0bde185a8eb8529eb

Contents?: true

Size: 1.2 KB

Versions: 52

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Mutant
  class Mutator
    class Node
      # Namespace for define mutations
      class Define < self

      private

        def dispatch
          emit_arguments_mutations
          emit_optarg_body_assignments
          emit_body(N_RAISE)
          emit_body(N_ZSUPER)
          emit_body(nil)
          emit_body_mutations if body
        end

        def emit_optarg_body_assignments
          arguments.children.each do |argument|
            next unless n_optarg?(argument) && AST::Meta::Optarg.new(argument).used?

            emit_body_prepend(s(:lvasgn, *argument))
          end
        end

        def emit_body_prepend(node)
          if body
            emit_body(s(:begin, node, body))
          else
            emit_body(node)
          end
        end

        # Mutator for instance method defines
        class Instance < self

          handle :def

          children :name, :arguments, :body

        end # Instance

        # Mutator for singleton method defines
        class Singleton < self

          handle :defs

          children :subject, :name, :arguments, :body

        end # Singleton

      end # Define
    end # Node
  end # Mutator
end # Mutant

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
mutant-0.11.11 lib/mutant/mutator/node/define.rb
mutant-0.11.10 lib/mutant/mutator/node/define.rb
mutant-0.11.9 lib/mutant/mutator/node/define.rb
mutant-0.11.8 lib/mutant/mutator/node/define.rb
mutant-0.11.7 lib/mutant/mutator/node/define.rb
mutant-0.11.6 lib/mutant/mutator/node/define.rb
mutant-0.11.5 lib/mutant/mutator/node/define.rb
mutant-0.11.4 lib/mutant/mutator/node/define.rb
mutant-0.11.3 lib/mutant/mutator/node/define.rb
mutant-0.11.2 lib/mutant/mutator/node/define.rb
mutant-0.11.1 lib/mutant/mutator/node/define.rb
mutant-0.11.0 lib/mutant/mutator/node/define.rb
mutant-0.10.35 lib/mutant/mutator/node/define.rb
mutant-0.10.34 lib/mutant/mutator/node/define.rb
mutant-0.10.33 lib/mutant/mutator/node/define.rb
mutant-0.10.32 lib/mutant/mutator/node/define.rb
mutant-0.10.31 lib/mutant/mutator/node/define.rb
mutant-0.10.30 lib/mutant/mutator/node/define.rb
mutant-0.10.29 lib/mutant/mutator/node/define.rb
mutant-0.10.28 lib/mutant/mutator/node/define.rb