mutant 0.5.19 → 0.5.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -4
- data/Changelog.md +9 -0
- data/Gemfile.devtools +15 -11
- data/README.md +10 -6
- data/config/flay.yml +1 -1
- data/config/reek.yml +3 -1
- data/lib/mutant.rb +41 -41
- data/lib/mutant/cache.rb +0 -2
- data/lib/mutant/cli.rb +6 -8
- data/lib/mutant/color.rb +0 -2
- data/lib/mutant/config.rb +0 -2
- data/lib/mutant/context.rb +0 -2
- data/lib/mutant/context/scope.rb +0 -2
- data/lib/mutant/delegator.rb +2 -0
- data/lib/mutant/diff.rb +4 -16
- data/lib/mutant/expression.rb +8 -7
- data/lib/mutant/expression/method.rb +3 -9
- data/lib/mutant/isolation.rb +65 -0
- data/lib/mutant/killer.rb +1 -3
- data/lib/mutant/loader.rb +0 -2
- data/lib/mutant/matcher.rb +0 -2
- data/lib/mutant/matcher/chain.rb +0 -2
- data/lib/mutant/matcher/filter.rb +0 -2
- data/lib/mutant/matcher/method.rb +1 -2
- data/lib/mutant/matcher/method/finder.rb +0 -2
- data/lib/mutant/matcher/method/instance.rb +1 -3
- data/lib/mutant/matcher/method/singleton.rb +0 -2
- data/lib/mutant/matcher/methods.rb +0 -2
- data/lib/mutant/matcher/namespace.rb +2 -6
- data/lib/mutant/matcher/null.rb +0 -2
- data/lib/mutant/matcher/scope.rb +0 -2
- data/lib/mutant/meta/example.rb +57 -18
- data/lib/mutant/meta/example/dsl.rb +10 -13
- data/lib/mutant/mutation.rb +0 -2
- data/lib/mutant/mutation/evil.rb +0 -2
- data/lib/mutant/mutation/neutral.rb +0 -2
- data/lib/mutant/mutator.rb +4 -31
- data/lib/mutant/mutator/node.rb +19 -18
- data/lib/mutant/mutator/node/and_asgn.rb +3 -6
- data/lib/mutant/mutator/node/argument.rb +0 -2
- data/lib/mutant/mutator/node/arguments.rb +47 -4
- data/lib/mutant/mutator/node/begin.rb +3 -10
- data/lib/mutant/mutator/node/binary.rb +0 -2
- data/lib/mutant/mutator/node/block.rb +0 -2
- data/lib/mutant/mutator/node/blockarg.rb +0 -2
- data/lib/mutant/mutator/node/break.rb +0 -2
- data/lib/mutant/mutator/node/case.rb +3 -6
- data/lib/mutant/mutator/node/conditional_loop.rb +0 -2
- data/lib/mutant/mutator/node/const.rb +1 -3
- data/lib/mutant/mutator/node/define.rb +0 -2
- data/lib/mutant/mutator/node/defined.rb +1 -3
- data/lib/mutant/mutator/node/dstr.rb +0 -2
- data/lib/mutant/mutator/node/dsym.rb +0 -2
- data/lib/mutant/mutator/node/generic.rb +0 -2
- data/lib/mutant/mutator/node/if.rb +8 -12
- data/lib/mutant/mutator/node/kwbegin.rb +0 -2
- data/lib/mutant/mutator/node/literal.rb +0 -2
- data/lib/mutant/mutator/node/literal/array.rb +2 -5
- data/lib/mutant/mutator/node/literal/boolean.rb +0 -2
- data/lib/mutant/mutator/node/literal/fixnum.rb +0 -2
- data/lib/mutant/mutator/node/literal/float.rb +0 -2
- data/lib/mutant/mutator/node/literal/hash.rb +0 -2
- data/lib/mutant/mutator/node/literal/nil.rb +0 -2
- data/lib/mutant/mutator/node/literal/range.rb +0 -2
- data/lib/mutant/mutator/node/literal/regex.rb +2 -4
- data/lib/mutant/mutator/node/literal/string.rb +0 -2
- data/lib/mutant/mutator/node/literal/symbol.rb +0 -2
- data/lib/mutant/mutator/node/masgn.rb +0 -2
- data/lib/mutant/mutator/node/mlhs.rb +0 -2
- data/lib/mutant/mutator/node/named_value/access.rb +0 -2
- data/lib/mutant/mutator/node/named_value/constant_assignment.rb +0 -2
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -2
- data/lib/mutant/mutator/node/next.rb +0 -3
- data/lib/mutant/mutator/node/noop.rb +0 -2
- data/lib/mutant/mutator/node/nthref.rb +0 -2
- data/lib/mutant/mutator/node/op_asgn.rb +2 -4
- data/lib/mutant/mutator/node/or_asgn.rb +4 -7
- data/lib/mutant/mutator/node/resbody.rb +1 -1
- data/lib/mutant/mutator/node/rescue.rb +0 -2
- data/lib/mutant/mutator/node/restarg.rb +0 -2
- data/lib/mutant/mutator/node/return.rb +3 -6
- data/lib/mutant/mutator/node/send.rb +14 -8
- data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -2
- data/lib/mutant/mutator/node/send/binary.rb +1 -3
- data/lib/mutant/mutator/node/splat.rb +0 -2
- data/lib/mutant/mutator/node/super.rb +0 -2
- data/lib/mutant/mutator/node/when.rb +0 -2
- data/lib/mutant/mutator/node/yield.rb +0 -2
- data/lib/mutant/mutator/node/zsuper.rb +0 -2
- data/lib/mutant/mutator/registry.rb +0 -2
- data/lib/mutant/mutator/util.rb +0 -2
- data/lib/mutant/mutator/util/array.rb +0 -2
- data/lib/mutant/mutator/util/symbol.rb +0 -2
- data/lib/mutant/node_helpers.rb +11 -2
- data/lib/mutant/reporter.rb +0 -2
- data/lib/mutant/reporter/cli.rb +0 -2
- data/lib/mutant/reporter/cli/printer.rb +0 -2
- data/lib/mutant/reporter/cli/progress.rb +0 -2
- data/lib/mutant/reporter/cli/report.rb +0 -2
- data/lib/mutant/reporter/cli/report/config.rb +0 -2
- data/lib/mutant/reporter/cli/report/mutation.rb +5 -5
- data/lib/mutant/reporter/cli/report/subject.rb +0 -2
- data/lib/mutant/reporter/null.rb +0 -2
- data/lib/mutant/runner.rb +0 -2
- data/lib/mutant/runner/config.rb +0 -2
- data/lib/mutant/runner/mutation.rb +0 -2
- data/lib/mutant/runner/subject.rb +0 -2
- data/lib/mutant/strategy.rb +0 -2
- data/lib/mutant/subject.rb +0 -2
- data/lib/mutant/subject/method.rb +0 -2
- data/lib/mutant/subject/method/instance.rb +1 -3
- data/lib/mutant/subject/method/singleton.rb +0 -2
- data/lib/mutant/version.rb +1 -3
- data/lib/mutant/zombifier.rb +0 -2
- data/meta/begin.rb +10 -0
- data/meta/case.rb +0 -2
- data/meta/def.rb +19 -0
- data/mutant-rspec.gemspec +1 -1
- data/mutant.gemspec +1 -1
- data/spec/integration/mutant/corpus_spec.rb +81 -22
- data/spec/integration/mutant/null_spec.rb +1 -3
- data/spec/integration/mutant/rspec_spec.rb +6 -8
- data/spec/integration/mutant/test_mutator_handles_types_spec.rb +0 -2
- data/spec/integration/mutant/zombie_spec.rb +0 -2
- data/spec/integrations.yml +12 -1
- data/spec/shared/method_matcher_behavior.rb +0 -2
- data/spec/spec_helper.rb +0 -2
- data/spec/support/compress_helper.rb +0 -2
- data/spec/support/ice_nine_config.rb +0 -2
- data/spec/support/rspec.rb +0 -2
- data/spec/support/test_app.rb +0 -2
- data/spec/unit/mutant/cli_new_spec.rb +0 -2
- data/spec/unit/mutant/cli_run_spec.rb +0 -2
- data/spec/unit/mutant/context/root_spec.rb +0 -2
- data/spec/unit/mutant/context/scope/root_spec.rb +0 -2
- data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +0 -2
- data/spec/unit/mutant/diff_spec.rb +0 -2
- data/spec/unit/mutant/expression/method_spec.rb +2 -4
- data/spec/unit/mutant/expression/namespace/flat_spec.rb +1 -3
- data/spec/unit/mutant/expression/namespace/recursive_spec.rb +10 -6
- data/spec/unit/mutant/isolation_spec.rb +61 -0
- data/spec/unit/mutant/loader/eval_spec.rb +0 -2
- data/spec/unit/mutant/matcher/chain_spec.rb +4 -15
- data/spec/unit/mutant/matcher/method/instance_spec.rb +0 -2
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +0 -2
- data/spec/unit/mutant/matcher/methods/instance_spec.rb +0 -2
- data/spec/unit/mutant/matcher/methods/singleton_spec.rb +0 -2
- data/spec/unit/mutant/matcher/namespace_spec.rb +33 -31
- data/spec/unit/mutant/mutation_spec.rb +0 -2
- data/spec/unit/mutant/runner/config_spec.rb +0 -2
- data/spec/unit/mutant/runner/mutation_spec.rb +0 -2
- data/spec/unit/mutant/runner/subject_spec.rb +0 -2
- data/spec/unit/mutant/strategy_spec.rb +0 -2
- data/spec/unit/mutant/subject/context_spec.rb +0 -2
- data/spec/unit/mutant/subject/mutations_spec.rb +0 -2
- data/spec/unit/mutant/subject/node_spec.rb +0 -2
- data/spec/unit/mutant/subject_spec.rb +0 -2
- data/spec/unit/mutant/warning_filter_spec.rb +6 -0
- data/spec/unit/mutant_spec.rb +0 -55
- data/test_app/Gemfile.devtools +15 -11
- data/test_app/Gemfile.rspec3 +2 -2
- metadata +7 -7
- data/lib/mutant/constants.rb +0 -45
- data/spec/unit/mutant/mutator_spec.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2423eb3dea806c37511ba8f9e23e20215330d9a5
|
4
|
+
data.tar.gz: b5c6e0e92cc025a1d70f61727567d3ccd64578c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0afc928d562d4f8adc32e1b1f7ba6c20544ee1c5e304c60772ab1fe5e7d648549a8e8b3c325ee7d828cc285f7083eb649d0344b90fb81c0b42f60cb78152034b
|
7
|
+
data.tar.gz: a7d05e7b132dc61673c683630de8a503496167521e57e9b7e0c3d86e7049bd979f7201772af5d9e1b3bfc8980731373480725193c6f93afc89aafd084cd023f8
|
data/.travis.yml
CHANGED
data/Changelog.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# v0.5.20 2014-06-15
|
2
|
+
|
3
|
+
* Remove support for matchers prefixed with ::
|
4
|
+
* Fix cases where mutated source diff was empty #198
|
5
|
+
* Fix mutate to simpler primitive violation break to next #203
|
6
|
+
* Improve integration / corpus tests to spot highlevel regressions on CI level.
|
7
|
+
|
8
|
+
* Remove support for matchers prefixed with ::
|
9
|
+
|
1
10
|
# v0.5.19 2014-06-06
|
2
11
|
|
3
12
|
Changes:
|
data/Gemfile.devtools
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
group :development do
|
4
|
-
gem 'rake', '~> 10.3.
|
5
|
-
gem 'rspec', '~> 2.99.0
|
6
|
-
gem 'rspec-core', '~> 2.99.0
|
4
|
+
gem 'rake', '~> 10.3.2'
|
5
|
+
gem 'rspec', '~> 2.99.0'
|
6
|
+
gem 'rspec-core', '~> 2.99.0'
|
7
7
|
gem 'yard', '~> 0.8.7.4'
|
8
8
|
|
9
9
|
platform :rbx do
|
@@ -11,30 +11,34 @@ group :development do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
group :yard do
|
15
|
+
gem 'kramdown', '~> 1.3.3'
|
16
|
+
end
|
17
|
+
|
14
18
|
group :guard do
|
15
|
-
gem 'guard', '~> 2.6.
|
19
|
+
gem 'guard', '~> 2.6.1'
|
16
20
|
gem 'guard-bundler', '~> 2.0.0'
|
17
|
-
gem 'guard-rspec', '~> 4.2.
|
21
|
+
gem 'guard-rspec', '~> 4.2.9'
|
18
22
|
gem 'guard-rubocop', '~> 1.1.0'
|
19
23
|
|
20
24
|
# file system change event handling
|
21
|
-
gem 'listen', '~> 2.7.
|
25
|
+
gem 'listen', '~> 2.7.7'
|
22
26
|
gem 'rb-fchange', '~> 0.0.6', require: false
|
23
27
|
gem 'rb-fsevent', '~> 0.9.4', require: false
|
24
|
-
gem 'rb-inotify', '~> 0.9.
|
28
|
+
gem 'rb-inotify', '~> 0.9.5', require: false
|
25
29
|
|
26
30
|
# notification handling
|
27
|
-
gem 'libnotify', '~> 0.8.
|
31
|
+
gem 'libnotify', '~> 0.8.3', require: false
|
28
32
|
gem 'rb-notifu', '~> 0.0.4', require: false
|
29
33
|
gem 'terminal-notifier-guard', '~> 1.5.3', require: false
|
30
34
|
end
|
31
35
|
|
32
36
|
group :metrics do
|
33
37
|
gem 'coveralls', '~> 0.7.0'
|
34
|
-
gem 'flay', '~> 2.
|
35
|
-
gem 'flog', '~> 4.2.
|
38
|
+
gem 'flay', '~> 2.5.0'
|
39
|
+
gem 'flog', '~> 4.2.1'
|
36
40
|
gem 'reek', '~> 1.3.7'
|
37
|
-
gem 'rubocop', '~> 0.
|
41
|
+
gem 'rubocop', '~> 0.23.0'
|
38
42
|
gem 'simplecov', '~> 0.7.1'
|
39
43
|
gem 'yardstick', '~> 0.9.9'
|
40
44
|
|
data/README.md
CHANGED
@@ -5,6 +5,8 @@ mutant
|
|
5
5
|
[![Dependency Status](https://gemnasium.com/mbj/mutant.png)](https://gemnasium.com/mbj/mutant)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/mbj/mutant.png)](https://codeclimate.com/github/mbj/mutant)
|
7
7
|
[![Inline docs](http://inch-ci.org/github/mbj/mutant.png)](http://inch-ci.org/github/mbj/mutant)
|
8
|
+
[![Gem Version](https://img.shields.io/gem/v/mutant.svg)](https://rubygems.org/gems/mutant)
|
9
|
+
[![Gittip](https://img.shields.io/gittip/mbj.svg)](https://gittip.com/mbj)
|
8
10
|
|
9
11
|
Mutant is a mutation testing tool for ruby.
|
10
12
|
|
@@ -115,13 +117,13 @@ Examples
|
|
115
117
|
```
|
116
118
|
cd virtus
|
117
119
|
# Run mutant on virtus namespace
|
118
|
-
mutant --include lib --require virtus --use rspec
|
120
|
+
mutant --include lib --require virtus --use rspec Virtus*
|
119
121
|
# Run mutant on specific virtus class
|
120
|
-
mutant --include lib --require virtus --use rspec
|
122
|
+
mutant --include lib --require virtus --use rspec Virtus::Attribute
|
121
123
|
# Run mutant on specific virtus class method
|
122
|
-
mutant --include lib --require virtus --use rspec
|
124
|
+
mutant --include lib --require virtus --use rspec Virtus::Attribute.build
|
123
125
|
# Run mutant on specific virtus instance method
|
124
|
-
mutant --include lib --require virtus --use rspec
|
126
|
+
mutant --include lib --require virtus --use rspec Virtus::Attribute#type
|
125
127
|
```
|
126
128
|
|
127
129
|
Subjects
|
@@ -151,8 +153,10 @@ Donations
|
|
151
153
|
I ([mbj](https://github.com/mbj)) build this and adjacent tools in my free time.
|
152
154
|
LOTS of unaccounted time and fun already went into this project.
|
153
155
|
|
154
|
-
You might consider to donate
|
155
|
-
|
156
|
+
You might consider to donate if you like this tool.
|
157
|
+
|
158
|
+
* [![Gittip](https://img.shields.io/gittip/mbj.svg)](https://gittip.com/mbj)
|
159
|
+
* [![Flattr this](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/1823010/mbjmutant-on-GitHub)
|
156
160
|
|
157
161
|
Support
|
158
162
|
-------
|
data/config/flay.yml
CHANGED
data/config/reek.yml
CHANGED
@@ -56,6 +56,7 @@ NestedIterators:
|
|
56
56
|
- Mutant::CLI#parse
|
57
57
|
- Mutant::Mutator::Util::Array::Element#dispatch
|
58
58
|
- Mutant::Mutator::Node::Resbody#mutate_captures
|
59
|
+
- Mutant::Mutator::Node::Arguments#emit_argument_mutations
|
59
60
|
- Mutant::Reporter::CLI::Report::Config#generic_stats
|
60
61
|
- Mutant::RequireHighjack#infect
|
61
62
|
- Mutant::RequireHighjack#desinfect
|
@@ -88,12 +89,13 @@ TooManyMethods:
|
|
88
89
|
- Mutant::CLI
|
89
90
|
- Mutant::Mutator::Node
|
90
91
|
- Mutant::Reporter::CLI
|
92
|
+
- Mutant::Meta::Example::Verification
|
91
93
|
max_methods: 10
|
92
94
|
TooManyStatements:
|
93
95
|
enabled: true
|
94
96
|
exclude:
|
95
97
|
- Mutant#self.singleton_subclass_instance
|
96
|
-
- Mutant#self.
|
98
|
+
- Mutant::Isolation#self.call
|
97
99
|
- Mutant::Rspec::Killer#run
|
98
100
|
- Mutant::Reporter::CLI#colorized_diff
|
99
101
|
- Mutant::Reporter::CLI::Report::Config#run
|
data/lib/mutant.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'stringio'
|
4
2
|
require 'set'
|
5
3
|
require 'adamantium'
|
@@ -26,6 +24,45 @@ module Mutant
|
|
26
24
|
# The frozen empty array used within mutant
|
27
25
|
EMPTY_ARRAY = [].freeze
|
28
26
|
|
27
|
+
symbolset = ->(strings) { strings.map(&:to_sym).to_set.freeze }
|
28
|
+
|
29
|
+
SCOPE_OPERATOR = '::'.freeze
|
30
|
+
|
31
|
+
# Set of nodes that cannot be on the LHS of an assignment
|
32
|
+
NOT_ASSIGNABLE = symbolset.(%w[int float str dstr class module self nil])
|
33
|
+
# Set of op-assign types
|
34
|
+
OP_ASSIGN = symbolset.call(%w[or_asgn and_asgn op_asgn])
|
35
|
+
# Set of node types that are not valid when emitted standalone
|
36
|
+
NOT_STANDALONE = symbolset.(%w[splat restarg block_pass])
|
37
|
+
INDEX_OPERATORS = symbolset.(%w[[] []=])
|
38
|
+
UNARY_METHOD_OPERATORS = symbolset.(%w[~@ +@ -@ !])
|
39
|
+
|
40
|
+
# Operators ruby implementeds as methods
|
41
|
+
METHOD_OPERATORS = symbolset.(%w[
|
42
|
+
<=> === []= [] <= >= == !~ != =~ <<
|
43
|
+
>> ** * % / | ^ & < > + - ~@ +@ -@ !
|
44
|
+
])
|
45
|
+
|
46
|
+
BINARY_METHOD_OPERATORS = (
|
47
|
+
METHOD_OPERATORS - (INDEX_OPERATORS + UNARY_METHOD_OPERATORS)
|
48
|
+
).to_set.freeze
|
49
|
+
|
50
|
+
OPERATOR_METHODS = (
|
51
|
+
METHOD_OPERATORS + INDEX_OPERATORS + UNARY_METHOD_OPERATORS
|
52
|
+
).to_set.freeze
|
53
|
+
|
54
|
+
# Nodes that are NOT handled by mutant.
|
55
|
+
#
|
56
|
+
# not - 1.8 only, mutant does not support 1.8
|
57
|
+
#
|
58
|
+
NODE_BLACKLIST = symbolset.(%w[not])
|
59
|
+
|
60
|
+
# Nodes that are NOT generated by parser but used by mutant / unparser.
|
61
|
+
NODE_EXTRA = symbolset.(%w[empty])
|
62
|
+
|
63
|
+
# All node types mutant handles
|
64
|
+
NODE_TYPES = ((Parser::Meta::NODE_TYPES + NODE_EXTRA) - NODE_BLACKLIST).to_set.freeze
|
65
|
+
|
29
66
|
# Lookup constant for location
|
30
67
|
#
|
31
68
|
# @param [String] location
|
@@ -35,7 +72,7 @@ module Mutant
|
|
35
72
|
# @api private
|
36
73
|
#
|
37
74
|
def self.constant_lookup(location)
|
38
|
-
location.
|
75
|
+
location.split(SCOPE_OPERATOR).reduce(Object) do |parent, name|
|
39
76
|
parent.const_get(name, nil)
|
40
77
|
end
|
41
78
|
end
|
@@ -51,43 +88,6 @@ module Mutant
|
|
51
88
|
self
|
52
89
|
end
|
53
90
|
|
54
|
-
IsolationError = Class.new(RuntimeError)
|
55
|
-
|
56
|
-
# Call block in isolation
|
57
|
-
#
|
58
|
-
# This isolation implements the fork strategy.
|
59
|
-
# Future strategies will probably use a process pool that can
|
60
|
-
# handle multiple mutation kills, in-isolation at once.
|
61
|
-
#
|
62
|
-
# @return [Object]
|
63
|
-
#
|
64
|
-
# @api private
|
65
|
-
#
|
66
|
-
def self.isolate(&block)
|
67
|
-
reader, writer = IO.pipe.each(&:binmode)
|
68
|
-
|
69
|
-
pid = fork do
|
70
|
-
reader.close
|
71
|
-
writer.write(Marshal.dump(block.call))
|
72
|
-
end
|
73
|
-
|
74
|
-
writer.close
|
75
|
-
|
76
|
-
begin
|
77
|
-
data = Marshal.load(reader.read)
|
78
|
-
rescue ArgumentError
|
79
|
-
raise IsolationError, 'Childprocess wrote un-unmarshallable data'
|
80
|
-
end
|
81
|
-
|
82
|
-
status = Process.waitpid2(pid).last
|
83
|
-
|
84
|
-
unless status.exitstatus.zero?
|
85
|
-
raise IsolationError, "Childprocess exited with nonzero exit status: #{status.exitstatus}"
|
86
|
-
end
|
87
|
-
|
88
|
-
data
|
89
|
-
end
|
90
|
-
|
91
91
|
# Define instance of subclassed superclass as constant
|
92
92
|
#
|
93
93
|
# @param [Class] superclass
|
@@ -120,9 +120,9 @@ require 'mutant/delegator'
|
|
120
120
|
require 'mutant/node_helpers'
|
121
121
|
require 'mutant/warning_filter'
|
122
122
|
require 'mutant/warning_expectation'
|
123
|
-
require 'mutant/constants'
|
124
123
|
require 'mutant/walker'
|
125
124
|
require 'mutant/require_highjack'
|
125
|
+
require 'mutant/isolation'
|
126
126
|
require 'mutant/mutator'
|
127
127
|
require 'mutant/mutation'
|
128
128
|
require 'mutant/mutation/evil'
|
data/lib/mutant/cache.rb
CHANGED
data/lib/mutant/cli.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'optparse'
|
4
2
|
|
5
3
|
module Mutant
|
@@ -120,9 +118,7 @@ module Mutant
|
|
120
118
|
# @api private
|
121
119
|
#
|
122
120
|
def subject_selector
|
123
|
-
if @subject_selectors.any?
|
124
|
-
Morpher::Evaluator::Predicate::Boolean::Or.new(@subject_selectors)
|
125
|
-
end
|
121
|
+
Morpher::Evaluator::Predicate::Boolean::Or.new(@subject_selectors) if @subject_selectors.any?
|
126
122
|
end
|
127
123
|
|
128
124
|
# Return predicate
|
@@ -153,6 +149,10 @@ module Mutant
|
|
153
149
|
# Return subject rejector
|
154
150
|
#
|
155
151
|
# @return [#call]
|
152
|
+
# if there is a subject rejector
|
153
|
+
#
|
154
|
+
# @return [nil]
|
155
|
+
# otherwise
|
156
156
|
#
|
157
157
|
# @api private
|
158
158
|
#
|
@@ -161,9 +161,7 @@ module Mutant
|
|
161
161
|
Morpher.compile(s(:eql, s(:attribute, :identification), s(:static, subject.identification)))
|
162
162
|
end
|
163
163
|
|
164
|
-
if rejectors.any?
|
165
|
-
Morpher::Evaluator::Predicate::Boolean::Or.new(rejectors)
|
166
|
-
end
|
164
|
+
Morpher::Evaluator::Predicate::Boolean::Or.new(rejectors) if rejectors.any?
|
167
165
|
end
|
168
166
|
end
|
169
167
|
|
data/lib/mutant/color.rb
CHANGED
data/lib/mutant/config.rb
CHANGED
data/lib/mutant/context.rb
CHANGED
data/lib/mutant/context/scope.rb
CHANGED
data/lib/mutant/delegator.rb
CHANGED
data/lib/mutant/diff.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
# Class to create diffs from source code
|
5
3
|
class Diff
|
@@ -8,7 +6,7 @@ module Mutant
|
|
8
6
|
# Return source diff
|
9
7
|
#
|
10
8
|
# @return [String]
|
11
|
-
# if there is
|
9
|
+
# if there is exactly one diff
|
12
10
|
#
|
13
11
|
# @return [nil]
|
14
12
|
# otherwise
|
@@ -16,19 +14,9 @@ module Mutant
|
|
16
14
|
# @api private
|
17
15
|
#
|
18
16
|
def diff
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
when 1
|
23
|
-
::Diff::LCS::Hunk.new(old, new, diffs.first, max_length, 0)
|
24
|
-
.diff(:unified) << "\n"
|
25
|
-
else
|
26
|
-
$stderr.puts(
|
27
|
-
'Mutation resulted in more than one diff, should not happen! ' \
|
28
|
-
'PLS report a bug!'
|
29
|
-
)
|
30
|
-
nil
|
31
|
-
end
|
17
|
+
return unless diffs.length.equal?(1)
|
18
|
+
::Diff::LCS::Hunk.new(old, new, diffs.first, max_length, 0)
|
19
|
+
.diff(:unified) << "\n"
|
32
20
|
end
|
33
21
|
memoize :diff
|
34
22
|
|
data/lib/mutant/expression.rb
CHANGED
@@ -13,16 +13,16 @@ module Mutant
|
|
13
13
|
*OPERATOR_METHODS.map(&:to_s)
|
14
14
|
).freeze
|
15
15
|
|
16
|
-
SCOPE_PATTERN =
|
17
|
-
(?:#{SCOPE_OPERATOR})?#{SCOPE_NAME_PATTERN}
|
18
|
-
(?:#{SCOPE_OPERATOR}#{SCOPE_NAME_PATTERN})*
|
19
|
-
/x.freeze
|
16
|
+
SCOPE_PATTERN = /#{SCOPE_NAME_PATTERN}(?:#{SCOPE_OPERATOR}#{SCOPE_NAME_PATTERN})*/.freeze
|
20
17
|
|
21
18
|
REGISTRY = {}
|
22
19
|
|
23
20
|
# Initialize expression
|
24
21
|
#
|
25
22
|
# @param [MatchData] match
|
23
|
+
#
|
24
|
+
# @api private
|
25
|
+
#
|
26
26
|
def initialize(*)
|
27
27
|
super
|
28
28
|
@syntax = match.to_s
|
@@ -42,6 +42,8 @@ module Mutant
|
|
42
42
|
#
|
43
43
|
# @return [Fixnum]
|
44
44
|
#
|
45
|
+
# @api private
|
46
|
+
#
|
45
47
|
def match_length(neddle)
|
46
48
|
if eql?(neddle)
|
47
49
|
syntax.length
|
@@ -99,9 +101,8 @@ module Mutant
|
|
99
101
|
def self.expressions(input)
|
100
102
|
REGISTRY.each_with_object([]) do |(regexp, klass), expressions|
|
101
103
|
match = regexp.match(input)
|
102
|
-
|
103
|
-
|
104
|
-
end
|
104
|
+
next unless match
|
105
|
+
expressions << klass.new(match)
|
105
106
|
end
|
106
107
|
end
|
107
108
|
private_class_method :expressions
|
@@ -9,15 +9,9 @@ module Mutant
|
|
9
9
|
'#' => Matcher::Methods::Instance
|
10
10
|
}.freeze
|
11
11
|
|
12
|
-
|
13
|
-
\
|
14
|
-
|
15
|
-
(?<scope_symbol>[.#])
|
16
|
-
(?<method_name>#{METHOD_NAME_PATTERN})
|
17
|
-
\z
|
18
|
-
/x.freeze
|
19
|
-
|
20
|
-
register(regexp)
|
12
|
+
register(
|
13
|
+
/\A(?<scope_name>#{SCOPE_PATTERN})(?<scope_symbol>[.#])(?<method_name>#{METHOD_NAME_PATTERN})\z/
|
14
|
+
)
|
21
15
|
|
22
16
|
# Return method matcher
|
23
17
|
#
|