class Mutest::Mutator::Node::Arguments
Mutator
for arguments node
Private Instance Methods
dispatch()
click to toggle source
Emit mutations
@return [undefined]
# File lib/mutest/mutator/node/arguments.rb, line 13 def dispatch emit_argument_presence emit_argument_mutations emit_hash_type_hint emit_mlhs_expansion end
emit_argument_mutations()
click to toggle source
Emit argument mutations
@return [undefined]
# File lib/mutest/mutator/node/arguments.rb, line 45 def emit_argument_mutations children.each_with_index do |child, index| mutate(child).each do |mutest| next if invalid_argument_replacement?(mutest, index) emit_child_update(index, mutest) end end end
emit_argument_presence()
click to toggle source
Emit argument presence mutation
@return [undefined]
# File lib/mutest/mutator/node/arguments.rb, line 23 def emit_argument_presence emit_type mutate_with(Util::Array::Presence, children) do |children| if children.one? && n_mlhs?(Mutest::Util.one(children)) emit_procarg(Mutest::Util.one(children)) else emit_type(*children) end end end
emit_hash_type_hint()
click to toggle source
# File lib/mutest/mutator/node/arguments.rb, line 64 def emit_hash_type_hint *first_args, last_arg = children return unless last_arg && hintworthy_node?(last_arg) last_name = last_arg.children.first emit_type(*first_args, s(:kwrestarg, last_name)) unless last_name.to_s.start_with?('_') end
emit_mlhs_expansion()
click to toggle source
Emit mlhs expansions
@return [undefined]
# File lib/mutest/mutator/node/arguments.rb, line 83 def emit_mlhs_expansion mlhs_childs_with_index.each do |child, index| dup_children = children.dup dup_children.delete_at(index) dup_children.insert(index, *child) emit_type(*dup_children) end end
emit_procarg(arg)
click to toggle source
Emit procarg form
@return [undefined]
# File lib/mutest/mutator/node/arguments.rb, line 38 def emit_procarg(arg) emit_type(s(:procarg0, *arg)) end
hintworthy_node?(node)
click to toggle source
Is this a simple arg or arg={} ?
# File lib/mutest/mutator/node/arguments.rb, line 75 def hintworthy_node?(node) n_arg?(node) || (n_optarg?(node) && node.children.last.eql?(s(:hash))) end
invalid_argument_replacement?(mutest, index)
click to toggle source
Test
if child mutation is allowed
@param [Parser::AST::Node]
@return [Boolean]
# File lib/mutest/mutator/node/arguments.rb, line 60 def invalid_argument_replacement?(mutest, index) n_arg?(mutest) && children[0...index].any?(&method(:n_optarg?)) end
mlhs_childs_with_index()
click to toggle source
Multiple left hand side childs
@return [Enumerable<Parser::AST::Node, Integer>]
# File lib/mutest/mutator/node/arguments.rb, line 95 def mlhs_childs_with_index children.each_with_index.select do |child, _index| n_mlhs?(child) end end