Class: Mutineer::Mutators::StatementRemoval
- Defined in:
- lib/mutineer/mutators/statement_removal.rb
Overview
Statement-removal operator: replace each non-final method statement with "nil". Tests whether the suite detects a missing side effect. The final expression is always skipped — replacing the return value with nil is the M5 return-nil operator's distinct concern (KTD-1). A body with < 2 statements has no non-final statement, so it generates nothing.
Clean-room: from the spec's operator description, not the mutant gem.
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#visit_statements_node(node) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mutineer/mutators/statement_removal.rb', line 15 def visit_statements_node(node) stmts = node.body return if stmts.length < 2 stmts[0...-1].each do |stmt| loc = stmt.location @mutations << Mutation.new( start_offset: loc.start_offset, end_offset: loc.end_offset, replacement: "nil", operator: :statement_removal ) end # ponytail: no super — recursing into a nested StatementsNode would # re-emit removals already covered at the top level and double-count. # Each subject's body is visited once. end |