Fix whitespace

This commit is contained in:
Dan Kubb 2013-04-17 20:31:21 -07:00
parent 4af9e3e5c9
commit c3c0e06c86
54 changed files with 106 additions and 110 deletions

View file

@ -10,7 +10,7 @@ rvm:
matrix:
allow_failures:
# No mutators for 1.8 specifc AST nodes
- rvm: rbx-18mode
- rvm: rbx-18mode
- rvm: 1.8.7
# We'll see what happens
- rvm: ruby-head

View file

@ -122,7 +122,7 @@
# v0.2.1 2012-12-07
* [fixed] Crash on unavailable source location
* [fixed] Incorrect handling of if and unless statements
* [fixed] Incorrect handling of if and unless statements
* [fixed] Expand Foo#initialize to spec/unit/foo in rspec dm2 strategy
* [fixed] Correctly expand [] to element_reader_spec.rb in rspec dm2 strategy
* [fixed] Correctly expand []= to element_writer_spec.rb in rspec dm2 strategy

View file

@ -7,12 +7,12 @@ mutant
Mutant is a mutation testing tool for ruby that aims to be better than existing mutation testers.
The idea is that if code can be changed and your tests do not notice, either that code isn't being covered
The idea is that if code can be changed and your tests do not notice, either that code isn't being covered
or it does not have a speced side effect.
Mutant does currently only support 1.9 mode under Rubinius or MRI. Support for JRuby is planned.
Mutant does currently only support 1.9 mode under Rubinius or MRI. Support for JRuby is planned.
Also it is easy to write a mutation killer for other test/spec frameworks than rspec2.
Also it is easy to write a mutation killer for other test/spec frameworks than rspec2.
Just create your own Mutant::Killer subclass, and make sure I get a PR!
See this [ASCII-Cast](http://ascii.io/a/1707) for mutant in action! (v0.2.1)
@ -45,7 +45,7 @@ CLI will be simplified in the next releases, but currently stick with this:
cd virtus
# Run mutant on virtus namespace (that uses the dm-2 style spec layout)
mutant -I lib -r virtus --rspec-dm2 ::Virtus
# Run mutant on specific virtus class
# Run mutant on specific virtus class
mutant -I lib -r virtus --rspec-dm2 ::Virtus::Attribute
# Run mutant on specific virtus class method
mutant -I lib -r virtus --rspec-dm2 ::Virtus::Attribute.build
@ -110,7 +110,7 @@ I'm very happy to receive/answer feedback/questions and critism.
Your options:
* Github Issue https://github.com/mutant/issues
* Ping me on https://twitter.com/_m_b_j_
* Ping me on https://twitter.com/_m_b_j_
* #datamapper channel on freenode, I hang around on CET daytimes. (nick mbj)
Credits

6
TODO
View file

@ -15,11 +15,11 @@ Mutations:
* Mutate options on Regexp literals
* Add mutations for dynamic regexp symbol and string literals
* Mutate "def foo; bar; end" to "def foo; self; end"?
* Emit negative and positive mutations
* Emit negative and positive mutations
* Mutate Block catch "def foo(&block)" and block pass "foo(&block)"
* Mutate super arguments just like send arguments
* Add timeout to terminate infinite loops
Example of a negative mutation:
Mutations on local variables and arguments prefixed with an underscore would be emitted as
negative mutations that must be alive.
@ -29,7 +29,7 @@ Loader:
Killers:
* Move test framework specific stuff to strategy
* Add a general master <=> killer IPC interface. So different strategies of isolation
* Add a general master <=> killer IPC interface. So different strategies of isolation
(fork, vs jruby runtime creation) will work without big impact.
Strategy:

View file

@ -5,7 +5,7 @@ AssignmentInConditionalCheck: {}
CaseMissingElseCheck: {}
ClassLineCountCheck:
line_count: 324
ClassNameCheck:
ClassNameCheck:
pattern: !ruby/regexp /\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/
ClassVariableCheck: {}
CyclomaticComplexityBlockCheck:

View file

@ -9,14 +9,14 @@ UncommunicativeParameterName:
- !ruby/regexp /[A-Z]/
LargeClass:
max_methods: 10
exclude:
exclude:
- "Mutant::Reporter::CLI" # 16 methods TODO Reduce!
- "Mutant::Reporter::Stats" # 6 ivars TODO Reduce!
- "Mutant::CLI" # 19 methods and 7 ivars, TODO Reduce!
enabled: true
max_instance_variables: 3
UncommunicativeMethodName:
accept:
accept:
- sha1
exclude: []
enabled: true
@ -26,7 +26,7 @@ UncommunicativeMethodName:
- !ruby/regexp /[A-Z]/
LongParameterList:
max_params: 2
exclude:
exclude:
- "Mutant::Mutator::Node#new_send_with_arguments" # 3 params
- "Mutant::Context::Constant#initialize" # 3 params
- "Mutant::Subject#initialize" # 3 params
@ -45,7 +45,7 @@ IrresponsibleModule:
exclude: []
enabled: true
UncommunicativeModuleName:
accept:
accept:
- Mutant::Mutator::Node::Iter19
- Mutant::Strategy::Rspec::DM2
exclude: []
@ -55,7 +55,7 @@ UncommunicativeModuleName:
- !ruby/regexp /[0-9]$/
NestedIterators:
ignore_iterators: []
exclude:
exclude:
- Mutant#self.define_singleton_subclass
- Mutant::Mutator::Util::Array::Element#dispatch
- Mutant::Mutator::Node::ReceiverCase#emit_when_branch_mutation
@ -67,7 +67,7 @@ LongMethod:
enabled: true
Duplication:
allow_calls: []
exclude:
exclude:
- Mutant::Mutator::Node::Literal::Hash#emit_element_presence
enabled: true
max_calls: 1

View file

@ -19,7 +19,7 @@ require 'concord'
# Patch ice none to freeze nodes correctly
class IceNine::Freezer
# Rubinius namsepace
class Rubinius
class Rubinius
# AST namespace
class AST < IceNine::Freezer::Object
# Node configuration
@ -84,8 +84,8 @@ require 'mutant/mutator/node/return'
require 'mutant/mutator/node/iter_19'
require 'mutant/mutator/node/if'
require 'mutant/mutator/node/receiver_case'
require 'mutant/config'
require 'mutant/loader'
require 'mutant/config'
require 'mutant/loader'
require 'mutant/context'
require 'mutant/context/scope'
require 'mutant/subject'

View file

@ -149,7 +149,7 @@ module Mutant
end
# Process matcher argument
#
#
# @return [undefined]
#
# @api private

View file

@ -11,7 +11,7 @@ module Mutant
SINGLETON_PATTERN = %r(\A(#{SCOPE_PATTERN})\z).freeze
# Return constant
# Return constant
#
# @param [String] location
#

View file

@ -26,7 +26,7 @@ module Mutant
# @api private
#
def namespace
Classifier.const_lookup(match.to_s)
Classifier.const_lookup(match.to_s)
end
end
end

View file

@ -1,8 +1,8 @@
module Mutant
# Base class for cli parsers
#
# I hate base classes for reusable functionallity.
# But could not come up with a nice composition/instantiation
# I hate base classes for reusable functionallity.
# But could not come up with a nice composition/instantiation
# solution.
#
class CLIParser
@ -15,7 +15,7 @@ module Mutant
OPTION_PATTERN = %r(\A-(?:-)?[a-zA-Z0-9\-]+\z).freeze
# Initialize CLI
# Initialize CLI
#
# @param [Array<String>] arguments
#

View file

@ -28,7 +28,7 @@ module Mutant
# Wrap node into ast node
#
# @param [Class, Module] scope
# @param [Class, Module] scope
# @param [Rubinius::AST::Node] node
#
# @return [Rubinius::AST::Class]

View file

@ -3,7 +3,7 @@ module Mutant
class Differ
include Adamantium::Flat
# Return source diff
# Return source diff
#
# @return [String]
#
@ -20,7 +20,7 @@ module Mutant
end
memoize :diff
# Return colorized source diff
# Return colorized source diff
#
# @return [String]
#
@ -40,7 +40,7 @@ module Mutant
# Initialize differ object
#
# @param [String] old
# @param [String] old
# @param [String] new
#
# @return [undefined]
@ -109,4 +109,3 @@ module Mutant
end
end
end

View file

@ -32,7 +32,7 @@ module Mutant
@strategy, @mutation = strategy, mutation
run_with_benchmark
end
# Test for kill failure
#
# @return [true]
@ -92,7 +92,7 @@ module Mutant
start_time = Time.now
@killed = run
end_time = Time.now
@runtime = end_time - start_time
@runtime = end_time - start_time
end
# Run killer

View file

@ -21,7 +21,7 @@ module Mutant
# Run killer
#
# @return [true]
# @return [true]
# if mutant was killed
#
# @return [false]

View file

@ -8,7 +8,7 @@ module Mutant
# Run rspec test
#
# @return [true]
# when test is NOT successful
# when test is NOT successful
#
# @return [false]
# otherwise

View file

@ -4,7 +4,7 @@ module Mutant
class Method < self
include Adamantium::Flat, Equalizer.new(:identification)
# Methods within rbx kernel directory are precompiled and their source
# Methods within rbx kernel directory are precompiled and their source
# cannot be accessed via reading source location
BLACKLIST = /\Akernel\//.freeze
@ -17,7 +17,7 @@ module Mutant
# returns self when block given
#
# @api private
#
#
def each(&block)
return to_enum unless block_given?

View file

@ -1,6 +1,6 @@
module Mutant
class Matcher
class Method
class Method
# Matcher for instance methods
class Instance < self
SUBJECT_CLASS = Subject::Method::Instance

View file

@ -32,8 +32,8 @@ module Mutant
#
def match?(node)
node.class == Rubinius::AST::DefineSingleton &&
line?(node) &&
name?(node) &&
line?(node) &&
name?(node) &&
receiver?(node)
end
@ -66,7 +66,7 @@ module Mutant
# @api private
#
def name?(node)
node.body.name == method_name
node.body.name == method_name
end
# Test for receiver match

View file

@ -1,6 +1,6 @@
module Mutant
class Matcher
# Abstract base class for matcher that returns method subjects extracted from scope
# Abstract base class for matcher that returns method subjects extracted from scope
class Methods < self
include AbstractType, Equalizer.new(:scope)
@ -29,7 +29,7 @@ module Mutant
# @return [self]
# if block given
#
# @return [Enumerator<Subject>]
# @return [Enumerator<Subject>]
# otherwise
#
# @api private
@ -99,7 +99,7 @@ module Mutant
# Return method names
#
# @return [Enumerable<Symbol>]
# @return [Enumerable<Symbol>]
#
# @api private
#

View file

@ -36,7 +36,7 @@ module Mutant
private
# Initialize object space matcher
# Initialize object space matcher
#
# @param [Class, Module] namespace
#
@ -96,8 +96,8 @@ module Mutant
# @api private
#
def emit_scope(scope)
if pattern =~ scope.name
yield scope
if pattern =~ scope.name
yield scope
end
end
end

View file

@ -32,7 +32,7 @@ module Mutant
# @api private
#
def self.build(notation)
descendants.each do |descendant|
descendants.each do |descendant|
filter = descendant.handle(notation)
return filter if filter
end

View file

@ -1,6 +1,6 @@
module Mutant
class Mutation
class Filter
class Filter
# Mutation filter that filters on mutation codes
class Code < self
include Equalizer.new(:code)
@ -36,7 +36,7 @@ module Mutant
# @api private
#
def self.handle(notation)
match = PATTERN.match(notation)
match = PATTERN.match(notation)
return unless match
new(match[1])
end

View file

@ -23,7 +23,7 @@ module Mutant
mutation.defaults = nil
end
mutation
end
end
end
end

View file

@ -18,7 +18,7 @@ module Mutant
emit_attribute_mutations(:condition)
emit_attribute_mutations(:body) unless nil_literal?(:body)
emit_attribute_mutations(:else) unless nil_literal?(:else)
emit_inverted_condition
emit_inverted_condition
emit_deleted_if_branch
emit_deleted_else_branch
emit_true_if_branch
@ -43,7 +43,7 @@ module Mutant
# Emit inverted condition
#
# Especially the same like swap branches but more universal as it also
# Especially the same like swap branches but more universal as it also
# covers the case there is no else branch
#
# @return [undefined]

View file

@ -10,7 +10,7 @@ module Mutant
# Currently unhandled node classes. Feel free to contribute your mutator!
#
# FIXME: This list is mixed with some 1.8 only nodes that should be extracted
#
#
%w(
ZSuper
ElementAssignment
@ -50,7 +50,7 @@ module Mutant
).each do |name|
handle(Rubinius::AST.const_get(name))
end
private
# Emit mutations

View file

@ -16,14 +16,14 @@ module Mutant
# @api private
#
def dispatch
emit_receiver
emit_receiver
emit_implicit_self_receiver
emit_receiver_mutations
emit_block_mutations
emit_block_absence_mutation
end
# Emit receiver
# Emit receiver
#
# @return [undefined]
#
@ -52,7 +52,7 @@ module Mutant
# @api private
#
def emit_receiver_mutations
emit_attribute_mutations(:receiver)
emit_attribute_mutations(:receiver)
end
# Emit block absence mutation
@ -102,11 +102,11 @@ module Mutant
end
# Emit mutation that replaces explicit send to self with implicit send to self
#
#
# @example:
#
# # This class does use Foo#a with explicitly specifing the receiver self.
# # But an implicit (privately) call should be used as there is no need for
# # But an implicit (privately) call should be used as there is no need for
# # specifing en explicit receiver.
#
# class Foo # Mutation

View file

@ -5,7 +5,7 @@ module Mutant
# Mutator for send with arguments
class WithArguments < self
handle(Rubinius::AST::SendWithArguments)
private

View file

@ -18,7 +18,7 @@ module Mutant
emit_node(Rubinius::AST::ZSuper)
emit_without_block
emit_attribute_mutations(:block) if node.block
emit_attribute_mutations(:arguments)
emit_attribute_mutations(:arguments)
end
# Emit without block mutation

View file

@ -34,7 +34,7 @@ module Mutant
private
# Emit mutations
#
#
# @return [undefined]
#
# @api private
@ -54,7 +54,7 @@ module Mutant
private
# Emit mutations
#
#
# @return [undefined]
#
# @api private

View file

@ -118,14 +118,14 @@ module Mutant
self
end
private
private
# Return IO stream
#
# @return [IO]
#
# @api private
#
#
attr_reader :io
# Test for colored output
@ -200,7 +200,7 @@ module Mutant
#
# @return [true]
# returns true if output is a tty
#
#
# @return [false]
# returns false otherwise
#

View file

@ -61,7 +61,7 @@ module Mutant
protected
# Return counts
# Return counts
#
# @return [Hash]
#
@ -77,7 +77,7 @@ module Mutant
#
attr_reader :start
# Return killers
# Return killers
#
# @return [Hash]
#
@ -123,7 +123,7 @@ module Mutant
self
end
# Test for errors
# Test for errors
#
# @return [true]
# if there are errors

View file

@ -48,7 +48,7 @@ module Mutant
# otherwise
#
# @api private
#
#
abstract_method :success?
private

View file

@ -1,7 +1,7 @@
module Mutant
# Abstract base class for killing strategies
class Strategy
class Strategy
include AbstractType, Adamantium::Flat, Equalizer.new
# Return config

View file

@ -3,7 +3,7 @@ module Mutant
class Rspec
class DM2
# Example lookup for the rspec dm2
# Example lookup for the rspec dm2
class Lookup
include AbstractType, Adamantium::Flat, Equalizer.new(:subject)
@ -64,7 +64,7 @@ module Mutant
#
# @param [Subjecŧ] subject
#
# @return [Lookup]
# @return [Lookup]
#
# @api private
#

View file

@ -85,7 +85,7 @@ module Mutant
# @return [Source]
#
# @api private
#
#
def source
ToSource.to_source(node)
end

View file

@ -70,7 +70,7 @@ module Mutant
end
# Singleton method subjects
class Singleton < self
class Singleton < self
# Test if method is public
#

View file

@ -19,7 +19,7 @@ describe Mutant, 'method matching' do
let(:method_arity) { values.fetch(:method_arity) }
let(:scope) { values.fetch(:scope) }
let(:node_class) { values.fetch(:node_class) }
let(:node) { mutation_subject.node }
let(:context) { mutation_subject.context }
let(:mutation_subject) { subject.first }

View file

@ -6,4 +6,3 @@ module IceNine
end
end
end

View file

@ -8,7 +8,7 @@ module Rspec
# @api private
#
def self.nest
original_world, original_configuration =
original_world, original_configuration =
::RSpec.instance_variable_get(:@world),
::RSpec.instance_variable_get(:@configuration)

View file

@ -151,7 +151,7 @@ module Zombie
#
# @api private
#
# FIXME:
# FIXME:
# Yeah looks very ugly but im currently to exited to do a cleanup.
#
def self.files

View file

@ -2,7 +2,7 @@ require 'spec_helper'
shared_examples_for 'an invalid cli run' do
it 'should raise error' do
expect { subject }.to raise_error(Mutant::CLIParser::Error, expected_message)
expect { subject }.to raise_error(Mutant::CLIParser::Error, expected_message)
end
end
@ -61,7 +61,7 @@ describe Mutant::CLI, '.new' do
context 'with code filter and missing argument' do
let(:arguments) { %w(--rspec-unit --code) }
let(:expected_message) { '"--code" is missing an argument' }
let(:expected_message) { '"--code" is missing an argument' }
it_should_behave_like 'an invalid cli run'
end

View file

@ -10,7 +10,7 @@ describe Mutant::CLI, '.run' do
let(:config) { mock('Config') }
let(:instance) { mock(described_class.name, :config => config) }
before do
before do
described_class.stub(:new => instance)
Mutant::Runner::Config.stub(:run => runner)
end

View file

@ -5,7 +5,7 @@ describe Mutant::Context::Scope, '#root' do
let(:object) { described_class.new(TestApp::Literal, path) }
let(:path) { mock('Path') }
let(:node) { ':node'.to_ast }
let(:node) { ':node'.to_ast }
let(:scope) { subject.body }
let(:scope_body) { scope.body }

View file

@ -12,7 +12,7 @@ describe Mutant::Killer, '#success?' do
kill_state.stub(:freeze => kill_state, :dup => kill_state)
end
let(:class_under_test) do
let(:class_under_test) do
Class.new(described_class) do
def run
end

View file

@ -12,7 +12,7 @@ describe Mutant::Matcher::Chain, '#each' do
let(:subject_a) { mock('Subject A') }
let(:subject_b) { mock('Subject B') }
before do
matcher_a.stub(:each).and_yield(subject_a).and_return(matcher_a)
matcher_b.stub(:each).and_yield(subject_b).and_return(matcher_b)

View file

@ -4,7 +4,7 @@ describe Mutant::Matcher::Chain, '#matchers' do
subject { object.matchers }
let(:object) { described_class.new(matchers) }
let(:matchers) { mock('Matchers') }
let(:matchers) { mock('Matchers') }
it { should be(matchers) }

View file

@ -70,7 +70,7 @@ describe Mutant::Mutator, 'define' do
Mutant::Random.stub(:hex_string => 'random')
end
let(:mutations) do
let(:mutations) do
mutations = []
mutations << 'def foo(a); end'
mutations << 'def foo(); end'
@ -90,9 +90,9 @@ describe Mutant::Mutator, 'define' do
mutations = []
# Body presence mutations
mutations << 'def self.foo; bar; self.baz; end'
mutations << 'def self.foo; self.bar; baz; end'
mutations << 'def self.foo; bar; self.baz; end'
mutations << 'def self.foo; self.bar; baz; end'
# Body presence mutations
mutations << 'def self.foo; self.bar; end'
mutations << 'def self.foo; self.baz; end'

View file

@ -20,12 +20,12 @@ describe Mutant::Mutator, 'if statement' do
mutants << 'if self.condition; false end'
# mutations of body
mutants << 'if self.condition; false; else false; end'
mutants << 'if self.condition; nil; else false; end'
mutants << 'if self.condition; false; else false; end'
mutants << 'if self.condition; nil; else false; end'
# mutations of else body
mutants << 'if self.condition; true; else true; end'
mutants << 'if self.condition; true; else nil; end'
mutants << 'if self.condition; true; else true; end'
mutants << 'if self.condition; true; else nil; end'
# mutation of condition to always be true
mutants << 'if true; true; else false; end'

View file

@ -20,8 +20,8 @@ describe Mutant::Mutator::Node::Literal, 'hash' do
mutations << '{ true => true , false => nil }'
# Remove each key once
mutations << '{ true => true }'
mutations << '{ false => false }'
mutations << '{ true => true }'
mutations << '{ false => false }'
# Empty hash
mutations << '{}'

View file

@ -16,7 +16,7 @@ describe Mutant::Mutator, 'send' do
let(:mutations) do
mutations = []
# with implicit receiver (send privately)
mutations << 'foo'
mutations << 'foo'
end
it_should_behave_like 'a mutator'
@ -58,7 +58,7 @@ describe Mutant::Mutator, 'send' do
context 'with block' do
let(:source) { 'foo() { a; b }' }
let(:mutations) do
let(:mutations) do
mutations = []
mutations << 'foo() { a }'
mutations << 'foo() { b }'
@ -77,7 +77,7 @@ describe Mutant::Mutator, 'send' do
Mutant::Random.stub(:hex_string => :random)
end
let(:mutations) do
let(:mutations) do
mutations = []
mutations << 'foo'
mutations << 'foo { |a, b| Object.new }'
@ -99,7 +99,7 @@ describe Mutant::Mutator, 'send' do
let(:source) { 'foo { |(a, b), c| }' }
let(:mutations) do
let(:mutations) do
mutations = []
mutations << 'foo { || }'
mutations << 'foo { |a, b, c| }'
@ -120,7 +120,7 @@ describe Mutant::Mutator, 'send' do
context 'one argument' do
let(:source) { 'foo(nil)' }
let(:mutations) do
let(:mutations) do
mutations = []
mutations << 'foo'
mutations << 'nil'
@ -133,7 +133,7 @@ describe Mutant::Mutator, 'send' do
context 'with explicit self as receiver' do
let(:source) { 'self.foo(nil)' }
let(:mutations) do
let(:mutations) do
mutations = []
mutations << 'self.foo'
mutations << 'foo(nil)'
@ -149,7 +149,7 @@ describe Mutant::Mutator, 'send' do
context "with keyword #{keyword}" do
let(:source) { "foo.#{keyword}(nil)" }
let(:mutations) do
let(:mutations) do
mutations = []
mutations << "foo.#{keyword}"
mutations << "foo"
@ -166,7 +166,7 @@ describe Mutant::Mutator, 'send' do
Mutant::BINARY_METHOD_OPERATORS.each do |operator|
let(:source) { "true #{operator} false" }
let(:mutations) do
let(:mutations) do
mutations = []
mutations << "((false) #{operator} (false))"
mutations << "((nil) #{operator} (false))"
@ -183,7 +183,7 @@ describe Mutant::Mutator, 'send' do
context 'two arguments' do
let(:source) { 'foo(nil, nil)' }
let(:mutations) do
let(:mutations) do
mutations = []
mutations << 'foo()'
mutations << 'foo(nil)'

View file

@ -1,6 +1,6 @@
require 'spec_helper'
describe Mutant::Strategy::MethodExpansion, '.run' do
describe Mutant::Strategy::MethodExpansion, '.run' do
subject { object.run(name) }
let(:object) { described_class }

View file

@ -12,5 +12,3 @@ shared_examples_for 'a method filter parse result' do
subject
end
end

View file

@ -8,7 +8,7 @@ shared_examples_for 'a method match' do
let(:method_arity) { values.fetch(:method_arity) }
let(:scope) { values.fetch(:scope) }
let(:node_class) { values.fetch(:node_class) }
let(:node) { mutation_subject.node }
let(:context) { mutation_subject.context }
let(:mutation_subject) { subject.first }