Class: Mutineer::Mutators::LiteralMutation
- Defined in:
- lib/mutineer/mutators/literal_mutation.rb
Overview
Literal-fuzzing operator (Tier 2, OFF by default). Integers emit up to three mutations (0, 1, n+1) with no-op guards for 0 and 1; strings collapse to "" unless already empty. One mutation per emitted candidate (R11).
Clean-room: from the spec's operator description, not the mutant gem.
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#visit_integer_node(node) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/mutineer/mutators/literal_mutation.rb', line 13 def visit_integer_node(node) n = node.value emit(node.location, "0") unless n.zero? emit(node.location, "1") unless n == 1 emit(node.location, (n + 1).to_s) super end |
#visit_string_node(node) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/mutineer/mutators/literal_mutation.rb', line 21 def visit_string_node(node) loc = node.location token = @source.byteslice(loc.start_offset...loc.end_offset) emit(loc, '""') unless token == '""' || token == "''" || node.unescaped.empty? super end |