lib/mutant/mutator/node/send.rb in mutant-0.8.24 vs lib/mutant/mutator/node/send.rb in mutant-0.9.0

- old
+ new

@@ -19,29 +19,22 @@ is_a?: %i[instance_of?], reverse_each: %i[each], reverse_merge: %i[merge], map: %i[each], flat_map: %i[map], - sample: %i[first last], - pop: %i[last], - shift: %i[first], - first: %i[last], - last: %i[first], send: %i[public_send __send__], __send__: %i[public_send], method: %i[public_method], gsub: %i[sub], eql?: %i[equal?], to_s: %i[to_str], to_i: %i[to_int], - to_a: %i[to_ary to_set], + to_a: %i[to_ary], to_h: %i[to_hash], at: %i[fetch key?], fetch: %i[key?], values_at: %i[fetch_values], - match: %i[match?], - '=~': %i[match?], :== => %i[eql? equal?], :>= => %i[> == eql? equal?], :<= => %i[< == eql? equal?], :> => %i[== >= eql? equal?], :< => %i[== <= eql? equal?] @@ -157,11 +150,11 @@ # Emit mutation from `to_i` to `Integer(...)` # # @return [undefined] def emit_integer_mutation - return unless receiver && selector.equal?(:to_i) + return unless selector.equal?(:to_i) emit(s(:send, nil, :Integer, receiver)) end # Emit mutation from `const_get` to const literal @@ -191,15 +184,24 @@ # # @return [undefined] def mutate_arguments emit_type(receiver, selector) remaining_children_with_index.each do |_node, index| - mutate_child(index) + mutate_argument_index(index) delete_child(index) end end + # Mutate argument + # + # @param [Integer] index + # + # @return [undefined] + def mutate_argument_index(index) + mutate_child(index) { |node| !n_begin?(node) } + end + # Emit argument propagation # # @return [undefined] def emit_argument_propagation emit_propagation(Mutant::Util.one(arguments)) if arguments.one? @@ -219,11 +221,10 @@ # Emit implicit self mutation # # @return [undefined] def emit_implicit_self emit_receiver(nil) if n_self?(receiver) && !( - KEYWORDS.include?(selector) || - METHOD_OPERATORS.include?(selector) || + KEYWORDS.include?(selector) || meta.attribute_assignment? ) end end # Send