mutant 0.5.19 → 0.5.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -21,8 +19,8 @@ module Mutant
|
|
21
19
|
#
|
22
20
|
def dispatch
|
23
21
|
emit_singletons
|
24
|
-
emit_left_mutations do |
|
25
|
-
!
|
22
|
+
emit_left_mutations do |node|
|
23
|
+
!n_self?(node)
|
26
24
|
end
|
27
25
|
emit_right_mutations
|
28
26
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -21,12 +19,11 @@ module Mutant
|
|
21
19
|
#
|
22
20
|
def dispatch
|
23
21
|
emit_singletons
|
24
|
-
unless left.type.equal?(:ivasgn)
|
25
|
-
emit_left_mutations do |mutation|
|
26
|
-
!mutation.type.equal?(:self)
|
27
|
-
end
|
28
|
-
end
|
29
22
|
emit_right_mutations
|
23
|
+
return if n_ivasgn?(left)
|
24
|
+
emit_left_mutations do |node|
|
25
|
+
!n_self?(node)
|
26
|
+
end
|
30
27
|
end
|
31
28
|
|
32
29
|
end # OrAsgn
|
@@ -33,7 +33,7 @@ module Mutant
|
|
33
33
|
def mutate_captures
|
34
34
|
return unless captures
|
35
35
|
Util::Array::Element.each(captures.children, self) do |matchers|
|
36
|
-
next if matchers.any?
|
36
|
+
next if matchers.any?(&method(:n_nil?))
|
37
37
|
emit_captures(s(:array, *matchers))
|
38
38
|
end
|
39
39
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -20,10 +18,9 @@ module Mutant
|
|
20
18
|
#
|
21
19
|
def dispatch
|
22
20
|
emit_singletons
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
21
|
+
return unless value
|
22
|
+
emit(value)
|
23
|
+
emit_value_mutations
|
27
24
|
end
|
28
25
|
|
29
26
|
end # Return
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -183,12 +181,20 @@ module Mutant
|
|
183
181
|
# @api private
|
184
182
|
#
|
185
183
|
def emit_implicit_self
|
186
|
-
if
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
184
|
+
emit_receiver(nil) if allow_implicit_self?
|
185
|
+
end
|
186
|
+
|
187
|
+
# Test if implicit self is allowed
|
188
|
+
#
|
189
|
+
# @return [Boolean]
|
190
|
+
#
|
191
|
+
# @api private
|
192
|
+
#
|
193
|
+
def allow_implicit_self?
|
194
|
+
n_self?(receiver) &&
|
195
|
+
!KEYWORDS.include?(selector) &&
|
196
|
+
!attribute_assignment? &&
|
197
|
+
!OP_ASSIGN.include?(parent_type)
|
192
198
|
end
|
193
199
|
|
194
200
|
# Test for assignment
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -22,7 +20,7 @@ module Mutant
|
|
22
20
|
emit(left)
|
23
21
|
emit_left_mutations
|
24
22
|
emit_selector_replacement
|
25
|
-
emit(right) unless right
|
23
|
+
emit(right) unless n_splat?(right)
|
26
24
|
emit_right_mutations
|
27
25
|
end
|
28
26
|
|
data/lib/mutant/mutator/util.rb
CHANGED
data/lib/mutant/node_helpers.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
# Mixin for node helpers
|
5
3
|
module NodeHelpers
|
@@ -44,5 +42,16 @@ module Mutant
|
|
44
42
|
s(:send, node, :!)
|
45
43
|
end
|
46
44
|
|
45
|
+
NODE_TYPES.each do |type|
|
46
|
+
fail "method: #{type} is already defined" if instance_methods(true).include?(type)
|
47
|
+
|
48
|
+
name = "n_#{type.to_s.sub(/\??\z/, '?')}"
|
49
|
+
|
50
|
+
define_method(name) do |node|
|
51
|
+
node.type.equal?(type)
|
52
|
+
end
|
53
|
+
private name
|
54
|
+
end
|
55
|
+
|
47
56
|
end # NodeHelpers
|
48
57
|
end # Mutant
|
data/lib/mutant/reporter.rb
CHANGED
data/lib/mutant/reporter/cli.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Reporter
|
5
3
|
class CLI
|
@@ -52,20 +50,22 @@ module Mutant
|
|
52
50
|
handle(Mutant::Mutation::Evil)
|
53
51
|
handle(Mutant::Mutation::Neutral)
|
54
52
|
|
53
|
+
DIFF_ERROR_MESSAGE = 'BUG: Mutation NOT resulted in exactly one diff. Please report a reproduction'.freeze
|
54
|
+
|
55
55
|
private
|
56
56
|
|
57
57
|
# Run report printer
|
58
58
|
#
|
59
|
-
# @return [
|
59
|
+
# @return [String]
|
60
60
|
#
|
61
61
|
# @api private
|
62
62
|
#
|
63
63
|
def details
|
64
64
|
original, current = object.original_source, object.source
|
65
65
|
diff = Mutant::Diff.build(original, current)
|
66
|
-
color? ? diff.colorized_diff : diff.diff
|
66
|
+
diff = color? ? diff.colorized_diff : diff.diff
|
67
|
+
diff || DIFF_ERROR_MESSAGE
|
67
68
|
end
|
68
|
-
|
69
69
|
end # Diff
|
70
70
|
end # Mutation
|
71
71
|
|
data/lib/mutant/reporter/null.rb
CHANGED
data/lib/mutant/runner.rb
CHANGED
data/lib/mutant/runner/config.rb
CHANGED
data/lib/mutant/strategy.rb
CHANGED
data/lib/mutant/subject.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Subject
|
5
3
|
class Method
|
@@ -32,7 +30,7 @@ module Mutant
|
|
32
30
|
#
|
33
31
|
def prepare
|
34
32
|
expected_warnings =
|
35
|
-
if name.equal?(:initialize)
|
33
|
+
if RUBY_ENGINE.eql?('ruby') && name.equal?(:initialize)
|
36
34
|
["#{__FILE__}:#{__LINE__ + 5}: warning: undefining `initialize' may cause serious problems\n"]
|
37
35
|
else
|
38
36
|
[]
|