Merge branch 'master' into flexible-rspec
This commit is contained in:
commit
ad0ea265a2
13 changed files with 116 additions and 8 deletions
|
@ -34,9 +34,9 @@ group :metrics do
|
|||
gem 'flay', '~> 2.4.0'
|
||||
gem 'flog', '~> 4.1.1'
|
||||
gem 'reek', '~> 1.3.1', git: 'https://github.com/troessner/reek.git'
|
||||
gem 'rubocop', '~> 0.10.0', git: 'https://github.com/bbatsov/rubocop.git'
|
||||
gem 'rubocop', '~> 0.10.0', git: 'https://github.com/rom-rb/rubocop.git', branch: 'upgrade-parser-dependency'
|
||||
gem 'simplecov', '~> 0.7.1'
|
||||
gem 'yardstick', '~> 0.9.6'
|
||||
gem 'yardstick', '~> 0.9.6', git: 'https://github.com/dkubb/yardstick.git'
|
||||
|
||||
platforms :ruby_19, :ruby_20 do
|
||||
gem 'yard-spellcheck', '~> 0.1.5'
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
threshold: 16
|
||||
total_score: 764
|
||||
total_score: 758
|
||||
|
|
|
@ -26,6 +26,7 @@ module Mutant
|
|||
EMPTY_STRING = ''.freeze
|
||||
end # Mutant
|
||||
|
||||
require 'mutant/version'
|
||||
require 'mutant/cache'
|
||||
require 'mutant/node_helpers'
|
||||
require 'mutant/singleton_methods'
|
||||
|
@ -73,6 +74,7 @@ require 'mutant/mutator/node/send/binary'
|
|||
require 'mutant/mutator/node/when'
|
||||
require 'mutant/mutator/node/define'
|
||||
require 'mutant/mutator/node/mlhs'
|
||||
require 'mutant/mutator/node/nthref'
|
||||
require 'mutant/mutator/node/masgn'
|
||||
require 'mutant/mutator/node/return'
|
||||
require 'mutant/mutator/node/block'
|
||||
|
|
|
@ -267,7 +267,12 @@ module Mutant
|
|||
opts.separator ''
|
||||
opts.separator 'Options:'
|
||||
|
||||
opts.on('--code FILTER', 'Adds a code filter') do |filter|
|
||||
opts.on('--version', 'Print mutants version') do |name|
|
||||
puts "mutant-#{Mutant::VERSION}"
|
||||
Kernel.exit(0)
|
||||
end.on('-r', '--require NAME', 'Require file with NAME') do |name|
|
||||
require name
|
||||
end.on('--code FILTER', 'Adds a code filter') do |filter|
|
||||
add_filter Mutation::Filter::Code, filter
|
||||
end.on('--fail-fast', 'Fail fast') do
|
||||
set_fail_fast
|
||||
|
|
|
@ -23,7 +23,7 @@ module Mutant
|
|||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @ai private
|
||||
# @api private
|
||||
#
|
||||
def identification
|
||||
scope.name
|
||||
|
|
|
@ -15,7 +15,7 @@ module Mutant
|
|||
:blockarg, :op_asgn, :and_asgn,
|
||||
:regopt, :restarg, :resbody, :retry, :arg_expr,
|
||||
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
|
||||
:alias, :for, :xstr, :back_ref, :nth_ref, :class,
|
||||
:alias, :for, :xstr, :back_ref, :class,
|
||||
:sclass, :match_with_lvasgn, :match_current_line, :or_asgn, :kwbegin
|
||||
)
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ module Mutant
|
|||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_nil
|
||||
emit_values(values)
|
||||
|
|
27
lib/mutant/mutator/node/nthref.rb
Normal file
27
lib/mutant/mutator/node/nthref.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
# Mutator for nth-ref nodes
|
||||
class NthRef < self
|
||||
|
||||
handle :nth_ref
|
||||
|
||||
children :number
|
||||
|
||||
private
|
||||
|
||||
# Perform dispatch
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_number(number - 1)
|
||||
emit_number(number + 1)
|
||||
end
|
||||
|
||||
end # NthRef
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
|
@ -11,6 +11,11 @@ module Mutant
|
|||
|
||||
children :receiver, :selector
|
||||
|
||||
SELECTOR_REPLACEMENTS = {
|
||||
:send => :public_send,
|
||||
:gsub => :sub
|
||||
}.freeze
|
||||
|
||||
INDEX_REFERENCE = :[]
|
||||
INDEX_ASSIGN = :[]=
|
||||
ASSIGN_SUFFIX = :'='
|
||||
|
@ -98,11 +103,23 @@ module Mutant
|
|||
#
|
||||
def normal_dispatch
|
||||
emit_naked_receiver
|
||||
emit_selector_mutations
|
||||
mutate_receiver
|
||||
emit_argument_propagation
|
||||
mutate_arguments
|
||||
end
|
||||
|
||||
# Emit selector mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_selector_mutations
|
||||
replacement = SELECTOR_REPLACEMENTS.fetch(selector) { return }
|
||||
emit_selector(replacement)
|
||||
end
|
||||
|
||||
# Emit naked receiver mutation
|
||||
#
|
||||
# @return [undefined]
|
||||
|
|
5
lib/mutant/version.rb
Normal file
5
lib/mutant/version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
module Mutant
|
||||
# The current mutant version
|
||||
VERSION = '0.3.0.beta22'.freeze
|
||||
end # Mutant
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
# encoding: utf-8
|
||||
#
|
||||
require File.expand_path('../lib/mutant/version', __FILE__)
|
||||
|
||||
Gem::Specification.new do |gem|
|
||||
gem.name = 'mutant'
|
||||
gem.version = '0.3.0.beta22'
|
||||
gem.version = Mutant::VERSION.dup
|
||||
gem.authors = ['Markus Schirp']
|
||||
gem.email = ['mbj@schirp-dso.com']
|
||||
gem.description = 'Mutation testing for ruby'
|
||||
|
@ -16,7 +18,7 @@ Gem::Specification.new do |gem|
|
|||
gem.extra_rdoc_files = %w[TODO LICENSE]
|
||||
gem.executables = %w[mutant]
|
||||
|
||||
gem.add_runtime_dependency('parser', '~> 2.0.0.pre5')
|
||||
gem.add_runtime_dependency('parser', '~> 2.0.0.pre6')
|
||||
gem.add_runtime_dependency('unparser', '~> 0.0.14')
|
||||
gem.add_runtime_dependency('ice_nine', '~> 0.8.0')
|
||||
gem.add_runtime_dependency('descendants_tracker', '~> 0.0.1')
|
||||
|
|
19
spec/unit/mutant/mutator/node/nthref/mutation_spec.rb
Normal file
19
spec/unit/mutant/mutator/node/nthref/mutation_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# encoding: utf-8
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator, 'nthref' do
|
||||
context '$1' do
|
||||
let(:source) { '$1' }
|
||||
let(:mutations) { ['$2', '$0'] }
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context '$2' do
|
||||
let(:source) { '$2' }
|
||||
let(:mutations) { ['$3', '$1'] }
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
end
|
|
@ -5,6 +5,35 @@ require 'spec_helper'
|
|||
# FIXME: This spec needs to be structured better!
|
||||
describe Mutant::Mutator, 'send' do
|
||||
|
||||
context 'when using String#gsub' do
|
||||
let(:source) { 'foo.gsub(a, b)' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'foo'
|
||||
mutations << 'foo.gsub(a)'
|
||||
mutations << 'foo.gsub(b)'
|
||||
mutations << 'foo.gsub'
|
||||
mutations << 'foo.sub(a, b)'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'when using Kernel#send' do
|
||||
let(:source) { 'foo.send(bar)' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'foo.send'
|
||||
mutations << 'foo.public_send(bar)'
|
||||
mutations << 'bar'
|
||||
mutations << 'foo'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'inside op assign' do
|
||||
let(:source) { 'self.foo ||= expression' }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue