Skip to content

Commit

Permalink
Fix restarg and kwrestarg deep mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj committed Oct 11, 2023
1 parent eb1a23b commit 5aeb182
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v0.11.23 2023-10-10

* Fix restarg and kwrestarg nested mutations.

# v0.11.23 2023-10-08

* Fix restarg and kwrestarg invalid mutations.
Expand Down
10 changes: 10 additions & 0 deletions lib/mutant/ast/structure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,16 @@ def variable_descendants(node)
fixed: EMPTY_ARRAY,
variable: nil
),
Node.new(
type: :forwarded_kwrestarg,
fixed: EMPTY_ARRAY,
variable: nil
),
Node.new(
type: :forwarded_restarg,
fixed: EMPTY_ARRAY,
variable: nil
),
Node.new(
type: :for,
fixed: Node.fixed(
Expand Down
31 changes: 31 additions & 0 deletions meta/def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,37 @@
mutation 'def foo(**); { nil => nil, ** }; end'
mutation 'def foo(**); {}; end'
end

Mutant::Meta::Example.add :hash do
source 'def foo(**); bar { { ** } }; end'

mutation 'def foo(**); bar { nil }; end'
mutation 'def foo(**); bar { raise }; end'
mutation 'def foo(**); bar { {} }; end'
mutation 'def foo(**); bar { }; end'
mutation 'def foo(**); bar; end'
mutation 'def foo(**); end'
mutation 'def foo(**); nil; end'
mutation 'def foo(**); raise; end'
mutation 'def foo(**); super; end'
mutation 'def foo(**); { ** }; end'
end

Mutant::Meta::Example.add :hash do
source 'def foo(*); bar { boz(*) }; end'

mutation 'def foo(*); bar { boz }; end'
mutation 'def foo(*); bar { nil }; end'
mutation 'def foo(*); bar { raise }; end'
mutation 'def foo(*); bar { }; end'
mutation 'def foo(*); bar.boz(*); end'
mutation 'def foo(*); bar; end'
mutation 'def foo(*); boz(*); end'
mutation 'def foo(*); end'
mutation 'def foo(*); nil; end'
mutation 'def foo(*); raise; end'
mutation 'def foo(*); super; end'
end
end

if RUBY_VERSION >= '3.1'
Expand Down

0 comments on commit 5aeb182

Please sign in to comment.