Sha256: e4d8f741c5ac768814f5d6c34e81390f0f0cc2bd670b24c7f73af420414c548a

Contents?: true

Size: 929 Bytes

Versions: 2

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true

module Mutant
  class Mutator
    class Node
      module Regexp
        # Character type mutator
        class CharacterType < Node
          map = {
            regexp_digit_type:           :regexp_nondigit_type,
            regexp_hex_type:             :regexp_nonhex_type,
            regexp_space_type:           :regexp_nonspace_type,
            regexp_word_boundary_anchor: :regexp_nonword_boundary_anchor,
            regexp_word_type:            :regexp_nonword_type,
            regexp_xgrapheme_type:       :regexp_space_type
          }

          MAP = IceNine.deep_freeze(map.merge(map.invert))

          handle(*MAP.keys)

          # Mutate to invert character type
          #
          # @return [undefined]
          def dispatch
            emit(s(MAP.fetch(node.type)))
          end
        end # CharacterType
      end # Regexp
    end # Node
  end # Mutator
end # Mutant

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mutant-0.8.18 lib/mutant/mutator/node/regexp/character_type.rb
mutant-0.8.17 lib/mutant/mutator/node/regexp/character_type.rb