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
data/lib/mutant/mutator/node.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
|
5
3
|
# Generator for mutations
|
@@ -119,12 +117,11 @@ module Mutant
|
|
119
117
|
# @api private
|
120
118
|
#
|
121
119
|
def mutate_child(index, mutator = Mutator, &block)
|
122
|
-
block ||=
|
120
|
+
block ||= ->(_node) { true }
|
123
121
|
child = children.at(index)
|
124
122
|
mutator.each(child, self) do |mutation|
|
125
|
-
|
126
|
-
|
127
|
-
end
|
123
|
+
next unless block.call(mutation)
|
124
|
+
emit_child_update(index, mutation)
|
128
125
|
end
|
129
126
|
end
|
130
127
|
|
@@ -166,7 +163,7 @@ module Mutant
|
|
166
163
|
# @api private
|
167
164
|
#
|
168
165
|
def emit_type(*children)
|
169
|
-
emit(
|
166
|
+
emit(Parser::AST::Node.new(node.type, children))
|
170
167
|
end
|
171
168
|
|
172
169
|
# Emit singleton literals
|
@@ -200,16 +197,6 @@ module Mutant
|
|
200
197
|
emit(N_NIL) unless asgn_left?
|
201
198
|
end
|
202
199
|
|
203
|
-
# Return new self typed child
|
204
|
-
#
|
205
|
-
# @return [Parser::AST::Node]
|
206
|
-
#
|
207
|
-
# @api private
|
208
|
-
#
|
209
|
-
def new_self(*children)
|
210
|
-
Parser::AST::Node.new(node.type, children)
|
211
|
-
end
|
212
|
-
|
213
200
|
# Emit values
|
214
201
|
#
|
215
202
|
# @param [Array<Object>] values
|
@@ -224,6 +211,20 @@ module Mutant
|
|
224
211
|
end
|
225
212
|
end
|
226
213
|
|
214
|
+
# Return parent node
|
215
|
+
#
|
216
|
+
# @return [Parser::AST::Node] node
|
217
|
+
# if parent with node is presnet
|
218
|
+
#
|
219
|
+
# @return [nil]
|
220
|
+
# otherwise
|
221
|
+
#
|
222
|
+
# @api private
|
223
|
+
#
|
224
|
+
def parent_node
|
225
|
+
parent.node if parent
|
226
|
+
end
|
227
|
+
|
227
228
|
# Return parent type
|
228
229
|
#
|
229
230
|
# @return [Symbol] type
|
@@ -235,7 +236,7 @@ module Mutant
|
|
235
236
|
# @api private
|
236
237
|
#
|
237
238
|
def parent_type
|
238
|
-
|
239
|
+
parent_node.type if parent_node
|
239
240
|
end
|
240
241
|
|
241
242
|
# Test if the node is the left of an or_asgn or op_asgn
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -21,14 +19,13 @@ 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
|
29
27
|
|
30
|
-
end #
|
28
|
+
end # AndAsgn
|
31
29
|
end # Node
|
32
30
|
end # Mutator
|
33
31
|
end # Mutant
|
34
|
-
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -17,10 +15,55 @@ module Mutant
|
|
17
15
|
# @api private
|
18
16
|
#
|
19
17
|
def dispatch
|
20
|
-
|
18
|
+
emit_argument_presence
|
19
|
+
emit_argument_mutations
|
21
20
|
emit_mlhs_expansion
|
22
21
|
end
|
23
22
|
|
23
|
+
# Emit argument presence mutation
|
24
|
+
#
|
25
|
+
# @return [undefined]
|
26
|
+
#
|
27
|
+
# @api private
|
28
|
+
#
|
29
|
+
def emit_argument_presence
|
30
|
+
emit_type
|
31
|
+
Mutator::Util::Array::Presence.each(children, self) do |children|
|
32
|
+
emit_type(*children)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Emit argument mutations
|
37
|
+
#
|
38
|
+
# @return [undefined]
|
39
|
+
#
|
40
|
+
# @api private
|
41
|
+
#
|
42
|
+
def emit_argument_mutations
|
43
|
+
children.each_with_index do |child, index|
|
44
|
+
Mutator.each(child) do |mutant|
|
45
|
+
next if invalid_argument_replacement?(mutant, index)
|
46
|
+
emit_child_update(index, mutant)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Test if child mutation is allowed
|
52
|
+
#
|
53
|
+
# @param [Parser::AST::Node]
|
54
|
+
#
|
55
|
+
# @return [Boolean]
|
56
|
+
#
|
57
|
+
# @api private
|
58
|
+
#
|
59
|
+
def invalid_argument_replacement?(mutant, index)
|
60
|
+
original = children.fetch(index)
|
61
|
+
|
62
|
+
n_optarg?(original) &&
|
63
|
+
n_arg?(mutant) &&
|
64
|
+
children[0...index].any?(&method(:n_optarg?))
|
65
|
+
end
|
66
|
+
|
24
67
|
# Emit mlhs expansions
|
25
68
|
#
|
26
69
|
# @return [undefined]
|
@@ -44,7 +87,7 @@ module Mutant
|
|
44
87
|
#
|
45
88
|
def mlhs_childs_with_index
|
46
89
|
children.each_with_index.select do |child, _index|
|
47
|
-
child
|
90
|
+
n_mlhs?(child)
|
48
91
|
end
|
49
92
|
end
|
50
93
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -23,7 +21,7 @@ module Mutant
|
|
23
21
|
end
|
24
22
|
children.each_with_index do |child, index|
|
25
23
|
mutate_child(index)
|
26
|
-
emit(child)
|
24
|
+
emit(child) unless children.eql?([child])
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
@@ -36,13 +34,8 @@ module Mutant
|
|
36
34
|
# @api private
|
37
35
|
#
|
38
36
|
def emit_child_subset(children)
|
39
|
-
|
40
|
-
|
41
|
-
when 1
|
42
|
-
emit(children.first)
|
43
|
-
else
|
44
|
-
emit_type(*children)
|
45
|
-
end
|
37
|
+
return if children.length < 2
|
38
|
+
emit_type(*children)
|
46
39
|
end
|
47
40
|
|
48
41
|
end # Block
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -50,10 +48,9 @@ module Mutant
|
|
50
48
|
def emit_else_mutations
|
51
49
|
else_branch = children.last
|
52
50
|
else_index = children.length - 1
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
51
|
+
return unless else_branch
|
52
|
+
mutate_child(else_index)
|
53
|
+
emit_child_update(else_index, nil)
|
57
54
|
end
|
58
55
|
|
59
56
|
end # Case
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -18,7 +16,7 @@ module Mutant
|
|
18
16
|
# @api private
|
19
17
|
#
|
20
18
|
def dispatch
|
21
|
-
emit_singletons unless
|
19
|
+
emit_singletons unless parent_node && n_const?(parent_node)
|
22
20
|
emit_type(nil, *children.drop(1))
|
23
21
|
children.each_with_index do |child, index|
|
24
22
|
mutate_child(index) if child.kind_of?(Parser::AST::Node)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -33,9 +31,9 @@ module Mutant
|
|
33
31
|
#
|
34
32
|
def mutate_condition
|
35
33
|
emit_condition_mutations do |condition|
|
36
|
-
!
|
34
|
+
!n_self?(condition)
|
37
35
|
end
|
38
|
-
emit_type(n_not(condition), if_branch, else_branch) unless condition
|
36
|
+
emit_type(n_not(condition), if_branch, else_branch) unless n_match_current_line?(condition)
|
39
37
|
emit_type(N_TRUE, if_branch, else_branch)
|
40
38
|
emit_type(N_FALSE, if_branch, else_branch)
|
41
39
|
end
|
@@ -48,10 +46,9 @@ module Mutant
|
|
48
46
|
#
|
49
47
|
def mutate_if_branch
|
50
48
|
emit_type(condition, else_branch, nil) if else_branch
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
49
|
+
return unless if_branch
|
50
|
+
emit_if_branch_mutations
|
51
|
+
emit_type(condition, if_branch, nil)
|
55
52
|
end
|
56
53
|
|
57
54
|
# Emit else branch mutations
|
@@ -61,10 +58,9 @@ module Mutant
|
|
61
58
|
# @api private
|
62
59
|
#
|
63
60
|
def mutate_else_branch
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
61
|
+
return unless else_branch
|
62
|
+
emit_else_branch_mutations
|
63
|
+
emit_type(condition, nil, else_branch)
|
68
64
|
end
|
69
65
|
|
70
66
|
end # If
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -21,9 +19,8 @@ module Mutant
|
|
21
19
|
emit_singletons
|
22
20
|
emit_type
|
23
21
|
mutate_body
|
24
|
-
|
25
|
-
|
26
|
-
end
|
22
|
+
return unless children.one?
|
23
|
+
emit(children.first)
|
27
24
|
end
|
28
25
|
|
29
26
|
# Mutate body
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Mutant
|
4
2
|
class Mutator
|
5
3
|
class Node
|
@@ -31,9 +29,9 @@ module Mutant
|
|
31
29
|
# @api private
|
32
30
|
#
|
33
31
|
def dispatch
|
34
|
-
emit_singletons unless
|
32
|
+
emit_singletons unless parent_node && n_match_current_line?(parent_node)
|
35
33
|
children.each_with_index do |child, index|
|
36
|
-
mutate_child(index) unless child
|
34
|
+
mutate_child(index) unless n_str?(child)
|
37
35
|
end
|
38
36
|
emit_type(options)
|
39
37
|
emit_type(s(:str, NULL_REGEXP_SOURCE), options)
|