Skip to content

Commit

Permalink
Merge pull request mbj#691 from mbj/fix/allow-empty-match-expressions
Browse files Browse the repository at this point in the history
Allow empty match expressions
  • Loading branch information
mbj authored Dec 5, 2016
2 parents 7c3f3a5 + 15b031a commit d4a0131
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 49 deletions.
6 changes: 3 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AllCops:
DisplayCopNames: true
Exclude:
- 'vendor/**/*'
- 'tmp/**/*'
- 'test_app/**/*'
- 'bin/mutant'
- 'tmp/**/*'
- 'vendor/**/*'
TargetRubyVersion: 2.2
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v0.8.13 2016-xx-xx

* Allow empty match expressions on CLI

# v0.8.12 2016-10-17

* Add mutation from `/foo|bar/` to `/foo/` and `/bar/`
Expand Down
2 changes: 1 addition & 1 deletion bin/mutant
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace =
.curry
.call(Kernel),
root_require: 'mutant',
includes: %w[
includes: %w[
mutant
unparser
morpher
Expand Down
3 changes: 3 additions & 0 deletions config/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,6 @@ AlignHash:
# Prefer `public_send` and `__send__` over `send`
Send:
Enabled: true

Lint/UnifiedInteger:
Enabled: false
2 changes: 0 additions & 2 deletions lib/mutant/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ def parse(arguments)
#
# @return [undefined]
def parse_match_expressions(expressions)
fail Error, 'No expressions given' if expressions.empty?

expressions.each do |expression|
add_matcher(:match_expressions, config.expression_parser.(expression))
end
Expand Down
3 changes: 1 addition & 2 deletions lib/mutant/color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def format(text)
# Initialize null color
#
# @return [undefined]
def initialize
end
def initialize; end

end.new

Expand Down
3 changes: 1 addition & 2 deletions lib/mutant/mutator/node/literal/nil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class Nil < self
# Emit mutations
#
# @return [undefined]
def dispatch
end
def dispatch; end

end # Nil
end # Literal
Expand Down
1 change: 1 addition & 0 deletions meta/case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
RUBY
end

# rubocop:disable Metrics/BlockLength
Mutant::Meta::Example.add :case do
source <<-RUBY
case condition
Expand Down
1 change: 1 addition & 0 deletions mutant.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require File.expand_path('../lib/mutant/version', __FILE__)

# rubocop:disable Metrics/BlockLength
Gem::Specification.new do |gem|
gem.name = 'mutant'
gem.version = Mutant::VERSION.dup
Expand Down
6 changes: 3 additions & 3 deletions spec/support/xspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def self.assert_not_empty(event_list)
private_class_method :assert_not_empty

def self.assert_total(event_list)
if event_list[0..-2].map(&:first).any?(&TERMINATE_EVENTS.method(:include?))
fail "Reaction not total: #{event_list}"
end
return unless event_list[0..-2].map(&:first).any?(&TERMINATE_EVENTS.method(:include?))

fail "Reaction not total: #{event_list}"
end
private_class_method :assert_total
end # MessageReaction
Expand Down
8 changes: 0 additions & 8 deletions spec/unit/mutant/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@
it_should_behave_like 'an invalid cli run'
end

context 'without expressions' do
let(:expressions) { [] }

let(:expected_message) { 'No expressions given' }

it_should_behave_like 'an invalid cli run'
end

context 'with include help flag' do
let(:flags) { %w[--help] }

Expand Down
6 changes: 2 additions & 4 deletions spec/unit/mutant/env/bootstrap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ def self.name
# Fix Class#name so other specs do not see this one
class << invalid_class
undef :name
def name
end
def name; end
end
end

Expand Down Expand Up @@ -151,8 +150,7 @@ def self.name
# Fix Class#name so other specs do not see this one
class << invalid_class
undef :name
def name
end
def name; end
end
end

Expand Down
15 changes: 5 additions & 10 deletions spec/unit/mutant/matcher/methods/instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,25 @@

let(:class_under_test) do
parent = Module.new do
def method_d
end
def method_d; end

def method_e
end
def method_e; end
end

Class.new do
include parent

private :method_d

def method_a
end
def method_a; end

protected

def method_b
end
def method_b; end

private

def method_c
end
def method_c; end
end
end

Expand Down
15 changes: 5 additions & 10 deletions spec/unit/mutant/matcher/methods/singleton_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@

let(:class_under_test) do
parent = Module.new do
def method_d
end
def method_d; end

def method_e
end
def method_e; end
end

Class.new do
extend parent

def self.method_a
end
def self.method_a; end

def self.method_b
end
def self.method_b; end
class << self; protected :method_b; end

def self.method_c
end
def self.method_c; end
private_class_method :method_c

end
Expand Down
1 change: 1 addition & 0 deletions spec/unit/mutant/repository/diff_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
subject { object.touches?(path, line_range) }

shared_context 'test if git tracks the file' do
# rubocop:disable Lint/UnneededSplatExpansion
before do
expect(config.kernel).to receive(:system)
.ordered
Expand Down
6 changes: 2 additions & 4 deletions spec/unit/mutant/subject/method/instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def initialize
@bar = :boo
end

def foo
end
def foo; end

def self.name
'Test'
Expand Down Expand Up @@ -84,8 +83,7 @@ def self.name
let(:scope) do
Class.new do
include Memoizable
def foo
end
def foo; end
memoize :foo
end
end
Expand Down

0 comments on commit d4a0131

Please sign in to comment.