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
18 19 20 |
# File 'lib/rigor/protection/mutator.rb', line 18 def anchor @anchor end |
#anchor_type ⇒ Object
Returns the value of attribute anchor_type
18 19 20 |
# File 'lib/rigor/protection/mutator.rb', line 18 def anchor_type @anchor_type end |
#expected_rule ⇒ Object
Returns the value of attribute expected_rule
18 19 20 |
# File 'lib/rigor/protection/mutator.rb', line 18 def expected_rule @expected_rule end |
#label ⇒ Object
Returns the value of attribute label
18 19 20 |
# File 'lib/rigor/protection/mutator.rb', line 18 def label @label end |
#line ⇒ Object
Returns the value of attribute line
18 19 20 |
# File 'lib/rigor/protection/mutator.rb', line 18 def line @line end |
#method_name ⇒ Object
Returns the value of attribute method_name
18 19 20 |
# File 'lib/rigor/protection/mutator.rb', line 18 def method_name @method_name end |
#operator ⇒ Object
Returns the value of attribute operator
18 19 20 |
# File 'lib/rigor/protection/mutator.rb', line 18 def operator @operator end |
#replacement ⇒ Object
Returns the value of attribute replacement
18 19 20 |
# File 'lib/rigor/protection/mutator.rb', line 18 def replacement @replacement end |
#start ⇒ Object
Returns the value of attribute start
18 19 20 |
# File 'lib/rigor/protection/mutator.rb', line 18 def start @start end |
#stop ⇒ Object
Returns the value of attribute stop
18 19 20 |
# File 'lib/rigor/protection/mutator.rb', line 18 def stop @stop end |
Instance Method Details
#apply(source) ⇒ Object
23 24 25 26 27 |
# File 'lib/rigor/protection/mutator.rb', line 23 def apply(source) prefix = source.byteslice(0, start) suffix = source.byteslice(stop, source.bytesize - stop) || "" "#{prefix}#{replacement}#{suffix}" end |