Skip to content
This repository was archived by the owner on Aug 23, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/mutest/mutator/node/define.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def dispatch
#
# @return [undefined]
def emit_optarg_body_assignments
arguments.children.each do |argument|
next unless n_optarg?(argument) && AST::Meta::Optarg.new(argument).used?
used_arguments.each do |argument|
next unless n_optarg?(argument)

emit_body_prepend(s(:lvasgn, *argument))
end
Expand All @@ -33,7 +33,7 @@ def emit_optarg_body_assignments
#
# @return [undefined]
def emit_restarg_body_mutation
arguments.children.each do |argument|
used_arguments.each do |argument|
replacement =
if n_restarg?(argument)
s(:array)
Expand All @@ -47,6 +47,10 @@ def emit_restarg_body_mutation
end
end

def used_arguments
arguments.children.select { |arg| AST::Meta::Optarg.new(arg).used? }
end

# Emit valid body ASTs depending on instance body
#
# @param node [Parser::AST::Node]
Expand Down
1 change: 0 additions & 1 deletion meta/kwrestarg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
source 'def foo(**_bar); end'

mutation 'def foo; end'
mutation 'def foo(**_bar); _bar = {}; end'
mutation 'def foo(**_bar); raise; end'
mutation 'def foo(**_bar); super; end'
end
Expand Down
8 changes: 8 additions & 0 deletions meta/restarg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@
mutation 'def foo(*bar); raise; end'
mutation 'def foo(*bar); super; end'
end

Mutest::Meta::Example.add :restarg do
source 'def foo(*_bar); end'

mutation 'def foo; end'
mutation 'def foo(*_bar); raise; end'
mutation 'def foo(*_bar); super; end'
end