Sha256: 1b2722c1c2b946f2549724d483c4ae09763f9a3f0a0d802dcfa790e71a2fd7af

Contents?: true

Size: 1.17 KB

Versions: 59

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Mutant
  class Mutator
    class Node
      # Mutator for if nodes
      class If < self

        handle(:if)

        children :condition, :if_branch, :else_branch

      private

        def dispatch
          emit_singletons
          mutate_condition
          mutate_if_branch
          mutate_else_branch
        end

        def mutate_condition
          emit_condition_mutations do |node|
            !n_self?(node)
          end
          emit_type(n_not(condition), if_branch, else_branch) unless n_match_current_line?(condition)
          emit_type(N_TRUE,  if_branch, else_branch)
          emit_type(N_FALSE, if_branch, else_branch)
        end

        def mutate_if_branch
          emit_type(condition, else_branch, nil) if else_branch
          return unless if_branch
          emit(if_branch)
          emit_if_branch_mutations
          emit_type(condition, if_branch, nil)
        end

        def mutate_else_branch
          return unless else_branch
          emit(else_branch)
          emit_else_branch_mutations
          emit_type(condition, nil, else_branch)
        end

      end # If
    end # Node
  end # Mutator
end # Mutant

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
mutant-0.10.14 lib/mutant/mutator/node/if.rb
mutant-0.10.13 lib/mutant/mutator/node/if.rb
mutant-0.10.12 lib/mutant/mutator/node/if.rb
mutant-0.10.11 lib/mutant/mutator/node/if.rb
mutant-0.10.10 lib/mutant/mutator/node/if.rb
mutant-0.10.9 lib/mutant/mutator/node/if.rb
mutant-0.10.8 lib/mutant/mutator/node/if.rb
mutant-0.10.7 lib/mutant/mutator/node/if.rb
mutant-0.10.6 lib/mutant/mutator/node/if.rb
mutant-0.10.5 lib/mutant/mutator/node/if.rb
mutant-0.10.4 lib/mutant/mutator/node/if.rb
mutant-0.10.1 lib/mutant/mutator/node/if.rb
mutant-0.10.0 lib/mutant/mutator/node/if.rb
mutant-0.9.14 lib/mutant/mutator/node/if.rb
mutant-0.9.13 lib/mutant/mutator/node/if.rb
mutant-0.9.12 lib/mutant/mutator/node/if.rb
mutant-0.9.11 lib/mutant/mutator/node/if.rb
mutant-0.9.10 lib/mutant/mutator/node/if.rb
mutant-0.9.9 lib/mutant/mutator/node/if.rb