Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deep forward args #1403

Merged
merged 5 commits into from
Oct 11, 2023
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
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# v0.11.24 2023-10-10

* Fix restarg and kwrestarg nested mutations.

[#1403](https://github.com/mbj/mutant/pull/1403)

# v0.11.23 2023-10-08

* Fix restarg and kwrestarg invalid mutations.

[#1402](https://github.com/mbj/mutant/pull/1402)

# v0.11.22 2023-07-16

* Introduce mutation operators config 'light' and 'full'. Mutant will default to
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
PATH
remote: .
specs:
mutant (0.11.23)
mutant (0.11.24)
diff-lcs (~> 1.3)
parser (~> 3.2.2, >= 3.2.2.4)
regexp_parser (~> 2.6.1)
regexp_parser (~> 2.8.2)
sorbet-runtime (~> 0.5.0)
unparser (~> 0.6.9)

Expand All @@ -27,7 +27,7 @@ GEM
racc
racc (1.7.1)
rainbow (3.1.1)
regexp_parser (2.6.2)
regexp_parser (2.8.2)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
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
2 changes: 1 addition & 1 deletion lib/mutant/mutator/regexp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def emit_removal
end

def emit_replacement
new_text = MAP[input.quantifier.text]
new_text = MAP[input.quantifier.text] or return

emit(mk_dup.tap { |new| new.quantifier.text = new_text })
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mutant/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module Mutant
# Current mutant version
VERSION = '0.11.23'
VERSION = '0.11.24'
end # Mutant
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
2 changes: 1 addition & 1 deletion mutant.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |gem|

gem.add_runtime_dependency('diff-lcs', '~> 1.3')
gem.add_runtime_dependency('parser', '~> 3.2.2', '>= 3.2.2.4')
gem.add_runtime_dependency('regexp_parser', '~> 2.6.1')
gem.add_runtime_dependency('regexp_parser', '~> 2.8.2')
gem.add_runtime_dependency('sorbet-runtime', '~> 0.5.0')
gem.add_runtime_dependency('unparser', '~> 0.6.9')

Expand Down
2 changes: 1 addition & 1 deletion scripts/devloop.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
while inotifywait lib/**/*.rb spec/**/*.rb Gemfile Gemfile.shared mutant.gemspec; do
while inotifywait lib/**/*.rb meta/**/*.rb spec/**/*.rb Gemfile Gemfile.shared mutant.gemspec; do
bundle exec rspec spec/unit -fd --fail-fast --order default \
&& bundle exec mutant run --since main --fail-fast --zombie -- 'Mutant*' \
&& bundle exec rubocop
Expand Down
28 changes: 3 additions & 25 deletions spec/integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,13 @@
- name: rubyspec
namespace: Rubyspec
repo_uri: 'https://github.com/ruby/rubyspec.git'
repo_ref: 249a36c2e9fcddbb208a0d618d05f6bd9a64fd17
repo_ref: 59bdcb4ea95c60159bb2bfc8c73022364da8ec0d
integration_name: mspec
mutation_coverage: false
mutation_generation: true
exclude:
- command_line/fixtures/bad_syntax.rb
- command_line/fixtures/freeze_flag_required_diff_enc.rb
- core/file/stat_spec.rb
- core/kernel/shared/sprintf_encoding.rb
- core/module/fixtures/autoload_empty.rb
- core/module/fixtures/autoload_never_set.rb
- core/module/fixtures/path2/load_path.rb
- core/regexp/shared/new.rb
- core/string/casecmp_spec.rb
- core/string/encode_spec.rb
- core/string/inspect_spec.rb
- core/string/shared/to_sym.rb
- core/symbol/casecmp_spec.rb
- language/fixtures/freeze_magic_comment_required_diff_enc.rb
- language/fixtures/utf16-be-nobom.rb
- language/fixtures/utf16-le-nobom.rb
- language/predefined/fixtures/data4.rb
- language/predefined/fixtures/data_only.rb
- language/source_encoding_spec.rb
- library/base64/decode64_spec.rb
- library/cgi/escapeHTML_spec.rb
# invalid regexp on 3.1 parser
- regexp_parser/test/parser/test_escapes.rb
- security/cve_2010_1330_spec.rb
# regexp_parser crash
- language/regexp/back-references_spec.rb
- name: regexp_parser
namespace: Regexp
repo_uri: 'https://github.com/ammar/regexp_parser.git'
Expand Down
7 changes: 6 additions & 1 deletion spec/support/corpus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ def checkout
#
# @return [Integer] mutations generated
def check_generation(path)
node = Unparser.parse(path.read) or return 0
begin
node = Unparser.parse(path.read) or return 0
# no need to generate mutation if the source is invalid
rescue Parser::SyntaxError
return 0
end

mutations = Mutant::Mutator::Node.mutate(
config: Mutant::Mutation::Config::DEFAULT.with(operators: Mutant::Mutation::Operators::Full.new),
Expand Down
10 changes: 5 additions & 5 deletions test_app/Gemfile.minitest.lock
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
PATH
remote: ..
specs:
mutant (0.11.23)
mutant (0.11.24)
diff-lcs (~> 1.3)
parser (~> 3.2.2, >= 3.2.2.4)
regexp_parser (~> 2.6.1)
regexp_parser (~> 2.8.2)
sorbet-runtime (~> 0.5.0)
unparser (~> 0.6.9)
mutant-minitest (0.11.23)
mutant-minitest (0.11.24)
minitest (~> 5.11)
mutant (= 0.11.23)
mutant (= 0.11.24)

GEM
remote: https://oss:Px2ENN7S91OmWaD5G7MIQJi1dmtmYrEh@gem.mutant.dev/
Expand All @@ -26,7 +26,7 @@ GEM
ast (~> 2.4.1)
racc
racc (1.7.1)
regexp_parser (2.6.1)
regexp_parser (2.8.2)
sorbet-runtime (0.5.10607)
unparser (0.6.9)
diff-lcs (~> 1.3)
Expand Down
10 changes: 5 additions & 5 deletions test_app/Gemfile.rspec3.8.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
PATH
remote: ..
specs:
mutant (0.11.23)
mutant (0.11.24)
diff-lcs (~> 1.3)
parser (~> 3.2.2, >= 3.2.2.4)
regexp_parser (~> 2.6.1)
regexp_parser (~> 2.8.2)
sorbet-runtime (~> 0.5.0)
unparser (~> 0.6.9)
mutant-rspec (0.11.23)
mutant (= 0.11.23)
mutant-rspec (0.11.24)
mutant (= 0.11.24)
rspec-core (>= 3.8.0, < 4.0.0)

GEM
Expand All @@ -31,7 +31,7 @@ GEM
ast (~> 2.4.1)
racc
racc (1.7.1)
regexp_parser (2.6.1)
regexp_parser (2.8.2)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
Expand Down