mutant 0.3.0.beta21 → 0.3.0.beta22

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 (223) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +37 -6
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.travis.yml +13 -7
  6. data/Gemfile +8 -3
  7. data/Gemfile.devtools +2 -6
  8. data/Guardfile +22 -8
  9. data/README.md +3 -1
  10. data/Rakefile +3 -0
  11. data/bin/mutant +4 -3
  12. data/config/devtools.yml +1 -1
  13. data/config/flay.yml +1 -1
  14. data/config/flog.yml +1 -1
  15. data/config/reek.yml +7 -6
  16. data/config/rubocop.yml +55 -0
  17. data/lib/mutant.rb +3 -1
  18. data/lib/mutant/cache.rb +2 -0
  19. data/lib/mutant/cli.rb +14 -10
  20. data/lib/mutant/cli/classifier.rb +22 -10
  21. data/lib/mutant/cli/classifier/method.rb +14 -15
  22. data/lib/mutant/cli/classifier/namespace.rb +6 -2
  23. data/lib/mutant/cli/classifier/scope.rb +3 -1
  24. data/lib/mutant/color.rb +7 -3
  25. data/lib/mutant/config.rb +2 -0
  26. data/lib/mutant/constants.rb +5 -4
  27. data/lib/mutant/context.rb +2 -0
  28. data/lib/mutant/context/scope.rb +3 -1
  29. data/lib/mutant/differ.rb +10 -2
  30. data/lib/mutant/killer.rb +4 -1
  31. data/lib/mutant/killer/forked.rb +2 -0
  32. data/lib/mutant/killer/forking.rb +2 -0
  33. data/lib/mutant/killer/rspec.rb +19 -3
  34. data/lib/mutant/killer/static.rb +2 -0
  35. data/lib/mutant/loader.rb +8 -1
  36. data/lib/mutant/matcher.rb +2 -0
  37. data/lib/mutant/matcher/chain.rb +2 -0
  38. data/lib/mutant/matcher/method.rb +15 -3
  39. data/lib/mutant/matcher/method/finder.rb +2 -0
  40. data/lib/mutant/matcher/method/instance.rb +4 -1
  41. data/lib/mutant/matcher/method/singleton.rb +7 -1
  42. data/lib/mutant/matcher/methods.rb +3 -1
  43. data/lib/mutant/matcher/namespace.rb +4 -2
  44. data/lib/mutant/matcher/scope.rb +2 -0
  45. data/lib/mutant/mutation.rb +19 -5
  46. data/lib/mutant/mutation/evil.rb +12 -0
  47. data/lib/mutant/mutation/filter.rb +2 -0
  48. data/lib/mutant/mutation/filter/code.rb +3 -1
  49. data/lib/mutant/mutation/filter/regexp.rb +2 -0
  50. data/lib/mutant/mutation/filter/whitelist.rb +2 -0
  51. data/lib/mutant/mutation/neutral.rb +25 -0
  52. data/lib/mutant/mutator.rb +4 -6
  53. data/lib/mutant/mutator/node.rb +5 -1
  54. data/lib/mutant/mutator/node/argument.rb +2 -0
  55. data/lib/mutant/mutator/node/arguments.rb +2 -0
  56. data/lib/mutant/mutator/node/begin.rb +2 -0
  57. data/lib/mutant/mutator/node/block.rb +2 -0
  58. data/lib/mutant/mutator/node/case.rb +3 -1
  59. data/lib/mutant/mutator/node/connective/binary.rb +3 -1
  60. data/lib/mutant/mutator/node/const.rb +2 -0
  61. data/lib/mutant/mutator/node/define.rb +2 -0
  62. data/lib/mutant/mutator/node/generic.rb +4 -3
  63. data/lib/mutant/mutator/node/if.rb +2 -0
  64. data/lib/mutant/mutator/node/literal.rb +2 -0
  65. data/lib/mutant/mutator/node/literal/array.rb +2 -0
  66. data/lib/mutant/mutator/node/literal/boolean.rb +2 -0
  67. data/lib/mutant/mutator/node/literal/dynamic.rb +2 -0
  68. data/lib/mutant/mutator/node/literal/fixnum.rb +3 -1
  69. data/lib/mutant/mutator/node/literal/float.rb +2 -0
  70. data/lib/mutant/mutator/node/literal/hash.rb +2 -0
  71. data/lib/mutant/mutator/node/literal/nil.rb +2 -0
  72. data/lib/mutant/mutator/node/literal/range.rb +2 -1
  73. data/lib/mutant/mutator/node/literal/regex.rb +2 -0
  74. data/lib/mutant/mutator/node/literal/string.rb +2 -0
  75. data/lib/mutant/mutator/node/literal/symbol.rb +5 -1
  76. data/lib/mutant/mutator/node/masgn.rb +2 -0
  77. data/lib/mutant/mutator/node/mlhs.rb +2 -0
  78. data/lib/mutant/mutator/node/named_value/access.rb +2 -0
  79. data/lib/mutant/mutator/node/named_value/constant_assignment.rb +2 -0
  80. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +3 -1
  81. data/lib/mutant/mutator/node/{cbase.rb → noop.rb} +7 -5
  82. data/lib/mutant/mutator/node/return.rb +2 -0
  83. data/lib/mutant/mutator/node/send.rb +2 -0
  84. data/lib/mutant/mutator/node/send/binary.rb +2 -0
  85. data/lib/mutant/mutator/node/splat.rb +2 -0
  86. data/lib/mutant/mutator/node/super.rb +2 -0
  87. data/lib/mutant/mutator/node/when.rb +3 -1
  88. data/lib/mutant/mutator/node/while.rb +2 -0
  89. data/lib/mutant/mutator/node/zsuper.rb +2 -0
  90. data/lib/mutant/mutator/registry.rb +55 -13
  91. data/lib/mutant/mutator/util.rb +2 -0
  92. data/lib/mutant/mutator/util/array.rb +3 -1
  93. data/lib/mutant/mutator/util/symbol.rb +2 -0
  94. data/lib/mutant/node_helpers.rb +10 -4
  95. data/lib/mutant/random.rb +2 -0
  96. data/lib/mutant/reporter.rb +2 -0
  97. data/lib/mutant/reporter/cli.rb +2 -0
  98. data/lib/mutant/reporter/cli/printer.rb +2 -0
  99. data/lib/mutant/reporter/cli/printer/config.rb +5 -2
  100. data/lib/mutant/reporter/cli/printer/killer.rb +2 -0
  101. data/lib/mutant/reporter/cli/printer/mutation.rb +13 -6
  102. data/lib/mutant/reporter/cli/printer/subject.rb +5 -1
  103. data/lib/mutant/reporter/null.rb +2 -0
  104. data/lib/mutant/runner.rb +2 -0
  105. data/lib/mutant/runner/config.rb +2 -0
  106. data/lib/mutant/runner/mutation.rb +2 -0
  107. data/lib/mutant/runner/subject.rb +2 -0
  108. data/lib/mutant/singleton_methods.rb +5 -3
  109. data/lib/mutant/strategy.rb +2 -0
  110. data/lib/mutant/strategy/method_expansion.rb +2 -0
  111. data/lib/mutant/strategy/rspec.rb +2 -0
  112. data/lib/mutant/strategy/rspec/dm2.rb +2 -0
  113. data/lib/mutant/strategy/rspec/dm2/lookup.rb +4 -2
  114. data/lib/mutant/strategy/rspec/dm2/lookup/method.rb +2 -0
  115. data/lib/mutant/strategy/static.rb +2 -0
  116. data/lib/mutant/subject.rb +4 -1
  117. data/lib/mutant/subject/method.rb +2 -0
  118. data/lib/mutant/subject/method/instance.rb +2 -0
  119. data/lib/mutant/subject/method/singleton.rb +2 -0
  120. data/lib/mutant/support/method_object.rb +2 -0
  121. data/lib/mutant/zombifier.rb +10 -6
  122. data/mutant.gemspec +11 -10
  123. data/spec/integration/mutant/rspec_killer_spec.rb +9 -4
  124. data/spec/integration/mutant/test_mutator_handles_types_spec.rb +3 -1
  125. data/spec/integration/mutant/zombie_spec.rb +2 -0
  126. data/spec/shared/method_matcher_behavior.rb +2 -0
  127. data/spec/shared/mutator_behavior.rb +16 -7
  128. data/spec/spec_helper.rb +26 -5
  129. data/spec/support/compress_helper.rb +5 -5
  130. data/spec/support/ice_nine_config.rb +2 -0
  131. data/spec/support/rspec.rb +2 -0
  132. data/spec/support/test_app.rb +2 -0
  133. data/spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb +2 -0
  134. data/spec/unit/mutant/cli/class_methods/new_spec.rb +17 -8
  135. data/spec/unit/mutant/cli/class_methods/run_spec.rb +10 -2
  136. data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +4 -1
  137. data/spec/unit/mutant/cli/classifier/method/each_spec.rb +89 -0
  138. data/spec/unit/mutant/cli/classifier/namespace/flat/each_spec.rb +58 -0
  139. data/spec/unit/mutant/cli/classifier/namespace/recursive/each_spec.rb +58 -0
  140. data/spec/unit/mutant/cli/classifier/scope/each_spec.rb +33 -0
  141. data/spec/unit/mutant/context/root_spec.rb +5 -1
  142. data/spec/unit/mutant/context/scope/root_spec.rb +2 -0
  143. data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +2 -0
  144. data/spec/unit/mutant/differ/class_methods/build_spec.rb +2 -0
  145. data/spec/unit/mutant/differ/class_methods/colorize_line_spec.rb +2 -0
  146. data/spec/unit/mutant/differ/diff_spec.rb +67 -5
  147. data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +21 -4
  148. data/spec/unit/mutant/killer/success_predicate_spec.rb +2 -0
  149. data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +12 -5
  150. data/spec/unit/mutant/matcher/chain/each_spec.rb +2 -0
  151. data/spec/unit/mutant/matcher/chain/matchers_spec.rb +2 -0
  152. data/spec/unit/mutant/matcher/each_spec.rb +8 -1
  153. data/spec/unit/mutant/matcher/method/instance/class_methods/build_spec.rb +4 -2
  154. data/spec/unit/mutant/matcher/method/instance/each_spec.rb +21 -20
  155. data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +22 -19
  156. data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +8 -3
  157. data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +8 -3
  158. data/spec/unit/mutant/matcher/namespace/each_spec.rb +8 -2
  159. data/spec/unit/mutant/mutator/each_spec.rb +2 -0
  160. data/spec/unit/mutant/mutator/emit_new_spec.rb +10 -3
  161. data/spec/unit/mutant/mutator/emit_spec.rb +4 -2
  162. data/spec/unit/mutant/mutator/node/and_asgn/mutation_spec.rb +26 -0
  163. data/spec/unit/mutant/mutator/node/begin/mutation_spec.rb +2 -0
  164. data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +4 -2
  165. data/spec/unit/mutant/mutator/node/block_pass/mutation_spec.rb +14 -0
  166. data/spec/unit/mutant/mutator/node/break/mutation_spec.rb +15 -0
  167. data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +2 -0
  168. data/spec/unit/mutant/mutator/node/cbase/mutation_spec.rb +3 -6
  169. data/spec/unit/mutant/mutator/node/connective/binary/mutation_spec.rb +2 -0
  170. data/spec/unit/mutant/mutator/node/const/mutation_spec.rb +3 -6
  171. data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +2 -1
  172. data/spec/unit/mutant/mutator/node/defined_predicate/mutation_spec.rb +10 -0
  173. data/spec/unit/mutant/mutator/node/dstr/mutation_spec.rb +21 -0
  174. data/spec/unit/mutant/mutator/node/dsym/mutation_spec.rb +21 -0
  175. data/spec/unit/mutant/mutator/node/ensure/mutation_spec.rb +15 -0
  176. data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +2 -1
  177. data/spec/unit/mutant/mutator/node/literal/array_spec.rb +2 -0
  178. data/spec/unit/mutant/mutator/node/literal/boolean/mutation_spec.rb +2 -0
  179. data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +2 -0
  180. data/spec/unit/mutant/mutator/node/literal/float_spec.rb +4 -2
  181. data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +2 -0
  182. data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +4 -5
  183. data/spec/unit/mutant/mutator/node/literal/range_spec.rb +8 -8
  184. data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +2 -0
  185. data/spec/unit/mutant/mutator/node/literal/string_spec.rb +2 -0
  186. data/spec/unit/mutant/mutator/node/literal/symbol_spec.rb +2 -0
  187. data/spec/unit/mutant/mutator/node/masgn/mutation_spec.rb +4 -10
  188. data/spec/unit/mutant/mutator/node/match_current_line/mutation_spec.rb +20 -0
  189. data/spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb +3 -2
  190. data/spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb +3 -2
  191. data/spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb +3 -2
  192. data/spec/unit/mutant/mutator/node/next/mutation_spec.rb +15 -0
  193. data/spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb +26 -0
  194. data/spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb +26 -0
  195. data/spec/unit/mutant/mutator/node/redo/mutation_spec.rb +10 -0
  196. data/spec/unit/mutant/mutator/node/rescue/mutation_spec.rb +24 -0
  197. data/spec/unit/mutant/mutator/node/restarg/mutation_spec.rb +16 -0
  198. data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +2 -0
  199. data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +3 -1
  200. data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +2 -0
  201. data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +3 -1
  202. data/spec/unit/mutant/mutator/node/yield/mutation_spec.rb +15 -0
  203. data/spec/unit/mutant/node_helpers/n_not_spec.rb +2 -0
  204. data/spec/unit/mutant/runner/config/subjects_spec.rb +6 -2
  205. data/spec/unit/mutant/runner/config/success_predicate_spec.rb +15 -6
  206. data/spec/unit/mutant/runner/mutation/killer_spec.rb +3 -1
  207. data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +15 -8
  208. data/spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb +2 -0
  209. data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +32 -11
  210. data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +31 -11
  211. data/spec/unit/mutant/subject/context_spec.rb +2 -0
  212. data/spec/unit/mutant/subject/mutations_spec.rb +2 -0
  213. data/spec/unit/mutant/subject/node_spec.rb +2 -0
  214. data/test_app/lib/test_app.rb +2 -0
  215. data/test_app/lib/test_app/literal.rb +2 -0
  216. data/test_app/spec/shared/method_filter_parse_behavior.rb +5 -1
  217. data/test_app/spec/shared/method_match_behavior.rb +2 -0
  218. data/test_app/spec/spec_helper.rb +3 -1
  219. data/test_app/spec/unit/test_app/literal/command_spec.rb +2 -0
  220. data/test_app/spec/unit/test_app/literal/string_spec.rb +3 -1
  221. metadata +66 -18
  222. data/bin/zombie +0 -18
  223. data/test_app/spec/shared/mutator_behavior.rb +0 -44
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -7,6 +9,8 @@ module Mutant
7
9
 
8
10
  handle(:sym)
9
11
 
12
+ PREFIX = 's'
13
+
10
14
  private
11
15
 
12
16
  # Emit mutatns
@@ -17,7 +21,7 @@ module Mutant
17
21
  #
18
22
  def dispatch
19
23
  emit_nil
20
- emit_new { new_self(('s'+Random.hex_string).to_sym) }
24
+ emit_new { new_self((PREFIX + Random.hex_string).to_sym) }
21
25
  end
22
26
 
23
27
  end # Symbol
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -15,7 +17,7 @@ module Mutant
15
17
  :lvasgn => ''
16
18
  )
17
19
 
18
- handle *MAP.keys
20
+ handle(*MAP.keys)
19
21
 
20
22
  private
21
23
 
@@ -1,11 +1,13 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
4
6
 
5
- # Mutation emitter to handle cbase nodes
6
- class Cbase < self
7
+ # Mutation emitter to handle noop nodes
8
+ class Noop < self
7
9
 
8
- handle(:cbase)
10
+ handle(:block_pass, :cbase)
9
11
 
10
12
  private
11
13
 
@@ -16,10 +18,10 @@ module Mutant
16
18
  # @api private
17
19
  #
18
20
  def dispatch
19
- # noop, for now
21
+ # noop
20
22
  end
21
23
 
22
- end # Cbase
24
+ end # Noop
23
25
  end # Node
24
26
  end # Mutator
25
27
  end # Mutant
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -41,7 +43,7 @@ module Mutant
41
43
  # @api private
42
44
  #
43
45
  def mutate_body
44
- mutate_child(children.length-1)
46
+ mutate_child(children.length - 1)
45
47
  end
46
48
 
47
49
  end # When
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Node
@@ -1,17 +1,15 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  # Registry for mutators
4
6
  module Registry
5
- # Return registry state
6
- #
7
- # @return [Hash]
8
- #
9
- # @api private
10
- #
11
- def self.registry
12
- @registry ||= {}
13
- end
14
- private_class_method :registry
7
+
8
+ # Raised when the type is an invalid type
9
+ InvalidTypeError = Class.new(TypeError)
10
+
11
+ # Raised when the type is a duplicate
12
+ DuplicateTypeError = Class.new(ArgumentError)
15
13
 
16
14
  # Register mutator class for AST node class
17
15
  #
@@ -23,8 +21,9 @@ module Mutant
23
21
  # @return [self]
24
22
  #
25
23
  def self.register(type, mutator_class)
26
- raise "duplicate type registration: #{type}" if registry.key?(type)
27
- registry[type]=mutator_class
24
+ assert_valid_type(type)
25
+ assert_unique_type(type)
26
+ registry[type] = mutator_class
28
27
  self
29
28
  end
30
29
 
@@ -42,9 +41,52 @@ module Mutant
42
41
  def self.lookup(node)
43
42
  type = node.type
44
43
  registry.fetch(type) do
45
- raise ArgumentError,"No mutator to handle: #{type.inspect}"
44
+ raise ArgumentError, "No mutator to handle: #{type.inspect}"
45
+ end
46
+ end
47
+
48
+ # Return registry state
49
+ #
50
+ # @return [Hash]
51
+ #
52
+ # @api private
53
+ #
54
+ def self.registry
55
+ @registry ||= {}
56
+ end
57
+ private_class_method :registry
58
+
59
+ # Assert the node type is valid
60
+ #
61
+ # @return [undefined]
62
+ #
63
+ # @raise [InvalidTypeError]
64
+ # raised when the node type is invalid
65
+ #
66
+ # @api private
67
+ #
68
+ def self.assert_valid_type(type)
69
+ unless NODE_TYPES.include?(type) || type.kind_of?(Class)
70
+ raise InvalidTypeError, "invalid type registration: #{type}"
71
+ end
72
+ end
73
+ private_class_method :assert_valid_type
74
+
75
+ # Assert the node type is unique and not already registered
76
+ #
77
+ # @return [undefined]
78
+ #
79
+ # @raise [DuplcateTypeError]
80
+ # raised when the node type is a duplicate
81
+ #
82
+ # @api private
83
+ #
84
+ def self.assert_unique_type(type)
85
+ if registry.key?(type)
86
+ raise DuplicateTypeError, "duplicate type registration: #{type}"
46
87
  end
47
88
  end
89
+ private_class_method :assert_unique_type
48
90
 
49
91
  end # Registry
50
92
  end # Mutator
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  # Namespace for utility mutators
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Util
@@ -43,7 +45,7 @@ module Mutant
43
45
  input.each_with_index do |element, index|
44
46
  Mutator.each(element).each do |mutation|
45
47
  dup = dup_input
46
- dup[index]=mutation
48
+ dup[index] = mutation
47
49
  emit(dup)
48
50
  end
49
51
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Mutator
3
5
  class Util
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  # Mixin for node helpers
3
5
  module NodeHelpers
@@ -15,10 +17,14 @@ module Mutant
15
17
  end
16
18
  module_function :s
17
19
 
18
- NAN = s(:send, s(:float, 0.0), :/, s(:args, s(:float, 0.0)))
19
- NEGATIVE_INFINITY = s(:send, s(:float, -1.0), :/, s(:args, s(:float, 0.0)))
20
- INFINITY = s(:send, s(:float, 1.0), :/, s(:args, s(:float, 0.0)))
21
- NEW_OBJECT = s(:send, s(:const, s(:cbase), :Object), :new)
20
+ NAN =
21
+ s(:begin, s(:send, s(:float, 0.0), :/, s(:args, s(:float, 0.0))))
22
+ INFINITY =
23
+ s(:begin, s(:send, s(:float, 1.0), :/, s(:args, s(:float, 0.0))))
24
+ NEW_OBJECT =
25
+ s(:send, s(:const, s(:cbase), :Object), :new)
26
+ NEGATIVE_INFINITY =
27
+ s(:begin, s(:send, s(:float, -1.0), :/, s(:args, s(:float, 0.0))))
22
28
 
23
29
  RAISE = s(:send, nil, :raise)
24
30
 
data/lib/mutant/random.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  # Module for generating random values
3
5
  module Random
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  # Abstract base class for reporters
3
5
  class Reporter
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Reporter
3
5
  # Reporter that reports in human readable format
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Reporter
3
5
  class CLI
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Reporter
3
5
  class CLI
@@ -130,8 +132,9 @@ module Mutant
130
132
  def generic_stats
131
133
  object.subjects.each_with_object(Hash.new(0)) do |runner, stats|
132
134
  Walker.run(runner.subject.node) do |node|
133
- next unless Mutator::Registry.lookup(node) == Mutator::Node::Generic
134
- stats[node.type] += 1
135
+ if Mutator::Registry.lookup(node) == Mutator::Node::Generic
136
+ stats[node.type] += 1
137
+ end
135
138
  end
136
139
  end
137
140
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Reporter
3
5
  class CLI
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Reporter
3
5
  class CLI
@@ -54,11 +56,12 @@ module Mutant
54
56
  # Reporter for noop mutations
55
57
  class Noop < self
56
58
 
57
- MESSAGE =
58
- "Parsed subject AST:\n" \
59
- "%s\n" \
60
- "Unparsed source:\n" \
61
- "%s\n"
59
+ MESSAGE = [
60
+ 'Parsed subject AST:',
61
+ '%s',
62
+ 'Unparsed source:',
63
+ '%s',
64
+ ].join("\n")
62
65
 
63
66
  private
64
67
 
@@ -69,7 +72,11 @@ module Mutant
69
72
  # @api private
70
73
  #
71
74
  def details
72
- sprintf(MESSAGE, mutation.subject.node.inspect, mutation.original_source)
75
+ sprintf(
76
+ MESSAGE,
77
+ mutation.subject.node.inspect,
78
+ mutation.original_source
79
+ )
73
80
  end
74
81
 
75
82
  end # Noop
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Reporter
3
5
  class CLI
@@ -59,6 +61,8 @@ module Mutant
59
61
  object.subject
60
62
  end
61
63
 
64
+ FORMAT = '(%02d/%02d) %3d%% - %0.02fs'.freeze
65
+
62
66
  # Print stats
63
67
  #
64
68
  # @return [undefned
@@ -66,7 +70,7 @@ module Mutant
66
70
  # @api private
67
71
  #
68
72
  def print_stats
69
- status('(%02d/%02d) %3d%% - %0.02fs', amount_kills, amount_mutations, coverage, time)
73
+ status(FORMAT, amount_kills, amount_mutations, coverage, time)
70
74
  end
71
75
 
72
76
  # Print progress bar finish
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  class Reporter
3
5
 
data/lib/mutant/runner.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Mutant
2
4
  # Runner baseclass
3
5
  class Runner