mutant 0.9.4 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +121 -0
- data/Changelog.md +26 -0
- data/Gemfile +0 -15
- data/Gemfile.lock +47 -58
- data/Gemfile.shared +7 -0
- data/LICENSE +1 -1
- data/README.md +72 -23
- data/config/reek.yml +1 -0
- data/config/rubocop.yml +10 -3
- data/docs/commercial-support.md +14 -0
- data/lib/mutant.rb +5 -1
- data/lib/mutant/ast.rb +0 -9
- data/lib/mutant/ast/find_metaclass_containing.rb +48 -0
- data/lib/mutant/ast/meta/send.rb +0 -6
- data/lib/mutant/bootstrap.rb +0 -36
- data/lib/mutant/cli.rb +6 -50
- data/lib/mutant/color.rb +0 -3
- data/lib/mutant/config.rb +0 -8
- data/lib/mutant/context.rb +0 -3
- data/lib/mutant/diff.rb +0 -17
- data/lib/mutant/env.rb +0 -6
- data/lib/mutant/expression/method.rb +6 -6
- data/lib/mutant/expression/methods.rb +6 -6
- data/lib/mutant/expression/parser.rb +0 -6
- data/lib/mutant/integration.rb +0 -18
- data/lib/mutant/isolation/fork.rb +0 -22
- data/lib/mutant/license.rb +12 -1
- data/lib/mutant/matcher.rb +0 -14
- data/lib/mutant/matcher/config.rb +0 -11
- data/lib/mutant/matcher/method.rb +0 -31
- data/lib/mutant/matcher/method/instance.rb +0 -8
- data/lib/mutant/matcher/method/metaclass.rb +86 -0
- data/lib/mutant/matcher/method/singleton.rb +0 -25
- data/lib/mutant/matcher/methods.rb +17 -28
- data/lib/mutant/matcher/namespace.rb +0 -10
- data/lib/mutant/matcher/scope.rb +2 -4
- data/lib/mutant/meta.rb +1 -3
- data/lib/mutant/meta/example/dsl.rb +0 -21
- data/lib/mutant/meta/example/verification.rb +1 -21
- data/lib/mutant/mutation.rb +0 -3
- data/lib/mutant/mutator.rb +1 -29
- data/lib/mutant/mutator/node.rb +1 -66
- data/lib/mutant/mutator/node/and_asgn.rb +0 -3
- data/lib/mutant/mutator/node/argument.rb +0 -15
- data/lib/mutant/mutator/node/arguments.rb +0 -20
- data/lib/mutant/mutator/node/begin.rb +0 -3
- data/lib/mutant/mutator/node/binary.rb +0 -23
- data/lib/mutant/mutator/node/block.rb +0 -15
- data/lib/mutant/mutator/node/break.rb +0 -3
- data/lib/mutant/mutator/node/case.rb +0 -9
- data/lib/mutant/mutator/node/class.rb +0 -3
- data/lib/mutant/mutator/node/conditional_loop.rb +0 -3
- data/lib/mutant/mutator/node/const.rb +0 -3
- data/lib/mutant/mutator/node/define.rb +0 -11
- data/lib/mutant/mutator/node/defined.rb +0 -3
- data/lib/mutant/mutator/node/dstr.rb +0 -3
- data/lib/mutant/mutator/node/dsym.rb +0 -3
- data/lib/mutant/mutator/node/generic.rb +0 -51
- data/lib/mutant/mutator/node/if.rb +0 -12
- data/lib/mutant/mutator/node/index.rb +0 -27
- data/lib/mutant/mutator/node/kwbegin.rb +0 -3
- data/lib/mutant/mutator/node/literal.rb +0 -3
- data/lib/mutant/mutator/node/literal/array.rb +0 -6
- data/lib/mutant/mutator/node/literal/boolean.rb +0 -4
- data/lib/mutant/mutator/node/literal/float.rb +0 -9
- data/lib/mutant/mutator/node/literal/hash.rb +0 -9
- data/lib/mutant/mutator/node/literal/integer.rb +0 -9
- data/lib/mutant/mutator/node/literal/nil.rb +0 -3
- data/lib/mutant/mutator/node/literal/range.rb +0 -6
- data/lib/mutant/mutator/node/literal/regex.rb +0 -6
- data/lib/mutant/mutator/node/literal/string.rb +0 -3
- data/lib/mutant/mutator/node/literal/symbol.rb +0 -3
- data/lib/mutant/mutator/node/masgn.rb +0 -3
- data/lib/mutant/mutator/node/match_current_line.rb +0 -3
- data/lib/mutant/mutator/node/mlhs.rb +0 -3
- data/lib/mutant/mutator/node/named_value/access.rb +2 -14
- data/lib/mutant/mutator/node/named_value/constant_assignment.rb +0 -9
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -6
- data/lib/mutant/mutator/node/next.rb +0 -3
- data/lib/mutant/mutator/node/noop.rb +0 -3
- data/lib/mutant/mutator/node/nthref.rb +0 -3
- data/lib/mutant/mutator/node/op_asgn.rb +0 -3
- data/lib/mutant/mutator/node/or_asgn.rb +0 -3
- data/lib/mutant/mutator/node/procarg_zero.rb +0 -3
- data/lib/mutant/mutator/node/regopt.rb +0 -6
- data/lib/mutant/mutator/node/resbody.rb +0 -6
- data/lib/mutant/mutator/node/rescue.rb +2 -19
- data/lib/mutant/mutator/node/return.rb +0 -3
- data/lib/mutant/mutator/node/sclass.rb +20 -0
- data/lib/mutant/mutator/node/send.rb +3 -62
- data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -9
- data/lib/mutant/mutator/node/send/binary.rb +0 -11
- data/lib/mutant/mutator/node/send/conditional.rb +0 -3
- data/lib/mutant/mutator/node/splat.rb +0 -3
- data/lib/mutant/mutator/node/super.rb +0 -3
- data/lib/mutant/mutator/node/when.rb +0 -19
- data/lib/mutant/mutator/node/yield.rb +0 -3
- data/lib/mutant/mutator/node/zsuper.rb +0 -3
- data/lib/mutant/mutator/util/array.rb +0 -6
- data/lib/mutant/mutator/util/symbol.rb +0 -3
- data/lib/mutant/parallel.rb +0 -13
- data/lib/mutant/parallel/driver.rb +0 -10
- data/lib/mutant/parallel/worker.rb +0 -22
- data/lib/mutant/registry.rb +2 -7
- data/lib/mutant/reporter/cli.rb +0 -5
- data/lib/mutant/reporter/cli/format.rb +1 -10
- data/lib/mutant/reporter/cli/printer.rb +0 -40
- data/lib/mutant/reporter/cli/printer/env_progress.rb +0 -15
- data/lib/mutant/reporter/cli/printer/isolation_result.rb +0 -18
- data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -5
- data/lib/mutant/reporter/cli/printer/mutation_result.rb +0 -21
- data/lib/mutant/reporter/cli/printer/status_progressive.rb +0 -8
- data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -9
- data/lib/mutant/repository/diff.rb +1 -13
- data/lib/mutant/repository/diff/ranges.rb +0 -11
- data/lib/mutant/result.rb +0 -3
- data/lib/mutant/runner.rb +0 -18
- data/lib/mutant/runner/sink.rb +0 -5
- data/lib/mutant/subject.rb +0 -8
- data/lib/mutant/subject/method.rb +0 -3
- data/lib/mutant/subject/method/instance.rb +0 -5
- data/lib/mutant/subject/method/metaclass.rb +30 -0
- data/lib/mutant/transform.rb +0 -92
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant/warnings.rb +0 -6
- data/lib/mutant/zombifier.rb +4 -34
- data/meta/and.rb +0 -2
- data/meta/array.rb +0 -3
- data/meta/begin.rb +0 -3
- data/meta/block.rb +0 -3
- data/meta/break.rb +0 -1
- data/meta/case.rb +0 -6
- data/meta/casgn.rb +0 -3
- data/meta/cvasgn.rb +0 -1
- data/meta/def.rb +0 -7
- data/meta/ensure.rb +0 -1
- data/meta/false.rb +0 -1
- data/meta/gvasgn.rb +0 -1
- data/meta/hash.rb +0 -4
- data/meta/if.rb +0 -5
- data/meta/ivasgn.rb +0 -1
- data/meta/kwbegin.rb +0 -1
- data/meta/lvasgn.rb +0 -1
- data/meta/match_current_line.rb +0 -1
- data/meta/next.rb +0 -1
- data/meta/or.rb +0 -2
- data/meta/regexp.rb +0 -1
- data/meta/rescue.rb +0 -6
- data/meta/sclass.rb +12 -0
- data/meta/send.rb +0 -4
- data/meta/true.rb +0 -1
- data/meta/until.rb +0 -1
- data/meta/while.rb +0 -2
- data/meta/yield.rb +0 -1
- data/mutant.gemspec +4 -3
- data/mutant.sh +12 -0
- data/spec/integrations.yml +3 -1
- data/spec/support/corpus.rb +3 -3
- data/spec/support/ruby_vm.rb +1 -2
- data/spec/support/shared_context.rb +3 -3
- data/spec/support/xspec.rb +2 -2
- data/spec/unit/mutant/ast/find_metaclass_containing_spec.rb +64 -0
- data/spec/unit/mutant/expression/methods_spec.rb +7 -2
- data/spec/unit/mutant/license_spec.rb +17 -5
- data/spec/unit/mutant/matcher/method/metaclass_spec.rb +108 -0
- data/spec/unit/mutant/matcher/methods/metaclass_spec.rb +62 -0
- data/spec/unit/mutant/matcher/namespace_spec.rb +3 -1
- data/spec/unit/mutant/matcher/scope_spec.rb +11 -1
- data/spec/unit/mutant/meta/example_spec.rb +3 -3
- data/spec/unit/mutant/mutator/node_spec.rb +1 -6
- data/spec/unit/mutant/parallel/driver_spec.rb +4 -4
- data/spec/unit/mutant/parallel/worker_spec.rb +5 -5
- data/spec/unit/mutant/parallel_spec.rb +7 -7
- data/spec/unit/mutant/registry_spec.rb +52 -25
- data/spec/unit/mutant/repository/diff/ranges_spec.rb +2 -2
- data/spec/unit/mutant/subject/method/metaclass_spec.rb +63 -0
- data/test_app/lib/test_app.rb +1 -0
- data/test_app/lib/test_app/metaclasses.rb +108 -0
- metadata +43 -16
- data/.circleci/config.yml +0 -53
- data/lib/mutant/variable.rb +0 -282
- data/spec/unit/mutant/variable_spec.rb +0 -618
@@ -14,9 +14,6 @@ module Mutant
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
# Emit mutations
|
18
|
-
#
|
19
|
-
# @return [undefined]
|
20
17
|
def dispatch
|
21
18
|
emit_singletons
|
22
19
|
emit_receiver_mutations { |node| !n_nil?(node) }
|
@@ -26,9 +23,6 @@ module Mutant
|
|
26
23
|
mutate_indices
|
27
24
|
end
|
28
25
|
|
29
|
-
# Emit send forms
|
30
|
-
#
|
31
|
-
# @return [undefined]
|
32
26
|
def emit_send_forms
|
33
27
|
return if left_assignment?
|
34
28
|
|
@@ -37,9 +31,6 @@ module Mutant
|
|
37
31
|
end
|
38
32
|
end
|
39
33
|
|
40
|
-
# Emit mutation `foo[n..-1]` -> `foo.drop(n)`
|
41
|
-
#
|
42
|
-
# @return [undefined]
|
43
34
|
def emit_drop_mutation
|
44
35
|
return unless indices.one? && n_irange?(Mutant::Util.one(indices))
|
45
36
|
|
@@ -50,9 +41,6 @@ module Mutant
|
|
50
41
|
emit(s(:send, receiver, :drop, start))
|
51
42
|
end
|
52
43
|
|
53
|
-
# Mutate indices
|
54
|
-
#
|
55
|
-
# @return [undefined]
|
56
44
|
def mutate_indices
|
57
45
|
children_indices(index_range).each do |index|
|
58
46
|
emit_propagation(children.fetch(index)) unless left_assignment?
|
@@ -61,9 +49,6 @@ module Mutant
|
|
61
49
|
end
|
62
50
|
end
|
63
51
|
|
64
|
-
# The index nodes
|
65
|
-
#
|
66
|
-
# @return [Enumerable<Parser::AST::Node>]
|
67
52
|
def indices
|
68
53
|
children[index_range]
|
69
54
|
end
|
@@ -74,9 +59,6 @@ module Mutant
|
|
74
59
|
|
75
60
|
private
|
76
61
|
|
77
|
-
# The range index children can be found
|
78
|
-
#
|
79
|
-
# @return [Range]
|
80
62
|
def index_range
|
81
63
|
NO_VALUE_RANGE
|
82
64
|
end
|
@@ -92,9 +74,6 @@ module Mutant
|
|
92
74
|
|
93
75
|
private
|
94
76
|
|
95
|
-
# Emit mutations
|
96
|
-
#
|
97
|
-
# @return [undefined]
|
98
77
|
def dispatch
|
99
78
|
super()
|
100
79
|
|
@@ -105,16 +84,10 @@ module Mutant
|
|
105
84
|
mutate_child(children.length.pred)
|
106
85
|
end
|
107
86
|
|
108
|
-
# Emit index read
|
109
|
-
#
|
110
|
-
# @return [undefined]
|
111
87
|
def emit_index_read
|
112
88
|
emit(s(:index, receiver, *children[index_range]))
|
113
89
|
end
|
114
90
|
|
115
|
-
# Index indices
|
116
|
-
#
|
117
|
-
# @return [Range<Integer>]
|
118
91
|
def index_range
|
119
92
|
if left_assignment?
|
120
93
|
NO_VALUE_RANGE
|
@@ -13,9 +13,6 @@ module Mutant
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
# Emit mutations
|
17
|
-
#
|
18
|
-
# @return [undefined]
|
19
16
|
def dispatch
|
20
17
|
emit_singletons
|
21
18
|
emit_type
|
@@ -24,9 +21,6 @@ module Mutant
|
|
24
21
|
emit(first) unless n_splat?(first)
|
25
22
|
end
|
26
23
|
|
27
|
-
# Mutate body
|
28
|
-
#
|
29
|
-
# @return [undefined]
|
30
24
|
def mutate_body
|
31
25
|
children.each_index do |index|
|
32
26
|
dup_children = children.dup
|
@@ -11,9 +11,6 @@ module Mutant
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
# Emit mutations
|
15
|
-
#
|
16
|
-
# @return [undefined]
|
17
14
|
def dispatch
|
18
15
|
emit_singletons
|
19
16
|
emit_values
|
@@ -26,16 +23,10 @@ module Mutant
|
|
26
23
|
N_INFINITY
|
27
24
|
].freeze
|
28
25
|
|
29
|
-
# Emit special cases
|
30
|
-
#
|
31
|
-
# @return [undefined]
|
32
26
|
def emit_special_cases
|
33
27
|
SPECIAL.each(&method(:emit))
|
34
28
|
end
|
35
29
|
|
36
|
-
# Values to mutate to
|
37
|
-
#
|
38
|
-
# @return [Array]
|
39
30
|
def values
|
40
31
|
original = children.first
|
41
32
|
|
@@ -11,18 +11,12 @@ module Mutant
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
# Emit mutations
|
15
|
-
#
|
16
|
-
# @return [undefined]
|
17
14
|
def dispatch
|
18
15
|
emit_singletons
|
19
16
|
emit_type
|
20
17
|
mutate_body
|
21
18
|
end
|
22
19
|
|
23
|
-
# Mutate body
|
24
|
-
#
|
25
|
-
# @return [undefined]
|
26
20
|
def mutate_body
|
27
21
|
children.each_index do |index|
|
28
22
|
mutate_child(index)
|
@@ -41,9 +35,6 @@ module Mutant
|
|
41
35
|
|
42
36
|
private
|
43
37
|
|
44
|
-
# Emit mutations
|
45
|
-
#
|
46
|
-
# @return [undefined]
|
47
38
|
def dispatch
|
48
39
|
emit_key_mutations
|
49
40
|
emit_value_mutations
|
@@ -11,24 +11,15 @@ module Mutant
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
# Emit mutations
|
15
|
-
#
|
16
|
-
# @return [undefined]
|
17
14
|
def dispatch
|
18
15
|
emit_singletons
|
19
16
|
emit_values
|
20
17
|
end
|
21
18
|
|
22
|
-
# Values to mutate to
|
23
|
-
#
|
24
|
-
# @return [Array]
|
25
19
|
def values
|
26
20
|
[0, 1, -value, value + 1, value - 1]
|
27
21
|
end
|
28
22
|
|
29
|
-
# Literal original value
|
30
|
-
#
|
31
|
-
# @return [Object]
|
32
23
|
def value
|
33
24
|
value, = children
|
34
25
|
value
|
@@ -19,9 +19,6 @@ module Mutant
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
# Emit mutations
|
23
|
-
#
|
24
|
-
# @return [undefined]
|
25
22
|
def dispatch
|
26
23
|
emit_singletons
|
27
24
|
emit_inverse
|
@@ -29,9 +26,6 @@ module Mutant
|
|
29
26
|
emit_upper_bound_mutations
|
30
27
|
end
|
31
28
|
|
32
|
-
# Inverse node
|
33
|
-
#
|
34
|
-
# @return [Parser::AST::Node]
|
35
29
|
def emit_inverse
|
36
30
|
emit(s(MAP.fetch(node.type), *children))
|
37
31
|
end
|
@@ -14,16 +14,10 @@ module Mutant
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
# Original regexp options
|
18
|
-
#
|
19
|
-
# @return [Parser::AST::Node]
|
20
17
|
def options
|
21
18
|
children.last
|
22
19
|
end
|
23
20
|
|
24
|
-
# Emit mutations
|
25
|
-
#
|
26
|
-
# @return [undefined]
|
27
21
|
def dispatch
|
28
22
|
emit_singletons unless parent_node
|
29
23
|
children.each_with_index do |child, index|
|
@@ -12,9 +12,6 @@ module Mutant
|
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
# Emit mutations
|
16
|
-
#
|
17
|
-
# @return [undefined]
|
18
15
|
def dispatch
|
19
16
|
emit_singletons
|
20
17
|
end
|
@@ -27,26 +24,17 @@ module Mutant
|
|
27
24
|
|
28
25
|
children :name
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
# @return [undefined]
|
27
|
+
private
|
28
|
+
|
33
29
|
def dispatch
|
34
30
|
emit_attribute_read
|
35
31
|
super()
|
36
32
|
end
|
37
33
|
|
38
|
-
private
|
39
|
-
|
40
|
-
# Emit instance variable as attribute send
|
41
|
-
#
|
42
|
-
# @return [undefined]
|
43
34
|
def emit_attribute_read
|
44
35
|
emit(s(:send, nil, attribute_name))
|
45
36
|
end
|
46
37
|
|
47
|
-
# Variable name without leading '@'
|
48
|
-
#
|
49
|
-
# @return [Symbol]
|
50
38
|
def attribute_name
|
51
39
|
name.slice(NAME_RANGE).to_sym
|
52
40
|
end
|
@@ -14,9 +14,6 @@ module Mutant
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
# Emit mutations
|
18
|
-
#
|
19
|
-
# @return [undefined]
|
20
17
|
def dispatch
|
21
18
|
mutate_name
|
22
19
|
return unless value # op asgn
|
@@ -24,16 +21,10 @@ module Mutant
|
|
24
21
|
emit_remove_const
|
25
22
|
end
|
26
23
|
|
27
|
-
# Emit remove_const
|
28
|
-
#
|
29
|
-
# @return [undefined]
|
30
24
|
def emit_remove_const
|
31
25
|
emit(s(:send, cbase, :remove_const, s(:sym, name)))
|
32
26
|
end
|
33
27
|
|
34
|
-
# Emit name mutations
|
35
|
-
#
|
36
|
-
# @return [undefined]
|
37
28
|
def mutate_name
|
38
29
|
Util::Symbol.call(name).each do |name|
|
39
30
|
emit_name(name.upcase)
|
@@ -25,18 +25,12 @@ module Mutant
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
# Emit mutations
|
29
|
-
#
|
30
|
-
# @return [undefined]
|
31
28
|
def dispatch
|
32
29
|
emit_singletons
|
33
30
|
mutate_name
|
34
31
|
emit_value_mutations if value # op asgn!
|
35
32
|
end
|
36
33
|
|
37
|
-
# Emit name mutations
|
38
|
-
#
|
39
|
-
# @return [undefined]
|
40
34
|
def mutate_name
|
41
35
|
prefix, regexp = MAP.fetch(node.type)
|
42
36
|
stripped = name.to_s.sub(regexp, EMPTY_STRING)
|