mutant 0.9.4 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +121 -0
  3. data/Changelog.md +26 -0
  4. data/Gemfile +0 -15
  5. data/Gemfile.lock +47 -58
  6. data/Gemfile.shared +7 -0
  7. data/LICENSE +1 -1
  8. data/README.md +72 -23
  9. data/config/reek.yml +1 -0
  10. data/config/rubocop.yml +10 -3
  11. data/docs/commercial-support.md +14 -0
  12. data/lib/mutant.rb +5 -1
  13. data/lib/mutant/ast.rb +0 -9
  14. data/lib/mutant/ast/find_metaclass_containing.rb +48 -0
  15. data/lib/mutant/ast/meta/send.rb +0 -6
  16. data/lib/mutant/bootstrap.rb +0 -36
  17. data/lib/mutant/cli.rb +6 -50
  18. data/lib/mutant/color.rb +0 -3
  19. data/lib/mutant/config.rb +0 -8
  20. data/lib/mutant/context.rb +0 -3
  21. data/lib/mutant/diff.rb +0 -17
  22. data/lib/mutant/env.rb +0 -6
  23. data/lib/mutant/expression/method.rb +6 -6
  24. data/lib/mutant/expression/methods.rb +6 -6
  25. data/lib/mutant/expression/parser.rb +0 -6
  26. data/lib/mutant/integration.rb +0 -18
  27. data/lib/mutant/isolation/fork.rb +0 -22
  28. data/lib/mutant/license.rb +12 -1
  29. data/lib/mutant/matcher.rb +0 -14
  30. data/lib/mutant/matcher/config.rb +0 -11
  31. data/lib/mutant/matcher/method.rb +0 -31
  32. data/lib/mutant/matcher/method/instance.rb +0 -8
  33. data/lib/mutant/matcher/method/metaclass.rb +86 -0
  34. data/lib/mutant/matcher/method/singleton.rb +0 -25
  35. data/lib/mutant/matcher/methods.rb +17 -28
  36. data/lib/mutant/matcher/namespace.rb +0 -10
  37. data/lib/mutant/matcher/scope.rb +2 -4
  38. data/lib/mutant/meta.rb +1 -3
  39. data/lib/mutant/meta/example/dsl.rb +0 -21
  40. data/lib/mutant/meta/example/verification.rb +1 -21
  41. data/lib/mutant/mutation.rb +0 -3
  42. data/lib/mutant/mutator.rb +1 -29
  43. data/lib/mutant/mutator/node.rb +1 -66
  44. data/lib/mutant/mutator/node/and_asgn.rb +0 -3
  45. data/lib/mutant/mutator/node/argument.rb +0 -15
  46. data/lib/mutant/mutator/node/arguments.rb +0 -20
  47. data/lib/mutant/mutator/node/begin.rb +0 -3
  48. data/lib/mutant/mutator/node/binary.rb +0 -23
  49. data/lib/mutant/mutator/node/block.rb +0 -15
  50. data/lib/mutant/mutator/node/break.rb +0 -3
  51. data/lib/mutant/mutator/node/case.rb +0 -9
  52. data/lib/mutant/mutator/node/class.rb +0 -3
  53. data/lib/mutant/mutator/node/conditional_loop.rb +0 -3
  54. data/lib/mutant/mutator/node/const.rb +0 -3
  55. data/lib/mutant/mutator/node/define.rb +0 -11
  56. data/lib/mutant/mutator/node/defined.rb +0 -3
  57. data/lib/mutant/mutator/node/dstr.rb +0 -3
  58. data/lib/mutant/mutator/node/dsym.rb +0 -3
  59. data/lib/mutant/mutator/node/generic.rb +0 -51
  60. data/lib/mutant/mutator/node/if.rb +0 -12
  61. data/lib/mutant/mutator/node/index.rb +0 -27
  62. data/lib/mutant/mutator/node/kwbegin.rb +0 -3
  63. data/lib/mutant/mutator/node/literal.rb +0 -3
  64. data/lib/mutant/mutator/node/literal/array.rb +0 -6
  65. data/lib/mutant/mutator/node/literal/boolean.rb +0 -4
  66. data/lib/mutant/mutator/node/literal/float.rb +0 -9
  67. data/lib/mutant/mutator/node/literal/hash.rb +0 -9
  68. data/lib/mutant/mutator/node/literal/integer.rb +0 -9
  69. data/lib/mutant/mutator/node/literal/nil.rb +0 -3
  70. data/lib/mutant/mutator/node/literal/range.rb +0 -6
  71. data/lib/mutant/mutator/node/literal/regex.rb +0 -6
  72. data/lib/mutant/mutator/node/literal/string.rb +0 -3
  73. data/lib/mutant/mutator/node/literal/symbol.rb +0 -3
  74. data/lib/mutant/mutator/node/masgn.rb +0 -3
  75. data/lib/mutant/mutator/node/match_current_line.rb +0 -3
  76. data/lib/mutant/mutator/node/mlhs.rb +0 -3
  77. data/lib/mutant/mutator/node/named_value/access.rb +2 -14
  78. data/lib/mutant/mutator/node/named_value/constant_assignment.rb +0 -9
  79. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -6
  80. data/lib/mutant/mutator/node/next.rb +0 -3
  81. data/lib/mutant/mutator/node/noop.rb +0 -3
  82. data/lib/mutant/mutator/node/nthref.rb +0 -3
  83. data/lib/mutant/mutator/node/op_asgn.rb +0 -3
  84. data/lib/mutant/mutator/node/or_asgn.rb +0 -3
  85. data/lib/mutant/mutator/node/procarg_zero.rb +0 -3
  86. data/lib/mutant/mutator/node/regopt.rb +0 -6
  87. data/lib/mutant/mutator/node/resbody.rb +0 -6
  88. data/lib/mutant/mutator/node/rescue.rb +2 -19
  89. data/lib/mutant/mutator/node/return.rb +0 -3
  90. data/lib/mutant/mutator/node/sclass.rb +20 -0
  91. data/lib/mutant/mutator/node/send.rb +3 -62
  92. data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -9
  93. data/lib/mutant/mutator/node/send/binary.rb +0 -11
  94. data/lib/mutant/mutator/node/send/conditional.rb +0 -3
  95. data/lib/mutant/mutator/node/splat.rb +0 -3
  96. data/lib/mutant/mutator/node/super.rb +0 -3
  97. data/lib/mutant/mutator/node/when.rb +0 -19
  98. data/lib/mutant/mutator/node/yield.rb +0 -3
  99. data/lib/mutant/mutator/node/zsuper.rb +0 -3
  100. data/lib/mutant/mutator/util/array.rb +0 -6
  101. data/lib/mutant/mutator/util/symbol.rb +0 -3
  102. data/lib/mutant/parallel.rb +0 -13
  103. data/lib/mutant/parallel/driver.rb +0 -10
  104. data/lib/mutant/parallel/worker.rb +0 -22
  105. data/lib/mutant/registry.rb +2 -7
  106. data/lib/mutant/reporter/cli.rb +0 -5
  107. data/lib/mutant/reporter/cli/format.rb +1 -10
  108. data/lib/mutant/reporter/cli/printer.rb +0 -40
  109. data/lib/mutant/reporter/cli/printer/env_progress.rb +0 -15
  110. data/lib/mutant/reporter/cli/printer/isolation_result.rb +0 -18
  111. data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -5
  112. data/lib/mutant/reporter/cli/printer/mutation_result.rb +0 -21
  113. data/lib/mutant/reporter/cli/printer/status_progressive.rb +0 -8
  114. data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -9
  115. data/lib/mutant/repository/diff.rb +1 -13
  116. data/lib/mutant/repository/diff/ranges.rb +0 -11
  117. data/lib/mutant/result.rb +0 -3
  118. data/lib/mutant/runner.rb +0 -18
  119. data/lib/mutant/runner/sink.rb +0 -5
  120. data/lib/mutant/subject.rb +0 -8
  121. data/lib/mutant/subject/method.rb +0 -3
  122. data/lib/mutant/subject/method/instance.rb +0 -5
  123. data/lib/mutant/subject/method/metaclass.rb +30 -0
  124. data/lib/mutant/transform.rb +0 -92
  125. data/lib/mutant/version.rb +1 -1
  126. data/lib/mutant/warnings.rb +0 -6
  127. data/lib/mutant/zombifier.rb +4 -34
  128. data/meta/and.rb +0 -2
  129. data/meta/array.rb +0 -3
  130. data/meta/begin.rb +0 -3
  131. data/meta/block.rb +0 -3
  132. data/meta/break.rb +0 -1
  133. data/meta/case.rb +0 -6
  134. data/meta/casgn.rb +0 -3
  135. data/meta/cvasgn.rb +0 -1
  136. data/meta/def.rb +0 -7
  137. data/meta/ensure.rb +0 -1
  138. data/meta/false.rb +0 -1
  139. data/meta/gvasgn.rb +0 -1
  140. data/meta/hash.rb +0 -4
  141. data/meta/if.rb +0 -5
  142. data/meta/ivasgn.rb +0 -1
  143. data/meta/kwbegin.rb +0 -1
  144. data/meta/lvasgn.rb +0 -1
  145. data/meta/match_current_line.rb +0 -1
  146. data/meta/next.rb +0 -1
  147. data/meta/or.rb +0 -2
  148. data/meta/regexp.rb +0 -1
  149. data/meta/rescue.rb +0 -6
  150. data/meta/sclass.rb +12 -0
  151. data/meta/send.rb +0 -4
  152. data/meta/true.rb +0 -1
  153. data/meta/until.rb +0 -1
  154. data/meta/while.rb +0 -2
  155. data/meta/yield.rb +0 -1
  156. data/mutant.gemspec +4 -3
  157. data/mutant.sh +12 -0
  158. data/spec/integrations.yml +3 -1
  159. data/spec/support/corpus.rb +3 -3
  160. data/spec/support/ruby_vm.rb +1 -2
  161. data/spec/support/shared_context.rb +3 -3
  162. data/spec/support/xspec.rb +2 -2
  163. data/spec/unit/mutant/ast/find_metaclass_containing_spec.rb +64 -0
  164. data/spec/unit/mutant/expression/methods_spec.rb +7 -2
  165. data/spec/unit/mutant/license_spec.rb +17 -5
  166. data/spec/unit/mutant/matcher/method/metaclass_spec.rb +108 -0
  167. data/spec/unit/mutant/matcher/methods/metaclass_spec.rb +62 -0
  168. data/spec/unit/mutant/matcher/namespace_spec.rb +3 -1
  169. data/spec/unit/mutant/matcher/scope_spec.rb +11 -1
  170. data/spec/unit/mutant/meta/example_spec.rb +3 -3
  171. data/spec/unit/mutant/mutator/node_spec.rb +1 -6
  172. data/spec/unit/mutant/parallel/driver_spec.rb +4 -4
  173. data/spec/unit/mutant/parallel/worker_spec.rb +5 -5
  174. data/spec/unit/mutant/parallel_spec.rb +7 -7
  175. data/spec/unit/mutant/registry_spec.rb +52 -25
  176. data/spec/unit/mutant/repository/diff/ranges_spec.rb +2 -2
  177. data/spec/unit/mutant/subject/method/metaclass_spec.rb +63 -0
  178. data/test_app/lib/test_app.rb +1 -0
  179. data/test_app/lib/test_app/metaclasses.rb +108 -0
  180. metadata +43 -16
  181. data/.circleci/config.yml +0 -53
  182. data/lib/mutant/variable.rb +0 -282
  183. 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
@@ -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
  super()
19
16
  emit_singletons
@@ -9,9 +9,6 @@ module Mutant
9
9
 
10
10
  private
11
11
 
12
- # Emit values
13
- #
14
- # @return [undefined]
15
12
  def emit_values
16
13
  values.each(&method(:emit_type))
17
14
  end
@@ -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
@@ -16,11 +16,7 @@ module Mutant
16
16
 
17
17
  handle(*MAP.keys)
18
18
 
19
- # Emit mutations
20
- #
21
- # @return [undefined]
22
19
  def dispatch
23
- emit_nil
24
20
  emit(s(MAP.fetch(node.type)))
25
21
  end
26
22
 
@@ -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
@@ -11,9 +11,6 @@ module Mutant
11
11
 
12
12
  private
13
13
 
14
- # Emit mutations
15
- #
16
- # @return [undefined]
17
14
  def dispatch; end
18
15
 
19
16
  end # Nil
@@ -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|
@@ -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
  end
@@ -15,9 +15,6 @@ module Mutant
15
15
 
16
16
  private
17
17
 
18
- # Emit mutations
19
- #
20
- # @return [undefined]
21
18
  def dispatch
22
19
  emit_singletons
23
20
  Util::Symbol.call(value).each(&method(:emit_type))
@@ -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
  end
@@ -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
  emit_regexp_mutations
@@ -10,9 +10,6 @@ module Mutant
10
10
 
11
11
  private
12
12
 
13
- # Emit mutations
14
- #
15
- # @return [undefined]
16
13
  def dispatch
17
14
  mutate_single_child do |_child, index|
18
15
  delete_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
- # Emit mutations
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)
@@ -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
  super()
19
16
  emit_singletons
@@ -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
  # noop
19
16
  end
@@ -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
  unless number.equal?(1)
20
17
  emit_number(number - 1)
@@ -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_left_mutations do |node|