Skip to content

Commit

Permalink
Add Ruby 3.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj committed Dec 26, 2020
1 parent caa2f95 commit 70c0007
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 56 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ruby-2.5, ruby-2.6, ruby-2.7]
ruby: [ruby-2.5, ruby-2.6, ruby-2.7, ruby-3.0]
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v2
Expand All @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ruby-2.6, ruby-2.7]
ruby: [ruby-2.6, ruby-2.7, ruby-3.0]
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v2
Expand All @@ -51,7 +51,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ruby-2.5, ruby-2.6, ruby-2.7]
ruby: [ruby-2.5, ruby-2.6, ruby-2.7, ruby-3.0]
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v2
Expand All @@ -71,7 +71,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ruby-2.5, ruby-2.6, ruby-2.7]
ruby: [ruby-2.5, ruby-2.6, ruby-2.7, ruby-3.0]
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v2
Expand All @@ -87,7 +87,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ruby-2.5, ruby-2.6, ruby-2.7]
ruby: [ruby-2.5, ruby-2.6, ruby-2.7, ruby-3.0]
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v2
Expand All @@ -103,7 +103,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ruby-2.5, ruby-2.6, ruby-2.7]
ruby: [ruby-2.5, ruby-2.6, ruby-2.7, ruby-3.0]
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v2
Expand All @@ -119,7 +119,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ruby-2.7]
ruby: [ruby-2.7, ruby-3.0]
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.bundle
/tmp
/.bundle
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.10.22 2020-12-23

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

* Add ruby-3.0 syntax and mutation support.

# v0.10.21 2020-12-23

* [#1174](https://github.com/mbj/mutant/pull/1174)
Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
mutant (0.10.21)
mutant (0.10.22)
abstract_type (~> 0.0.7)
adamantium (~> 0.2.0)
anima (~> 0.3.1)
Expand All @@ -12,9 +12,9 @@ PATH
ice_nine (~> 0.11.1)
memoizable (~> 0.4.2)
mprelude (~> 0.1.0)
parser (~> 2.7.1)
parser (~> 3.0.0)
procto (~> 0.0.2)
unparser (~> 0.5.5)
unparser (~> 0.5.6)
variable (~> 0.0.1)

GEM
Expand Down Expand Up @@ -47,7 +47,7 @@ GEM
procto (~> 0.0.2)
mutant-license (0.1.1.2.2355046999240944981729280251890364410689.2)
parallel (1.20.1)
parser (2.7.2.0)
parser (3.0.0.0)
ast (~> 2.4.1)
procto (0.0.3)
rainbow (3.0.0)
Expand Down Expand Up @@ -83,15 +83,15 @@ GEM
ruby-progressbar (1.10.1)
thread_safe (0.3.6)
unicode-display_width (1.7.0)
unparser (0.5.5)
unparser (0.5.6)
abstract_type (~> 0.0.7)
adamantium (~> 0.2.0)
anima (~> 0.3.1)
concord (~> 0.1.5)
diff-lcs (~> 1.3)
equalizer (~> 0.0.9)
mprelude (~> 0.1.0)
parser (>= 2.6.5)
parser (>= 3.0.0)
procto (~> 0.0.2)
variable (0.0.1)
equalizer (~> 0.0.11)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Supported indicates if a specific Ruby version / Implementation is actively supp
| cRUBY/MRI | 2.5 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| cRUBY/MRI | 2.6 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| cRUBY/MRI | 2.7 | :heavy_check_mark: | :heavy_check_mark: | :soon: | :heavy_check_mark: |
| cRUBY/MRI | 3.0 | :warning: | :soon: | :soon: | :soon: |
| cRUBY/MRI | 3.0 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_ceck_mark: |
| jruby | TBD | :email: | :email: | :email: | :email: |
| mruby | TBD | :email: | :email: | :email: | :email: |
| cRUBY/MRI | < 2.5 | :no_entry: | :no_entry: | :no_entry: | :no_entry: |
Expand Down
1 change: 1 addition & 0 deletions lib/mutant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ module Mutant
require 'mutant/mutator/node/match_current_line'
require 'mutant/mutator/node/index'
require 'mutant/mutator/node/procarg_zero'
require 'mutant/mutator/node/kwargs'
require 'mutant/loader'
require 'mutant/context'
require 'mutant/scope'
Expand Down
2 changes: 1 addition & 1 deletion lib/mutant/expression/namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Recursive < self
def initialize(*)
super

@syntax = "#{scope_name}*"
@syntax = "#{scope_name}*".freeze # rubocop:disable Style/RedundantFreeze

@recursion_pattern = Regexp.union(
/\A#{scope_name}\z/,
Expand Down
34 changes: 34 additions & 0 deletions lib/mutant/mutator/node/kwargs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

module Mutant
class Mutator
class Node
# Mutator for kwargs node
class Kwargs < self

handle(:kwargs)

private

def dispatch
emit_argument_presence
emit_argument_mutations
end

def emit_argument_presence
Util::Array::Presence.call(children).each do |children|
emit_type(*children)
end
end

def emit_argument_mutations
children.each_with_index do |child, index|
Mutator.mutate(child).each do |mutant|
emit_child_update(index, mutant)
end
end
end
end # Kwargs
end # Node
end # Mutator
end # Mutant
2 changes: 1 addition & 1 deletion lib/mutant/subject/method/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def options
# rubocop:disable Style/GuardClause
if FREEZER_OPTION_VALUES.key?(freezer)
[
s(:hash,
s(:kwargs,
s(:pair,
s(:sym, :freezer),
s(:sym, FREEZER_OPTION_VALUES.fetch(freezer))))
Expand Down
4 changes: 2 additions & 2 deletions lib/mutant/timer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def now
class Deadline
include Anima.new(:timer, :allowed_time)

def initialize(**arguments)
super(**arguments)
def initialize(*arguments)
super(*arguments)
@start_at = timer.now
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.10.21'
VERSION = '0.10.22'
end # Mutant
45 changes: 21 additions & 24 deletions meta/send.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,33 +363,30 @@
source 'foo.public_send(:bar, 1, two: true, **kwargs, &block)'

singleton_mutations
mutation 'foo.public_send(:bar, 1, { two: true, **kwargs }, &nil)'
mutation 'foo.public_send(:bar, 1, { two: true, **kwargs }, &self)'
mutation 'foo.public_send(:bar, 1, two: true, **kwargs, &nil)'
mutation 'foo.public_send(:bar, 1, two: true, **kwargs, &self)'
mutation 'foo.bar(1, two: true, **kwargs, &block)'
mutation 'foo'
mutation 'self.public_send(:bar, 1, { two: true, **kwargs }, &block)'
mutation 'self.public_send(:bar, 1, two: true, **kwargs, &block)'
mutation 'foo.public_send'
mutation 'foo.public_send(nil, 1, { two: true, **kwargs }, &block)'
mutation 'foo.public_send(self, 1, { two: true, **kwargs }, &block)'
mutation 'foo.public_send(:bar__mutant__, 1, { two: true, **kwargs }, &block)'
mutation 'foo.public_send(1, { two: true, **kwargs }, &block)'
mutation 'foo.public_send(:bar, nil, { two: true, **kwargs }, &block)'
mutation 'foo.public_send(:bar, self, { two: true, **kwargs }, &block)'
mutation 'foo.public_send(:bar, 0, { two: true, **kwargs }, &block)'
mutation 'foo.public_send(:bar, -1, { two: true, **kwargs }, &block)'
mutation 'foo.public_send(:bar, 2, { two: true, **kwargs }, &block)'
mutation 'foo.public_send(:bar, { two: true, **kwargs }, &block)'
mutation 'foo.public_send(:bar, 1, nil, &block)'
mutation 'foo.public_send(:bar, 1, self, &block)'
mutation 'foo.public_send(:bar, 1, {}, &block)'
mutation 'foo.public_send(:bar, 1, { nil => true, **kwargs }, &block)'
mutation 'foo.public_send(:bar, 1, { self => true, **kwargs }, &block)'
mutation 'foo.public_send(:bar, 1, { two__mutant__: true, **kwargs }, &block)'
mutation 'foo.public_send(:bar, 1, { two: false, **kwargs }, &block)'
mutation 'foo.public_send(:bar, 1, { **kwargs }, &block)'
mutation 'foo.public_send(:bar, 1, { two: true, **nil }, &block)'
mutation 'foo.public_send(:bar, 1, { two: true, **self }, &block)'
mutation 'foo.public_send(:bar, 1, { two: true }, &block)'
mutation 'foo.public_send(nil, 1, two: true, **kwargs, &block)'
mutation 'foo.public_send(self, 1, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar__mutant__, 1, two: true, **kwargs, &block)'
mutation 'foo.public_send(1, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, nil, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, self, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, 0, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, -1, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, 2, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, two: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, 1, nil => true, **kwargs, &block)'
mutation 'foo.public_send(:bar, 1, self => true, **kwargs, &block)'
mutation 'foo.public_send(:bar, 1, two__mutant__: true, **kwargs, &block)'
mutation 'foo.public_send(:bar, 1, two: false, **kwargs, &block)'
mutation 'foo.public_send(:bar, 1, **kwargs, &block)'
mutation 'foo.public_send(:bar, 1, two: true, **nil, &block)'
mutation 'foo.public_send(:bar, 1, two: true, **self, &block)'
mutation 'foo.public_send(:bar, 1, two: true, &block)'
mutation 'foo.public_send(:bar, 1, &block)'
mutation 'foo.public_send(:bar, 1, two: true, **kwargs)'
end
Expand Down
4 changes: 2 additions & 2 deletions mutant.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency('ice_nine', '~> 0.11.1')
gem.add_runtime_dependency('memoizable', '~> 0.4.2')
gem.add_runtime_dependency('mprelude', '~> 0.1.0')
gem.add_runtime_dependency('parser', '~> 2.7.1')
gem.add_runtime_dependency('parser', '~> 3.0.0')
gem.add_runtime_dependency('procto', '~> 0.0.2')
gem.add_runtime_dependency('unparser', '~> 0.5.5')
gem.add_runtime_dependency('unparser', '~> 0.5.6')
gem.add_runtime_dependency('variable', '~> 0.0.1')

gem.add_development_dependency('parallel', '~> 1.3')
Expand Down
17 changes: 9 additions & 8 deletions mutant.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#/usr/bin/bash -ex

bundle exec mutant run \
--zombie \
--ignore-subject Mutant::CLI#add_debug_options \
--ignore-subject Mutant::Isolation::Fork::Parent#call \
--ignore-subject Mutant::Mutator::Node::Argument#skip? \
--ignore-subject Mutant::Mutator::Node::ProcargZero#dispatch \
--ignore-subject Mutant::Mutator::Node::When#mutate_conditions \
--ignore-subject Mutant::Zombifier#call \
bundle exec mutant run \
--zombie \
--ignore-subject Mutant::CLI#add_debug_options \
--ignore-subject Mutant::Expression::Namespace::Recursive#initialize \
--ignore-subject Mutant::Isolation::Fork::Parent#call \
--ignore-subject Mutant::Mutator::Node::Argument#skip? \
--ignore-subject Mutant::Mutator::Node::ProcargZero#dispatch \
--ignore-subject Mutant::Mutator::Node::When#mutate_conditions \
--ignore-subject Mutant::Zombifier#call \
$*
4 changes: 2 additions & 2 deletions spec/unit/mutant/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def expect_value(value)
end

let(:original) do
Mutant::Config::DEFAULT.with(**{ key => original_value })
Mutant::Config::DEFAULT.with(key => original_value)
end

let(:other) do
Mutant::Config::DEFAULT.with(**{ key => other_value })
Mutant::Config::DEFAULT.with(key => other_value)
end

shared_examples 'overwrite value' do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/mutant/subject/method/instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def foo; end
let(:memoize_provider) { memoize_provider }

let(:options_node) do
[s(:hash, s(:pair, s(:sym, :freezer), s(:sym, freezer_option)))]
[s(:kwargs, s(:pair, s(:sym, :freezer), s(:sym, freezer_option)))]
end

context 'when no memoize options are given' do
Expand Down

0 comments on commit 70c0007

Please sign in to comment.