mutant 0.2.20 → 0.3.0.beta2

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.
Files changed (201) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +10 -11
  3. data/Changelog.md +93 -38
  4. data/Gemfile +3 -1
  5. data/Gemfile.devtools +16 -20
  6. data/Guardfile +1 -1
  7. data/README.md +36 -16
  8. data/Rakefile +21 -2
  9. data/TODO +11 -7
  10. data/bin/mutant +4 -0
  11. data/bin/zombie +4 -0
  12. data/config/devtools.yml +2 -0
  13. data/config/flay.yml +2 -2
  14. data/config/flog.yml +1 -1
  15. data/config/{site.reek → reek.yml} +94 -70
  16. data/lib/mutant/cli/classifier/method.rb +100 -0
  17. data/lib/mutant/cli/classifier/namespace.rb +47 -0
  18. data/lib/mutant/cli/classifier/scope.rb +35 -0
  19. data/lib/mutant/cli/classifier.rb +141 -0
  20. data/lib/mutant/cli.rb +115 -162
  21. data/lib/mutant/color.rb +2 -2
  22. data/lib/mutant/config.rb +27 -0
  23. data/lib/mutant/constants.rb +32 -17
  24. data/lib/mutant/context/scope.rb +33 -51
  25. data/lib/mutant/context.rb +8 -19
  26. data/lib/mutant/differ.rb +5 -5
  27. data/lib/mutant/helper.rb +2 -17
  28. data/lib/mutant/killer/forked.rb +44 -0
  29. data/lib/mutant/killer/forking.rb +3 -57
  30. data/lib/mutant/killer/rspec.rb +16 -20
  31. data/lib/mutant/killer/static.rb +6 -7
  32. data/lib/mutant/killer.rb +48 -74
  33. data/lib/mutant/loader.rb +6 -6
  34. data/lib/mutant/matcher/chain.rb +4 -25
  35. data/lib/mutant/matcher/method/instance.rb +14 -24
  36. data/lib/mutant/matcher/method/singleton.rb +35 -46
  37. data/lib/mutant/matcher/method.rb +95 -83
  38. data/lib/mutant/matcher/{scope_methods.rb → methods.rb} +53 -76
  39. data/lib/mutant/matcher/namespace.rb +71 -0
  40. data/lib/mutant/matcher/scope.rb +34 -0
  41. data/lib/mutant/matcher.rb +24 -34
  42. data/lib/mutant/mutation/evil.rb +35 -0
  43. data/lib/mutant/mutation/filter/code.rb +7 -28
  44. data/lib/mutant/mutation/filter/regexp.rb +6 -18
  45. data/lib/mutant/mutation/filter/whitelist.rb +5 -4
  46. data/lib/mutant/mutation/filter.rb +10 -9
  47. data/lib/mutant/mutation/neutral.rb +35 -0
  48. data/lib/mutant/mutation.rb +21 -61
  49. data/lib/mutant/mutator/node/argument.rb +88 -0
  50. data/lib/mutant/mutator/node/arguments.rb +52 -0
  51. data/lib/mutant/mutator/node/assignment.rb +34 -38
  52. data/lib/mutant/mutator/node/begin.rb +33 -0
  53. data/lib/mutant/mutator/node/block.rb +14 -14
  54. data/lib/mutant/mutator/node/case.rb +59 -0
  55. data/lib/mutant/mutator/node/define.rb +26 -22
  56. data/lib/mutant/mutator/node/if.rb +31 -71
  57. data/lib/mutant/mutator/node/literal/array.rb +25 -9
  58. data/lib/mutant/mutator/node/literal/boolean.rb +13 -30
  59. data/lib/mutant/mutator/node/literal/dynamic.rb +6 -5
  60. data/lib/mutant/mutator/node/literal/fixnum.rb +18 -7
  61. data/lib/mutant/mutator/node/literal/float.rb +15 -8
  62. data/lib/mutant/mutator/node/literal/hash.rb +33 -52
  63. data/lib/mutant/mutator/node/literal/nil.rb +8 -7
  64. data/lib/mutant/mutator/node/literal/range.rb +25 -50
  65. data/lib/mutant/mutator/node/literal/regex.rb +15 -23
  66. data/lib/mutant/mutator/node/literal/string.rb +7 -6
  67. data/lib/mutant/mutator/node/literal/symbol.rb +7 -6
  68. data/lib/mutant/mutator/node/literal.rb +4 -46
  69. data/lib/mutant/mutator/node/mlhs.rb +27 -0
  70. data/lib/mutant/mutator/node/noop.rb +18 -43
  71. data/lib/mutant/mutator/node/return.rb +8 -8
  72. data/lib/mutant/mutator/node/send/binary.rb +31 -0
  73. data/lib/mutant/mutator/node/send.rb +106 -72
  74. data/lib/mutant/mutator/node/super.rb +15 -20
  75. data/lib/mutant/mutator/node/when.rb +32 -7
  76. data/lib/mutant/mutator/node/while.rb +9 -7
  77. data/lib/mutant/mutator/node.rb +116 -66
  78. data/lib/mutant/mutator/registry.rb +14 -11
  79. data/lib/mutant/mutator/util/array.rb +9 -9
  80. data/lib/mutant/mutator/util/symbol.rb +6 -20
  81. data/lib/mutant/mutator/util.rb +6 -3
  82. data/lib/mutant/mutator.rb +12 -28
  83. data/lib/mutant/node_helpers.rb +28 -0
  84. data/lib/mutant/random.rb +3 -2
  85. data/lib/mutant/reporter/cli/printer/config.rb +174 -0
  86. data/lib/mutant/reporter/cli/printer/killer.rb +42 -0
  87. data/lib/mutant/reporter/cli/printer/mutation.rb +55 -0
  88. data/lib/mutant/reporter/cli/printer/subject.rb +147 -0
  89. data/lib/mutant/reporter/cli/printer.rb +165 -0
  90. data/lib/mutant/reporter/cli.rb +9 -277
  91. data/lib/mutant/reporter/null.rb +6 -30
  92. data/lib/mutant/reporter.rb +6 -73
  93. data/lib/mutant/runner/config.rb +82 -0
  94. data/lib/mutant/runner/mutation.rb +58 -0
  95. data/lib/mutant/runner/subject.rb +81 -0
  96. data/lib/mutant/runner.rb +42 -92
  97. data/lib/mutant/singleton_methods.rb +2 -2
  98. data/lib/mutant/strategy/method_expansion.rb +51 -0
  99. data/lib/mutant/strategy/rspec/dm2/lookup/method.rb +142 -0
  100. data/lib/mutant/strategy/rspec/dm2/lookup.rb +61 -0
  101. data/lib/mutant/strategy/rspec/dm2.rb +22 -0
  102. data/lib/mutant/strategy/rspec.rb +20 -22
  103. data/lib/mutant/strategy/static.rb +18 -0
  104. data/lib/mutant/strategy.rb +15 -50
  105. data/lib/mutant/subject/method.rb +100 -0
  106. data/lib/mutant/subject.rb +18 -49
  107. data/lib/mutant/support/method_object.rb +4 -2
  108. data/lib/mutant.rb +40 -35
  109. data/mutant.gemspec +9 -8
  110. data/spec/integration/mutant/rspec_killer_spec.rb +3 -3
  111. data/spec/integration/mutant/test_mutator_handles_types_spec.rb +9 -0
  112. data/spec/integration/mutant/zombie_spec.rb +1 -1
  113. data/spec/shared/method_matcher_behavior.rb +35 -0
  114. data/spec/shared/mutator_behavior.rb +63 -32
  115. data/spec/spec_helper.rb +13 -3
  116. data/spec/support/ice_nine_config.rb +8 -0
  117. data/spec/support/rspec.rb +1 -1
  118. data/spec/support/zombie.rb +1 -1
  119. data/spec/unit/mutant/cli/class_methods/new_spec.rb +42 -28
  120. data/spec/unit/mutant/cli/class_methods/run_spec.rb +15 -13
  121. data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +44 -0
  122. data/spec/unit/mutant/context/scope/root_spec.rb +4 -4
  123. data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +6 -5
  124. data/spec/unit/mutant/killer/success_predicate_spec.rb +28 -0
  125. data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +1 -1
  126. data/spec/unit/mutant/matcher/chain/each_spec.rb +1 -1
  127. data/spec/unit/mutant/matcher/chain/matchers_spec.rb +1 -1
  128. data/spec/unit/mutant/matcher/method/instance/each_spec.rb +112 -0
  129. data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +93 -0
  130. data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +59 -0
  131. data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +53 -0
  132. data/spec/unit/mutant/matcher/namespace/each_spec.rb +37 -0
  133. data/spec/unit/mutant/mutator/node/begin/mutation_spec.rb +33 -0
  134. data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +42 -14
  135. data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +319 -0
  136. data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +31 -27
  137. data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +75 -0
  138. data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +1 -1
  139. data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +2 -2
  140. data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +1 -3
  141. data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +1 -9
  142. data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +6 -2
  143. data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +111 -108
  144. data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +0 -33
  145. data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +2 -2
  146. data/spec/unit/mutant/runner/config/subjects_spec.rb +38 -0
  147. data/spec/unit/mutant/runner/config/success_predicate_spec.rb +53 -0
  148. data/spec/unit/mutant/runner/failed_predicte_spec.rb +33 -0
  149. data/spec/unit/mutant/runner/mutation/killer_spec.rb +39 -0
  150. data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +49 -0
  151. data/spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb +49 -0
  152. data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +52 -0
  153. data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +42 -0
  154. data/spec/unit/mutant/subject/context_spec.rb +6 -3
  155. data/spec/unit/mutant/subject/each_spec.rb +11 -8
  156. data/spec/unit/mutant/subject/node_spec.rb +6 -2
  157. data/test_app/spec/shared/method_filter_parse_behavior.rb +0 -2
  158. data/test_app/spec/shared/method_match_behavior.rb +1 -1
  159. data/test_app/spec/spec_helper.rb +4 -2
  160. metadata +101 -109
  161. data/config/roodi.yml +0 -26
  162. data/lib/mutant/matcher/method/classifier.rb +0 -141
  163. data/lib/mutant/matcher/object_space.rb +0 -114
  164. data/lib/mutant/mutator/node/actual_arguments.rb +0 -25
  165. data/lib/mutant/mutator/node/default_arguments.rb +0 -25
  166. data/lib/mutant/mutator/node/formal_arguments_19/default_mutations.rb +0 -33
  167. data/lib/mutant/mutator/node/formal_arguments_19/pattern_argument_expansion.rb +0 -35
  168. data/lib/mutant/mutator/node/formal_arguments_19/require_defaults.rb +0 -37
  169. data/lib/mutant/mutator/node/formal_arguments_19.rb +0 -41
  170. data/lib/mutant/mutator/node/iter_19.rb +0 -27
  171. data/lib/mutant/mutator/node/literal/empty_array.rb +0 -26
  172. data/lib/mutant/mutator/node/pattern_arguments.rb +0 -41
  173. data/lib/mutant/mutator/node/pattern_variable.rb +0 -23
  174. data/lib/mutant/mutator/node/receiver_case.rb +0 -122
  175. data/lib/mutant/mutator/node/send/binary_operator_method.rb +0 -61
  176. data/lib/mutant/mutator/node/send/with_arguments.rb +0 -81
  177. data/lib/mutant/reporter/stats.rb +0 -120
  178. data/lib/mutant/strategy/rspec/example_lookup.rb +0 -163
  179. data/spec/integration/mutant/method_matching_spec.rb +0 -269
  180. data/spec/shared/method_match_behavior.rb +0 -39
  181. data/spec/unit/mutant/killer/fail_ques_spec.rb +0 -39
  182. data/spec/unit/mutant/matcher/class_methods/from_string_spec.rb +0 -49
  183. data/spec/unit/mutant/matcher/class_methods/parse_spec.rb +0 -12
  184. data/spec/unit/mutant/matcher/method/class_methods/parse_spec.rb +0 -21
  185. data/spec/unit/mutant/matcher/method/classifier/class_methods/run_spec.rb +0 -52
  186. data/spec/unit/mutant/matcher/object_space/class_methods/parse_spec.rb +0 -24
  187. data/spec/unit/mutant/matcher/object_space/each_spec.rb +0 -31
  188. data/spec/unit/mutant/mutator/node/if_statement/mutation_spec.rb +0 -60
  189. data/spec/unit/mutant/mutator/node/receiver_case/mutation_spec.rb +0 -27
  190. data/spec/unit/mutant/strategy/rspec/example_lookup/spec_file_spec.rb +0 -236
  191. data/spec/unit/mutant/subject/class_methods/new_spec.rb +0 -13
  192. data/tasks/metrics/ci.rake +0 -7
  193. data/tasks/metrics/flay.rake +0 -41
  194. data/tasks/metrics/flog.rake +0 -43
  195. data/tasks/metrics/heckle.rake +0 -216
  196. data/tasks/metrics/metric_fu.rake +0 -31
  197. data/tasks/metrics/reek.rake +0 -15
  198. data/tasks/metrics/roodi.rake +0 -15
  199. data/tasks/metrics/yardstick.rake +0 -23
  200. data/tasks/spec.rake +0 -45
  201. data/tasks/yard.rake +0 -9
@@ -1,10 +1,12 @@
1
1
  module Mutant
2
2
  class Mutator
3
3
  class Node
4
- # Mutator on AST blocks
4
+ # Emitter for mutations on 19 blocks
5
5
  class Block < self
6
6
 
7
- handle(Rubinius::AST::Block)
7
+ handle(:block)
8
+
9
+ children :send, :arguments, :body
8
10
 
9
11
  private
10
12
 
@@ -15,18 +17,16 @@ module Mutant
15
17
  # @api private
16
18
  #
17
19
  def dispatch
18
- array = input.array
19
- emit_attribute_mutations(:array) do |mutation|
20
- array = mutation.array
21
- # Do not generate empty bodies
22
- if array.empty?
23
- array << new_nil
24
- end
25
- mutation
20
+ emit(send)
21
+ emit_arguments_mutations
22
+ if body
23
+ emit_body_mutations
24
+ else
25
+ emit_body(NEW_OBJECT)
26
26
  end
27
27
  end
28
28
 
29
- end
30
- end
31
- end
32
- end
29
+ end # Block
30
+ end # Node
31
+ end # Mutator
32
+ end # Mutant
@@ -0,0 +1,59 @@
1
+ module Mutant
2
+ class Mutator
3
+ class Node
4
+
5
+ # Mutator for case nodes
6
+ class Case < self
7
+
8
+ handle(:case)
9
+
10
+ children :condition
11
+
12
+ private
13
+
14
+ # Emit mutations
15
+ #
16
+ # @return [undefined]
17
+ #
18
+ # @api private
19
+ #
20
+ def dispatch
21
+ emit_condition_mutations
22
+ emit_when_mutations
23
+ emit_else_mutations
24
+ end
25
+
26
+ # Emit when mutations
27
+ #
28
+ # @return [undefined]
29
+ #
30
+ # @api private
31
+ #
32
+ def emit_when_mutations
33
+ indices = children.each_index.drop(1).take(children.length-2)
34
+ one = indices.one?
35
+ indices.each do |index|
36
+ mutate_child(index)
37
+ delete_child(index) unless one
38
+ end
39
+ end
40
+
41
+ # Emit else mutations
42
+ #
43
+ # @return [undefined]
44
+ #
45
+ # @api private
46
+ #
47
+ def emit_else_mutations
48
+ else_branch = children.last
49
+ else_index = children.length - 1
50
+ if else_branch
51
+ mutate_child(else_index)
52
+ emit_child_update(else_index, nil)
53
+ end
54
+ end
55
+
56
+ end # Case
57
+ end # Node
58
+ end # Mutator
59
+ end # Mutant
@@ -1,11 +1,9 @@
1
1
  module Mutant
2
2
  class Mutator
3
3
  class Node
4
+ # Namespace for define mutations
4
5
  class Define < self
5
6
 
6
- handle(Rubinius::AST::Define)
7
- handle(Rubinius::AST::DefineSingletonScope)
8
-
9
7
  private
10
8
 
11
9
  # Emit mutations
@@ -15,27 +13,33 @@ module Mutant
15
13
  # @api private
16
14
  #
17
15
  def dispatch
18
- emit_attribute_mutations(:body)
19
- emit_attribute_mutations(:arguments)
16
+ emit_arguments_mutations
17
+ if body
18
+ emit_body_mutations
19
+ else
20
+ emit_body(NEW_OBJECT)
21
+ end
20
22
  end
21
- end
22
23
 
23
- class DefineSingleton < self
24
+ # Mutator for instance method defines
25
+ class Instance < self
24
26
 
25
- handle(Rubinius::AST::DefineSingleton)
27
+ handle :def
26
28
 
27
- private
29
+ children :name, :arguments, :body
28
30
 
29
- # Emit mutations
30
- #
31
- # @return [undefined]
32
- #
33
- # @api private
34
- #
35
- def dispatch
36
- emit_attribute_mutations(:body)
37
- end
38
- end
39
- end
40
- end
41
- end
31
+ end # Instance
32
+
33
+ # Mutator for singleton method defines
34
+ class Singleton < self
35
+
36
+ handle :defs
37
+
38
+ children :subject, :name, :arguments, :body
39
+
40
+ end # Singelton
41
+
42
+ end # Define
43
+ end # Node
44
+ end # Mutator
45
+ end # Mutant
@@ -1,108 +1,68 @@
1
1
  module Mutant
2
2
  class Mutator
3
3
  class Node
4
- # Mutator for Rubinius::AST::If nodes
4
+ # Mutator for if nodes
5
5
  class If < self
6
6
 
7
- handle(Rubinius::AST::If)
7
+ handle(:if)
8
+
9
+ children :condition, :if_branch, :else_branch
8
10
 
9
11
  private
10
12
 
11
- # Emit mutations on Rubinius::AST::If nodes
13
+ # Emit mutations
12
14
  #
13
15
  # @return [undefined]
14
16
  #
15
17
  # @api private
16
18
  #
17
19
  def dispatch
18
- emit_attribute_mutations(:condition)
19
- emit_attribute_mutations(:body) unless nil_literal?(:body)
20
- emit_attribute_mutations(:else) unless nil_literal?(:else)
21
- emit_inverted_condition
22
- emit_deleted_if_branch
23
- emit_deleted_else_branch
24
- end
25
-
26
- # Test if attribute is non nil literal
27
- #
28
- # @param [Symbol] name
29
- #
30
- # @return [true]
31
- # if attribute value a nil literal
32
- #
33
- # @return [false]
34
- # otherwise
35
- #
36
- # @api private
37
- #
38
- def nil_literal?(name)
39
- node.public_send(name).kind_of?(Rubinius::AST::NilLiteral)
20
+ mutate_condition
21
+ mutate_if_branch
22
+ mutate_else_branch
40
23
  end
41
24
 
42
- # Emit inverted condition
43
- #
44
- # Especially the same like swap branches but more universal as it also
45
- # covers the case there is no else branch
25
+ # Emit conditon mutations
46
26
  #
47
27
  # @return [undefined]
48
28
  #
49
29
  # @api private
50
30
  #
51
- def emit_inverted_condition
52
- emit_self(new_send(condition, :'!'), if_branch, else_branch)
31
+ def mutate_condition
32
+ emit_condition_mutations
33
+ emit_self(s(:send, condition, :!), if_branch, else_branch)
34
+ emit_self(s(:true), if_branch, else_branch)
35
+ emit_self(s(:false), if_branch, else_branch)
53
36
  end
54
37
 
55
- # Emit deleted else branch
38
+ # Emit if branch mutations
56
39
  #
57
40
  # @return [undefined]
58
41
  #
59
42
  # @api private
60
43
  #
61
- def emit_deleted_else_branch
62
- emit_self(condition, if_branch, nil)
44
+ def mutate_if_branch
45
+ emit_self(condition, else_branch, nil) if else_branch
46
+ if if_branch
47
+ emit_if_branch_mutations
48
+ emit_self(condition, if_branch, nil)
49
+ end
63
50
  end
64
51
 
65
- # Emit deleted if branch
52
+ # Emit else branch mutations
66
53
  #
67
54
  # @return [undefined]
68
55
  #
69
56
  # @api private
70
57
  #
71
- def emit_deleted_if_branch
72
- body = else_branch || return
73
- emit_self(condition, body, nil)
58
+ def mutate_else_branch
59
+ if else_branch
60
+ emit_else_branch_mutations
61
+ emit_self(condition, nil, else_branch)
62
+ end
74
63
  end
75
64
 
76
- # Return if_branch of node
77
- #
78
- # @return [Rubinius::AST::Node]
79
- #
80
- # @api private
81
- #
82
- def if_branch
83
- node.body
84
- end
85
-
86
- # Return condition of node
87
- #
88
- # @return [Rubinius::AST::Node]
89
- #
90
- # @api private
91
- #
92
- def condition
93
- node.condition
94
- end
95
-
96
- # Return else body of node
97
- #
98
- # @return [Rubinius::AST::Node]
99
- #
100
- # @api private
101
- #
102
- def else_branch
103
- node.else
104
- end
105
- end
106
- end
107
- end
108
- end
65
+ end # If
66
+ end # Node
67
+ end # Mutator
68
+ end # Mutant
@@ -5,7 +5,7 @@ module Mutant
5
5
  # Mutator for array literals
6
6
  class Array < self
7
7
 
8
- handle(Rubinius::AST::ArrayLiteral)
8
+ handle(:array)
9
9
 
10
10
  private
11
11
 
@@ -16,13 +16,29 @@ module Mutant
16
16
  # @api private
17
17
  #
18
18
  def dispatch
19
- emit_attribute_mutations(:body)
20
- emit_self([])
21
19
  emit_nil
22
- emit_self([new_nil] + node.body.dup)
20
+ emit_self
21
+ mutate_body
23
22
  end
24
- end
25
- end
26
- end
27
- end
28
- end
23
+
24
+ # Mutate body
25
+ #
26
+ # @return [undefined]
27
+ #
28
+ # @api private
29
+ #
30
+ def mutate_body
31
+ children.each_index do |index|
32
+ dup_children = children.dup
33
+ dup_children.delete_at(index)
34
+ emit_self(*dup_children)
35
+ mutate_child(index)
36
+ end
37
+ emit_self(s(:nil), *children)
38
+ end
39
+
40
+ end # Array
41
+ end # Literal
42
+ end # Node
43
+ end # Mutator
44
+ end # Mutant
@@ -7,6 +7,13 @@ module Mutant
7
7
 
8
8
  private
9
9
 
10
+ MAP = {
11
+ :true => :false,
12
+ :false => :true
13
+ }.freeze
14
+
15
+ handle(*MAP.keys)
16
+
10
17
  # Emit mutants
11
18
  #
12
19
  # @return [undefined]
@@ -15,35 +22,11 @@ module Mutant
15
22
  #
16
23
  def dispatch
17
24
  emit_nil
18
- emit(inverse)
19
- end
20
-
21
- # Return inverse
22
- #
23
- # @return [Rubinius::AST::Node]
24
- #
25
- # @api private
26
- #
27
- def inverse
28
- new(self.class::INVERSE_CLASS)
29
- end
30
-
31
- # Mutator for true literals
32
- class TrueLiteral < self
33
- INVERSE_CLASS = Rubinius::AST::FalseLiteral
34
-
35
- handle(Rubinius::AST::TrueLiteral)
25
+ emit(s(MAP.fetch(node.type)))
36
26
  end
37
27
 
38
-
39
- # Mutator for false literals
40
- class FalseLiteral < self
41
- INVERSE_CLASS = Rubinius::AST::TrueLiteral
42
-
43
- handle(Rubinius::AST::FalseLiteral)
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
28
+ end # Boolean
29
+ end # Literal
30
+ end # Node
31
+ end # Mutatork
32
+ end # Mutant
@@ -17,8 +17,9 @@ module Mutant
17
17
  def dispatch
18
18
  emit_nil
19
19
  end
20
- end
21
- end
22
- end
23
- end
24
- end
20
+
21
+ end # Dynamic
22
+ end # Literal
23
+ end # Node
24
+ end # Mutator
25
+ end # Mutant
@@ -5,7 +5,7 @@ module Mutant
5
5
  # Mutator for fixnum literals
6
6
  class Fixnum < self
7
7
 
8
- handle(Rubinius::AST::FixnumLiteral)
8
+ handle(:int)
9
9
 
10
10
  private
11
11
 
@@ -28,10 +28,21 @@ module Mutant
28
28
  # @api private
29
29
  #
30
30
  def values
31
- [0, 1, -node.value]
31
+ [0, 1, -value, value+1, value-1]
32
32
  end
33
- end
34
- end
35
- end
36
- end
37
- end
33
+
34
+ # Return value
35
+ #
36
+ # @return [Object]
37
+ #
38
+ # @api private
39
+ #
40
+ def value
41
+ children.first
42
+ end
43
+
44
+ end # Fixnuma
45
+ end # Literal
46
+ end # Node
47
+ end # Mutator
48
+ end # Mutant
@@ -5,7 +5,7 @@ module Mutant
5
5
  # Mutator for float literals
6
6
  class Float < self
7
7
 
8
- handle(Rubinius::AST::FloatLiteral)
8
+ handle(:float)
9
9
 
10
10
  private
11
11
 
@@ -20,6 +20,12 @@ module Mutant
20
20
  emit_new { new_self(Random.float) }
21
21
  end
22
22
 
23
+ SPECIAL = [
24
+ NodeHelpers::NAN,
25
+ NodeHelpers::NEGATIVE_INFINITY,
26
+ NodeHelpers::INFINITY
27
+ ].freeze
28
+
23
29
  # Emit special cases
24
30
  #
25
31
  # @return [undefined]
@@ -27,7 +33,7 @@ module Mutant
27
33
  # @api private
28
34
  #
29
35
  def emit_special_cases
30
- [infinity, negative_infinity, nan].each do |value|
36
+ SPECIAL.each do |value|
31
37
  emit(value)
32
38
  end
33
39
  end
@@ -39,10 +45,11 @@ module Mutant
39
45
  # @api private
40
46
  #
41
47
  def values
42
- [0.0, 1.0] << -node.value
48
+ [0.0, 1.0, -children.first]
43
49
  end
44
- end
45
- end
46
- end
47
- end
48
- end
50
+
51
+ end # Float
52
+ end # Literal
53
+ end # Node
54
+ end # Mutator
55
+ end # Mutant
@@ -5,7 +5,7 @@ module Mutant
5
5
  # Mutator for hash literals
6
6
  class Hash < self
7
7
 
8
- handle(Rubinius::AST::HashLiteral)
8
+ handle(:hash)
9
9
 
10
10
  private
11
11
 
@@ -17,67 +17,48 @@ module Mutant
17
17
  #
18
18
  def dispatch
19
19
  emit_nil
20
- emit_values(values)
21
- emit_element_presence
22
- emit_body
20
+ emit_self
21
+ mutate_body
23
22
  end
24
23
 
25
- # Emit body mutations
24
+ # Mutate body
26
25
  #
27
26
  # @return [undefined]
28
27
  #
29
28
  # @api private
30
29
  #
31
- def emit_body
32
- emit_attribute_mutations(:array, Mutator::Util::Array::Element)
30
+ def mutate_body
31
+ children.each_index do |index|
32
+ mutate_child(index)
33
+ dup_children = children.dup
34
+ dup_children.delete_at(index)
35
+ emit_self(*dup_children)
36
+ end
33
37
  end
34
38
 
35
- # Return array of values in literal
36
- #
37
- # @return [Array]
38
- #
39
- # @api private
40
- #
41
- def array
42
- node.array
43
- end
39
+ # Mutator for hash pairs
40
+ class Pair < Node
44
41
 
45
- # Return duplicate of array values in literal
46
- #
47
- # @return [Array]
48
- #
49
- # @api private
50
- #
51
- def dup_array
52
- array.dup
53
- end
42
+ handle(:pair)
54
43
 
55
- # Return values to mutate against
56
- #
57
- # @return [Array]
58
- #
59
- # @api private
60
- #
61
- def values
62
- [[]]
63
- end
44
+ children :key, :value
64
45
 
65
- # Emit element presence mutations
66
- #
67
- # @return [undefined]
68
- #
69
- # @api private
70
- #
71
- def emit_element_presence
72
- 0.step(array.length-1, 2) do |index|
73
- contents = dup_array
74
- contents.delete_at(index)
75
- contents.delete_at(index)
76
- emit_self(contents)
46
+ private
47
+
48
+ # Perform dispatch
49
+ #
50
+ # @return [undefined]
51
+ #
52
+ # @api private
53
+ #
54
+ def dispatch
55
+ emit_key_mutations
56
+ emit_value_mutations
77
57
  end
78
- end
79
- end
80
- end
81
- end
82
- end
83
- end
58
+
59
+ end # Pair
60
+ end # Hash
61
+ end # Literal
62
+ end # Node
63
+ end # Mutator
64
+ end # Mutant
@@ -5,7 +5,7 @@ module Mutant
5
5
  # Mutator for nil literals
6
6
  class Nil < self
7
7
 
8
- handle(Rubinius::AST::NilLiteral)
8
+ handle(:nil)
9
9
 
10
10
  private
11
11
 
@@ -16,10 +16,11 @@ module Mutant
16
16
  # @api private
17
17
  #
18
18
  def dispatch
19
- emit('Object.new'.to_ast)
19
+ emit(NEW_OBJECT)
20
20
  end
21
- end
22
- end
23
- end
24
- end
25
- end
21
+
22
+ end # Nil
23
+ end # Literal
24
+ end # Node
25
+ end # Mutator
26
+ end # Mutant