Sha256: 89a9bfc937b08e3ee2856e879ca9d0cfa4e341e9c0571db75f6948a541f41a94

Contents?: true

Size: 850 Bytes

Versions: 33

Compression:

Stored size: 850 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[..-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

33 entries across 33 versions & 1 rubygems

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