Sha256: 8c0392c6403c4e99630de2dc8531f15f875e19eeaf1ba870e08dd007c6bb44f9

Contents?: true

Size: 851 Bytes

Versions: 46

Compression:

Stored size: 851 Bytes

Contents

# frozen_string_literal: true

module Mutant
  class Mutator
    class Node

      # Mutator for when nodes
      class When < self

        handle(:when)

      private

        def dispatch
          if body
            mutate_body
          else
            emit_child_update(body_index, N_RAISE)
          end
          mutate_conditions
        end

        def mutate_conditions
          conditions = children.length - 1
          children[0..-2].each_index do |index|
            delete_child(index) if conditions > 1
            mutate_child(index)
          end
        end

        def mutate_body
          mutate_child(body_index)
        end

        def body
          children.fetch(body_index)
        end

        def body_index
          children.length - 1
        end

      end # When
    end # Node
  end # Mutator
end # Mutant

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
mutant-0.11.5 lib/mutant/mutator/node/when.rb
mutant-0.11.4 lib/mutant/mutator/node/when.rb
mutant-0.11.3 lib/mutant/mutator/node/when.rb
mutant-0.11.2 lib/mutant/mutator/node/when.rb
mutant-0.11.1 lib/mutant/mutator/node/when.rb
mutant-0.11.0 lib/mutant/mutator/node/when.rb
mutant-0.10.35 lib/mutant/mutator/node/when.rb
mutant-0.10.34 lib/mutant/mutator/node/when.rb
mutant-0.10.33 lib/mutant/mutator/node/when.rb
mutant-0.10.32 lib/mutant/mutator/node/when.rb
mutant-0.10.31 lib/mutant/mutator/node/when.rb
mutant-0.10.30 lib/mutant/mutator/node/when.rb
mutant-0.10.29 lib/mutant/mutator/node/when.rb
mutant-0.10.28 lib/mutant/mutator/node/when.rb
mutant-0.10.27 lib/mutant/mutator/node/when.rb
mutant-0.10.26 lib/mutant/mutator/node/when.rb
mutant-0.10.25 lib/mutant/mutator/node/when.rb
mutant-0.10.24 lib/mutant/mutator/node/when.rb
mutant-0.10.23 lib/mutant/mutator/node/when.rb
mutant-0.10.22 lib/mutant/mutator/node/when.rb