diff --git a/Changelog.md b/Changelog.md index 703cc1874..724b6bf0a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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. diff --git a/lib/mutant/ast/structure.rb b/lib/mutant/ast/structure.rb index 72e1f6e0a..5f480a01f 100644 --- a/lib/mutant/ast/structure.rb +++ b/lib/mutant/ast/structure.rb @@ -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( diff --git a/meta/def.rb b/meta/def.rb index 820fa7846..d95feb7f1 100644 --- a/meta/def.rb +++ b/meta/def.rb @@ -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'