Sha256: 9186b38d5b07672969c28af9b9aa12ad0cd09ecbc47242a6fa76fb58c531931a

Contents?: true

Size: 860 Bytes

Versions: 8

Compression:

Stored size: 860 Bytes

Contents

module Mutest
  class Mutator
    class Node
      module Regexp
        # Mutator for zero-or-more quantifier, `*`
        class ZeroOrMore < Node
          MAP = IceNine.deep_freeze(
            regexp_greedy_zero_or_more:     :regexp_greedy_one_or_more,
            regexp_reluctant_zero_or_more:  :regexp_reluctant_one_or_more,
            regexp_possessive_zero_or_more: :regexp_possessive_one_or_more
          )

          handle(*MAP.keys)

          children :min, :max, :subject

          # Replace `/a*/` with `/a+/`, `/a*?/` with `/a+?/`, and `/a*+/` with `/a++/`
          #
          # @return [undefined]
          def dispatch
            emit(s(MAP.fetch(node.type), *children))
            emit_subject_mutations
            emit(subject)
          end
        end # ZeroOrMore
      end # Regexp
    end # Node
  end # Mutator
end # Mutest

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mutest-0.0.9 lib/mutest/mutator/node/regexp/zero_or_more.rb
mutest-0.0.8 lib/mutest/mutator/node/regexp/zero_or_more.rb
mutest-0.0.7 lib/mutest/mutator/node/regexp/zero_or_more.rb
mutest-0.0.6 lib/mutest/mutator/node/regexp/zero_or_more.rb
mutest-0.0.5 lib/mutest/mutator/node/regexp/zero_or_more.rb
mutest-0.0.4 lib/mutest/mutator/node/regexp/zero_or_more.rb
mutest-0.0.3 lib/mutest/mutator/node/regexp/zero_or_more.rb
mutest-0.0.2 lib/mutest/mutator/node/regexp/zero_or_more.rb