Class: Rigor::Protection::Mutation
- Inherits:
-
Struct
- Object
- Struct
- Rigor::Protection::Mutation
- Defined in:
- lib/rigor/protection/mutator.rb
Overview
One concrete edit: replace source bytes [start, stop) with ‘replacement`. `anchor` is the Prism node whose inferred type decides type-relevance —the call receiver whose contract the mutation could violate, or nil when there is no concrete receiver (implicit-self call, literal outside a call). `anchor_type` (the rendered receiver type) and `method_name` are filled in for reporting a surviving site; both may stay nil.
Instance Attribute Summary collapse
-
#anchor ⇒ Object
Returns the value of attribute anchor.
-
#anchor_type ⇒ Object
Returns the value of attribute anchor_type.
-
#expected_rule ⇒ Object
Returns the value of attribute expected_rule.
-
#label ⇒ Object
Returns the value of attribute label.
-
#line ⇒ Object
Returns the value of attribute line.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#replacement ⇒ Object
Returns the value of attribute replacement.
-
#start ⇒ Object
Returns the value of attribute start.
-
#stop ⇒ Object
Returns the value of attribute stop.
Instance Method Summary collapse
Instance Attribute Details
#anchor ⇒ Object
Returns the value of attribute anchor
22 23 24 |
# File 'lib/rigor/protection/mutator.rb', line 22 def anchor @anchor end |
#anchor_type ⇒ Object
Returns the value of attribute anchor_type
22 23 24 |
# File 'lib/rigor/protection/mutator.rb', line 22 def anchor_type @anchor_type end |
#expected_rule ⇒ Object
Returns the value of attribute expected_rule
22 23 24 |
# File 'lib/rigor/protection/mutator.rb', line 22 def expected_rule @expected_rule end |
#label ⇒ Object
Returns the value of attribute label
22 23 24 |
# File 'lib/rigor/protection/mutator.rb', line 22 def label @label end |
#line ⇒ Object
Returns the value of attribute line
22 23 24 |
# File 'lib/rigor/protection/mutator.rb', line 22 def line @line end |
#method_name ⇒ Object
Returns the value of attribute method_name
22 23 24 |
# File 'lib/rigor/protection/mutator.rb', line 22 def method_name @method_name end |
#operator ⇒ Object
Returns the value of attribute operator
22 23 24 |
# File 'lib/rigor/protection/mutator.rb', line 22 def operator @operator end |
#replacement ⇒ Object
Returns the value of attribute replacement
22 23 24 |
# File 'lib/rigor/protection/mutator.rb', line 22 def replacement @replacement end |
#start ⇒ Object
Returns the value of attribute start
22 23 24 |
# File 'lib/rigor/protection/mutator.rb', line 22 def start @start end |
#stop ⇒ Object
Returns the value of attribute stop
22 23 24 |
# File 'lib/rigor/protection/mutator.rb', line 22 def stop @stop end |
Instance Method Details
#apply(source) ⇒ Object
27 28 29 30 31 |
# File 'lib/rigor/protection/mutator.rb', line 27 def apply(source) prefix = source.byteslice(0, start) suffix = source.byteslice(stop, source.bytesize - stop) || "" "#{prefix}#{replacement}#{suffix}" end |