Class: Henitai::Operators::RegexMutator

Inherits:
Henitai::Operator show all
Defined in:
lib/henitai/operators/regex_mutator.rb

Overview

Mutates regular expression literals by altering quantifiers, anchors, and character-class negation.

Each applicable transformation yields a separate mutant. Invalid results (unparseable regex) are discarded before emission. Anchor removal and character-class negation are intentionally one-way: they reduce noisy patterns rather than mirroring a full edit matrix.

Constant Summary collapse

NODE_TYPES =
%i[regexp].freeze

Constants inherited from Henitai::Operator

Henitai::Operator::FULL_SET, Henitai::Operator::LIGHT_SET

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Henitai::Operator

for_set, #name

Class Method Details

.node_typesObject



17
18
19
# File 'lib/henitai/operators/regex_mutator.rb', line 17

def self.node_types
  NODE_TYPES
end

Instance Method Details

#mutate(node, subject:) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/henitai/operators/regex_mutator.rb', line 21

def mutate(node, subject:)
  source, opts_node = extract_parts(node)
  return [] unless source

  transformations(source).filter_map do |new_source, description|
    build_regex_mutant(node, opts_node, new_source, source, description, subject:)
  end
end