Sha256: e7ae6ff3625d00c2e8892a3215b23fd6e17b1233285ffd2cb262d1f4a4d83391

Contents?: true

Size: 916 Bytes

Versions: 9

Compression:

Stored size: 916 Bytes

Contents

# frozen_string_literal: true

module Mutant
  class Mutator
    class Node
      class Literal < self
        # Mutator for regexp literals
        class Regex < self

          handle(:regexp)

          # No input can ever be matched with this
          NULL_REGEXP_SOURCE = 'nomatch\A'

        private

          # Original regexp options
          #
          # @return [Parser::AST::Node]
          def options
            children.last
          end

          # Emit mutations
          #
          # @return [undefined]
          def dispatch
            emit_singletons unless parent_node
            children.each_with_index do |child, index|
              mutate_child(index) unless n_str?(child)
            end
            emit_type(options)
            emit_type(s(:str, NULL_REGEXP_SOURCE), options)
          end

        end # Regex
      end # Literal
    end # Node
  end # Mutator
end # Mutant

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mutant-0.9.8 lib/mutant/mutator/node/literal/regex.rb
mutant-0.9.7 lib/mutant/mutator/node/literal/regex.rb
mutant-0.9.6 lib/mutant/mutator/node/literal/regex.rb
mutant-0.9.5 lib/mutant/mutator/node/literal/regex.rb
mutant-0.9.4 lib/mutant/mutator/node/literal/regex.rb
mutant-0.9.3 lib/mutant/mutator/node/literal/regex.rb
mutant-0.9.2 lib/mutant/mutator/node/literal/regex.rb
mutant-0.9.1 lib/mutant/mutator/node/literal/regex.rb
mutant-0.9.0 lib/mutant/mutator/node/literal/regex.rb