mutant 0.5.19 → 0.5.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -4
  3. data/Changelog.md +9 -0
  4. data/Gemfile.devtools +15 -11
  5. data/README.md +10 -6
  6. data/config/flay.yml +1 -1
  7. data/config/reek.yml +3 -1
  8. data/lib/mutant.rb +41 -41
  9. data/lib/mutant/cache.rb +0 -2
  10. data/lib/mutant/cli.rb +6 -8
  11. data/lib/mutant/color.rb +0 -2
  12. data/lib/mutant/config.rb +0 -2
  13. data/lib/mutant/context.rb +0 -2
  14. data/lib/mutant/context/scope.rb +0 -2
  15. data/lib/mutant/delegator.rb +2 -0
  16. data/lib/mutant/diff.rb +4 -16
  17. data/lib/mutant/expression.rb +8 -7
  18. data/lib/mutant/expression/method.rb +3 -9
  19. data/lib/mutant/isolation.rb +65 -0
  20. data/lib/mutant/killer.rb +1 -3
  21. data/lib/mutant/loader.rb +0 -2
  22. data/lib/mutant/matcher.rb +0 -2
  23. data/lib/mutant/matcher/chain.rb +0 -2
  24. data/lib/mutant/matcher/filter.rb +0 -2
  25. data/lib/mutant/matcher/method.rb +1 -2
  26. data/lib/mutant/matcher/method/finder.rb +0 -2
  27. data/lib/mutant/matcher/method/instance.rb +1 -3
  28. data/lib/mutant/matcher/method/singleton.rb +0 -2
  29. data/lib/mutant/matcher/methods.rb +0 -2
  30. data/lib/mutant/matcher/namespace.rb +2 -6
  31. data/lib/mutant/matcher/null.rb +0 -2
  32. data/lib/mutant/matcher/scope.rb +0 -2
  33. data/lib/mutant/meta/example.rb +57 -18
  34. data/lib/mutant/meta/example/dsl.rb +10 -13
  35. data/lib/mutant/mutation.rb +0 -2
  36. data/lib/mutant/mutation/evil.rb +0 -2
  37. data/lib/mutant/mutation/neutral.rb +0 -2
  38. data/lib/mutant/mutator.rb +4 -31
  39. data/lib/mutant/mutator/node.rb +19 -18
  40. data/lib/mutant/mutator/node/and_asgn.rb +3 -6
  41. data/lib/mutant/mutator/node/argument.rb +0 -2
  42. data/lib/mutant/mutator/node/arguments.rb +47 -4
  43. data/lib/mutant/mutator/node/begin.rb +3 -10
  44. data/lib/mutant/mutator/node/binary.rb +0 -2
  45. data/lib/mutant/mutator/node/block.rb +0 -2
  46. data/lib/mutant/mutator/node/blockarg.rb +0 -2
  47. data/lib/mutant/mutator/node/break.rb +0 -2
  48. data/lib/mutant/mutator/node/case.rb +3 -6
  49. data/lib/mutant/mutator/node/conditional_loop.rb +0 -2
  50. data/lib/mutant/mutator/node/const.rb +1 -3
  51. data/lib/mutant/mutator/node/define.rb +0 -2
  52. data/lib/mutant/mutator/node/defined.rb +1 -3
  53. data/lib/mutant/mutator/node/dstr.rb +0 -2
  54. data/lib/mutant/mutator/node/dsym.rb +0 -2
  55. data/lib/mutant/mutator/node/generic.rb +0 -2
  56. data/lib/mutant/mutator/node/if.rb +8 -12
  57. data/lib/mutant/mutator/node/kwbegin.rb +0 -2
  58. data/lib/mutant/mutator/node/literal.rb +0 -2
  59. data/lib/mutant/mutator/node/literal/array.rb +2 -5
  60. data/lib/mutant/mutator/node/literal/boolean.rb +0 -2
  61. data/lib/mutant/mutator/node/literal/fixnum.rb +0 -2
  62. data/lib/mutant/mutator/node/literal/float.rb +0 -2
  63. data/lib/mutant/mutator/node/literal/hash.rb +0 -2
  64. data/lib/mutant/mutator/node/literal/nil.rb +0 -2
  65. data/lib/mutant/mutator/node/literal/range.rb +0 -2
  66. data/lib/mutant/mutator/node/literal/regex.rb +2 -4
  67. data/lib/mutant/mutator/node/literal/string.rb +0 -2
  68. data/lib/mutant/mutator/node/literal/symbol.rb +0 -2
  69. data/lib/mutant/mutator/node/masgn.rb +0 -2
  70. data/lib/mutant/mutator/node/mlhs.rb +0 -2
  71. data/lib/mutant/mutator/node/named_value/access.rb +0 -2
  72. data/lib/mutant/mutator/node/named_value/constant_assignment.rb +0 -2
  73. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -2
  74. data/lib/mutant/mutator/node/next.rb +0 -3
  75. data/lib/mutant/mutator/node/noop.rb +0 -2
  76. data/lib/mutant/mutator/node/nthref.rb +0 -2
  77. data/lib/mutant/mutator/node/op_asgn.rb +2 -4
  78. data/lib/mutant/mutator/node/or_asgn.rb +4 -7
  79. data/lib/mutant/mutator/node/resbody.rb +1 -1
  80. data/lib/mutant/mutator/node/rescue.rb +0 -2
  81. data/lib/mutant/mutator/node/restarg.rb +0 -2
  82. data/lib/mutant/mutator/node/return.rb +3 -6
  83. data/lib/mutant/mutator/node/send.rb +14 -8
  84. data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -2
  85. data/lib/mutant/mutator/node/send/binary.rb +1 -3
  86. data/lib/mutant/mutator/node/splat.rb +0 -2
  87. data/lib/mutant/mutator/node/super.rb +0 -2
  88. data/lib/mutant/mutator/node/when.rb +0 -2
  89. data/lib/mutant/mutator/node/yield.rb +0 -2
  90. data/lib/mutant/mutator/node/zsuper.rb +0 -2
  91. data/lib/mutant/mutator/registry.rb +0 -2
  92. data/lib/mutant/mutator/util.rb +0 -2
  93. data/lib/mutant/mutator/util/array.rb +0 -2
  94. data/lib/mutant/mutator/util/symbol.rb +0 -2
  95. data/lib/mutant/node_helpers.rb +11 -2
  96. data/lib/mutant/reporter.rb +0 -2
  97. data/lib/mutant/reporter/cli.rb +0 -2
  98. data/lib/mutant/reporter/cli/printer.rb +0 -2
  99. data/lib/mutant/reporter/cli/progress.rb +0 -2
  100. data/lib/mutant/reporter/cli/report.rb +0 -2
  101. data/lib/mutant/reporter/cli/report/config.rb +0 -2
  102. data/lib/mutant/reporter/cli/report/mutation.rb +5 -5
  103. data/lib/mutant/reporter/cli/report/subject.rb +0 -2
  104. data/lib/mutant/reporter/null.rb +0 -2
  105. data/lib/mutant/runner.rb +0 -2
  106. data/lib/mutant/runner/config.rb +0 -2
  107. data/lib/mutant/runner/mutation.rb +0 -2
  108. data/lib/mutant/runner/subject.rb +0 -2
  109. data/lib/mutant/strategy.rb +0 -2
  110. data/lib/mutant/subject.rb +0 -2
  111. data/lib/mutant/subject/method.rb +0 -2
  112. data/lib/mutant/subject/method/instance.rb +1 -3
  113. data/lib/mutant/subject/method/singleton.rb +0 -2
  114. data/lib/mutant/version.rb +1 -3
  115. data/lib/mutant/zombifier.rb +0 -2
  116. data/meta/begin.rb +10 -0
  117. data/meta/case.rb +0 -2
  118. data/meta/def.rb +19 -0
  119. data/mutant-rspec.gemspec +1 -1
  120. data/mutant.gemspec +1 -1
  121. data/spec/integration/mutant/corpus_spec.rb +81 -22
  122. data/spec/integration/mutant/null_spec.rb +1 -3
  123. data/spec/integration/mutant/rspec_spec.rb +6 -8
  124. data/spec/integration/mutant/test_mutator_handles_types_spec.rb +0 -2
  125. data/spec/integration/mutant/zombie_spec.rb +0 -2
  126. data/spec/integrations.yml +12 -1
  127. data/spec/shared/method_matcher_behavior.rb +0 -2
  128. data/spec/spec_helper.rb +0 -2
  129. data/spec/support/compress_helper.rb +0 -2
  130. data/spec/support/ice_nine_config.rb +0 -2
  131. data/spec/support/rspec.rb +0 -2
  132. data/spec/support/test_app.rb +0 -2
  133. data/spec/unit/mutant/cli_new_spec.rb +0 -2
  134. data/spec/unit/mutant/cli_run_spec.rb +0 -2
  135. data/spec/unit/mutant/context/root_spec.rb +0 -2
  136. data/spec/unit/mutant/context/scope/root_spec.rb +0 -2
  137. data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +0 -2
  138. data/spec/unit/mutant/diff_spec.rb +0 -2
  139. data/spec/unit/mutant/expression/method_spec.rb +2 -4
  140. data/spec/unit/mutant/expression/namespace/flat_spec.rb +1 -3
  141. data/spec/unit/mutant/expression/namespace/recursive_spec.rb +10 -6
  142. data/spec/unit/mutant/isolation_spec.rb +61 -0
  143. data/spec/unit/mutant/loader/eval_spec.rb +0 -2
  144. data/spec/unit/mutant/matcher/chain_spec.rb +4 -15
  145. data/spec/unit/mutant/matcher/method/instance_spec.rb +0 -2
  146. data/spec/unit/mutant/matcher/method/singleton_spec.rb +0 -2
  147. data/spec/unit/mutant/matcher/methods/instance_spec.rb +0 -2
  148. data/spec/unit/mutant/matcher/methods/singleton_spec.rb +0 -2
  149. data/spec/unit/mutant/matcher/namespace_spec.rb +33 -31
  150. data/spec/unit/mutant/mutation_spec.rb +0 -2
  151. data/spec/unit/mutant/runner/config_spec.rb +0 -2
  152. data/spec/unit/mutant/runner/mutation_spec.rb +0 -2
  153. data/spec/unit/mutant/runner/subject_spec.rb +0 -2
  154. data/spec/unit/mutant/strategy_spec.rb +0 -2
  155. data/spec/unit/mutant/subject/context_spec.rb +0 -2
  156. data/spec/unit/mutant/subject/mutations_spec.rb +0 -2
  157. data/spec/unit/mutant/subject/node_spec.rb +0 -2
  158. data/spec/unit/mutant/subject_spec.rb +0 -2
  159. data/spec/unit/mutant/warning_filter_spec.rb +6 -0
  160. data/spec/unit/mutant_spec.rb +0 -55
  161. data/test_app/Gemfile.devtools +15 -11
  162. data/test_app/Gemfile.rspec3 +2 -2
  163. metadata +7 -7
  164. data/lib/mutant/constants.rb +0 -45
  165. data/spec/unit/mutant/mutator_spec.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b345e5eb8a65a538f350534528ca7c327bf2dde1
4
- data.tar.gz: b516b255a58425b77916f19dc5640c2e4e849393
3
+ metadata.gz: 2423eb3dea806c37511ba8f9e23e20215330d9a5
4
+ data.tar.gz: b5c6e0e92cc025a1d70f61727567d3ccd64578c7
5
5
  SHA512:
6
- metadata.gz: 6e1bcd22f9acf5400057b7dcac381f7c29ddf2dda558a422ed8b8d5d2c48189eeee17d3deee583cb0865ee3e2077f552b2451bc5743625f29739dca5bfb7021a
7
- data.tar.gz: b242006807e001093b1f22ef974c22900987901263ef39fe4d0e6ef651fe3b54ee79c8fa6a0fb46367228b7cb8e45822c60c0de250f5cd0ef31a3d039d19c93e
6
+ metadata.gz: 0afc928d562d4f8adc32e1b1f7ba6c20544ee1c5e304c60772ab1fe5e7d648549a8e8b3c325ee7d828cc285f7083eb649d0344b90fb81c0b42f60cb78152034b
7
+ data.tar.gz: a7d05e7b132dc61673c683630de8a503496167521e57e9b7e0c3d86e7049bd979f7201772af5d9e1b3bfc8980731373480725193c6f93afc89aafd084cd023f8
@@ -5,11 +5,8 @@ env:
5
5
  rvm:
6
6
  - 1.9.3
7
7
  - 2.0.0
8
- - 2.1.1
8
+ - 2.1.2
9
9
  - rbx-2
10
- matrix:
11
- allow_failures:
12
- - rvm: rbx-2
13
10
  notifications:
14
11
  irc:
15
12
  channels:
@@ -1,3 +1,12 @@
1
+ # v0.5.20 2014-06-15
2
+
3
+ * Remove support for matchers prefixed with ::
4
+ * Fix cases where mutated source diff was empty #198
5
+ * Fix mutate to simpler primitive violation break to next #203
6
+ * Improve integration / corpus tests to spot highlevel regressions on CI level.
7
+
8
+ * Remove support for matchers prefixed with ::
9
+
1
10
  # v0.5.19 2014-06-06
2
11
 
3
12
  Changes:
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  group :development do
4
- gem 'rake', '~> 10.3.1'
5
- gem 'rspec', '~> 2.99.0.beta2'
6
- gem 'rspec-core', '~> 2.99.0.beta2'
4
+ gem 'rake', '~> 10.3.2'
5
+ gem 'rspec', '~> 2.99.0'
6
+ gem 'rspec-core', '~> 2.99.0'
7
7
  gem 'yard', '~> 0.8.7.4'
8
8
 
9
9
  platform :rbx do
@@ -11,30 +11,34 @@ group :development do
11
11
  end
12
12
  end
13
13
 
14
+ group :yard do
15
+ gem 'kramdown', '~> 1.3.3'
16
+ end
17
+
14
18
  group :guard do
15
- gem 'guard', '~> 2.6.0'
19
+ gem 'guard', '~> 2.6.1'
16
20
  gem 'guard-bundler', '~> 2.0.0'
17
- gem 'guard-rspec', '~> 4.2.8'
21
+ gem 'guard-rspec', '~> 4.2.9'
18
22
  gem 'guard-rubocop', '~> 1.1.0'
19
23
 
20
24
  # file system change event handling
21
- gem 'listen', '~> 2.7.3'
25
+ gem 'listen', '~> 2.7.7'
22
26
  gem 'rb-fchange', '~> 0.0.6', require: false
23
27
  gem 'rb-fsevent', '~> 0.9.4', require: false
24
- gem 'rb-inotify', '~> 0.9.4', require: false
28
+ gem 'rb-inotify', '~> 0.9.5', require: false
25
29
 
26
30
  # notification handling
27
- gem 'libnotify', '~> 0.8.2', require: false
31
+ gem 'libnotify', '~> 0.8.3', require: false
28
32
  gem 'rb-notifu', '~> 0.0.4', require: false
29
33
  gem 'terminal-notifier-guard', '~> 1.5.3', require: false
30
34
  end
31
35
 
32
36
  group :metrics do
33
37
  gem 'coveralls', '~> 0.7.0'
34
- gem 'flay', '~> 2.4.0'
35
- gem 'flog', '~> 4.2.0'
38
+ gem 'flay', '~> 2.5.0'
39
+ gem 'flog', '~> 4.2.1'
36
40
  gem 'reek', '~> 1.3.7'
37
- gem 'rubocop', '~> 0.21.0'
41
+ gem 'rubocop', '~> 0.23.0'
38
42
  gem 'simplecov', '~> 0.7.1'
39
43
  gem 'yardstick', '~> 0.9.9'
40
44
 
data/README.md CHANGED
@@ -5,6 +5,8 @@ mutant
5
5
  [![Dependency Status](https://gemnasium.com/mbj/mutant.png)](https://gemnasium.com/mbj/mutant)
6
6
  [![Code Climate](https://codeclimate.com/github/mbj/mutant.png)](https://codeclimate.com/github/mbj/mutant)
7
7
  [![Inline docs](http://inch-ci.org/github/mbj/mutant.png)](http://inch-ci.org/github/mbj/mutant)
8
+ [![Gem Version](https://img.shields.io/gem/v/mutant.svg)](https://rubygems.org/gems/mutant)
9
+ [![Gittip](https://img.shields.io/gittip/mbj.svg)](https://gittip.com/mbj)
8
10
 
9
11
  Mutant is a mutation testing tool for ruby.
10
12
 
@@ -115,13 +117,13 @@ Examples
115
117
  ```
116
118
  cd virtus
117
119
  # Run mutant on virtus namespace
118
- mutant --include lib --require virtus --use rspec ::Virtus*
120
+ mutant --include lib --require virtus --use rspec Virtus*
119
121
  # Run mutant on specific virtus class
120
- mutant --include lib --require virtus --use rspec ::Virtus::Attribute
122
+ mutant --include lib --require virtus --use rspec Virtus::Attribute
121
123
  # Run mutant on specific virtus class method
122
- mutant --include lib --require virtus --use rspec ::Virtus::Attribute.build
124
+ mutant --include lib --require virtus --use rspec Virtus::Attribute.build
123
125
  # Run mutant on specific virtus instance method
124
- mutant --include lib --require virtus --use rspec ::Virtus::Attribute#type
126
+ mutant --include lib --require virtus --use rspec Virtus::Attribute#type
125
127
  ```
126
128
 
127
129
  Subjects
@@ -151,8 +153,10 @@ Donations
151
153
  I ([mbj](https://github.com/mbj)) build this and adjacent tools in my free time.
152
154
  LOTS of unaccounted time and fun already went into this project.
153
155
 
154
- You might consider to donate. I have a [gittip](https://gittip.com/mbj) account.
155
- Also I'm looking for sponsors. Email me if you are interested.
156
+ You might consider to donate if you like this tool.
157
+
158
+ * [![Gittip](https://img.shields.io/gittip/mbj.svg)](https://gittip.com/mbj)
159
+ * [![Flattr this](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/1823010/mbjmutant-on-GitHub)
156
160
 
157
161
  Support
158
162
  -------
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 18
3
- total_score: 883
3
+ total_score: 903
@@ -56,6 +56,7 @@ NestedIterators:
56
56
  - Mutant::CLI#parse
57
57
  - Mutant::Mutator::Util::Array::Element#dispatch
58
58
  - Mutant::Mutator::Node::Resbody#mutate_captures
59
+ - Mutant::Mutator::Node::Arguments#emit_argument_mutations
59
60
  - Mutant::Reporter::CLI::Report::Config#generic_stats
60
61
  - Mutant::RequireHighjack#infect
61
62
  - Mutant::RequireHighjack#desinfect
@@ -88,12 +89,13 @@ TooManyMethods:
88
89
  - Mutant::CLI
89
90
  - Mutant::Mutator::Node
90
91
  - Mutant::Reporter::CLI
92
+ - Mutant::Meta::Example::Verification
91
93
  max_methods: 10
92
94
  TooManyStatements:
93
95
  enabled: true
94
96
  exclude:
95
97
  - Mutant#self.singleton_subclass_instance
96
- - Mutant#self.isolate
98
+ - Mutant::Isolation#self.call
97
99
  - Mutant::Rspec::Killer#run
98
100
  - Mutant::Reporter::CLI#colorized_diff
99
101
  - Mutant::Reporter::CLI::Report::Config#run
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'stringio'
4
2
  require 'set'
5
3
  require 'adamantium'
@@ -26,6 +24,45 @@ module Mutant
26
24
  # The frozen empty array used within mutant
27
25
  EMPTY_ARRAY = [].freeze
28
26
 
27
+ symbolset = ->(strings) { strings.map(&:to_sym).to_set.freeze }
28
+
29
+ SCOPE_OPERATOR = '::'.freeze
30
+
31
+ # Set of nodes that cannot be on the LHS of an assignment
32
+ NOT_ASSIGNABLE = symbolset.(%w[int float str dstr class module self nil])
33
+ # Set of op-assign types
34
+ OP_ASSIGN = symbolset.call(%w[or_asgn and_asgn op_asgn])
35
+ # Set of node types that are not valid when emitted standalone
36
+ NOT_STANDALONE = symbolset.(%w[splat restarg block_pass])
37
+ INDEX_OPERATORS = symbolset.(%w[[] []=])
38
+ UNARY_METHOD_OPERATORS = symbolset.(%w[~@ +@ -@ !])
39
+
40
+ # Operators ruby implementeds as methods
41
+ METHOD_OPERATORS = symbolset.(%w[
42
+ <=> === []= [] <= >= == !~ != =~ <<
43
+ >> ** * % / | ^ & < > + - ~@ +@ -@ !
44
+ ])
45
+
46
+ BINARY_METHOD_OPERATORS = (
47
+ METHOD_OPERATORS - (INDEX_OPERATORS + UNARY_METHOD_OPERATORS)
48
+ ).to_set.freeze
49
+
50
+ OPERATOR_METHODS = (
51
+ METHOD_OPERATORS + INDEX_OPERATORS + UNARY_METHOD_OPERATORS
52
+ ).to_set.freeze
53
+
54
+ # Nodes that are NOT handled by mutant.
55
+ #
56
+ # not - 1.8 only, mutant does not support 1.8
57
+ #
58
+ NODE_BLACKLIST = symbolset.(%w[not])
59
+
60
+ # Nodes that are NOT generated by parser but used by mutant / unparser.
61
+ NODE_EXTRA = symbolset.(%w[empty])
62
+
63
+ # All node types mutant handles
64
+ NODE_TYPES = ((Parser::Meta::NODE_TYPES + NODE_EXTRA) - NODE_BLACKLIST).to_set.freeze
65
+
29
66
  # Lookup constant for location
30
67
  #
31
68
  # @param [String] location
@@ -35,7 +72,7 @@ module Mutant
35
72
  # @api private
36
73
  #
37
74
  def self.constant_lookup(location)
38
- location.sub(CBASE_PATTERN, EMPTY_STRING).split(SCOPE_OPERATOR).reduce(Object) do |parent, name|
75
+ location.split(SCOPE_OPERATOR).reduce(Object) do |parent, name|
39
76
  parent.const_get(name, nil)
40
77
  end
41
78
  end
@@ -51,43 +88,6 @@ module Mutant
51
88
  self
52
89
  end
53
90
 
54
- IsolationError = Class.new(RuntimeError)
55
-
56
- # Call block in isolation
57
- #
58
- # This isolation implements the fork strategy.
59
- # Future strategies will probably use a process pool that can
60
- # handle multiple mutation kills, in-isolation at once.
61
- #
62
- # @return [Object]
63
- #
64
- # @api private
65
- #
66
- def self.isolate(&block)
67
- reader, writer = IO.pipe.each(&:binmode)
68
-
69
- pid = fork do
70
- reader.close
71
- writer.write(Marshal.dump(block.call))
72
- end
73
-
74
- writer.close
75
-
76
- begin
77
- data = Marshal.load(reader.read)
78
- rescue ArgumentError
79
- raise IsolationError, 'Childprocess wrote un-unmarshallable data'
80
- end
81
-
82
- status = Process.waitpid2(pid).last
83
-
84
- unless status.exitstatus.zero?
85
- raise IsolationError, "Childprocess exited with nonzero exit status: #{status.exitstatus}"
86
- end
87
-
88
- data
89
- end
90
-
91
91
  # Define instance of subclassed superclass as constant
92
92
  #
93
93
  # @param [Class] superclass
@@ -120,9 +120,9 @@ require 'mutant/delegator'
120
120
  require 'mutant/node_helpers'
121
121
  require 'mutant/warning_filter'
122
122
  require 'mutant/warning_expectation'
123
- require 'mutant/constants'
124
123
  require 'mutant/walker'
125
124
  require 'mutant/require_highjack'
125
+ require 'mutant/isolation'
126
126
  require 'mutant/mutator'
127
127
  require 'mutant/mutation'
128
128
  require 'mutant/mutation/evil'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Mutant
4
2
  # An AST cache
5
3
  class Cache
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'optparse'
4
2
 
5
3
  module Mutant
@@ -120,9 +118,7 @@ module Mutant
120
118
  # @api private
121
119
  #
122
120
  def subject_selector
123
- if @subject_selectors.any?
124
- Morpher::Evaluator::Predicate::Boolean::Or.new(@subject_selectors)
125
- end
121
+ Morpher::Evaluator::Predicate::Boolean::Or.new(@subject_selectors) if @subject_selectors.any?
126
122
  end
127
123
 
128
124
  # Return predicate
@@ -153,6 +149,10 @@ module Mutant
153
149
  # Return subject rejector
154
150
  #
155
151
  # @return [#call]
152
+ # if there is a subject rejector
153
+ #
154
+ # @return [nil]
155
+ # otherwise
156
156
  #
157
157
  # @api private
158
158
  #
@@ -161,9 +161,7 @@ module Mutant
161
161
  Morpher.compile(s(:eql, s(:attribute, :identification), s(:static, subject.identification)))
162
162
  end
163
163
 
164
- if rejectors.any?
165
- Morpher::Evaluator::Predicate::Boolean::Or.new(rejectors)
166
- end
164
+ Morpher::Evaluator::Predicate::Boolean::Or.new(rejectors) if rejectors.any?
167
165
  end
168
166
  end
169
167
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Mutant
4
2
  # Class to colorize strings
5
3
  class Color
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Mutant
4
2
  # The configuration of a mutator run
5
3
  class Config
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Mutant
4
2
  # An abstract context where mutations can be appied to.
5
3
  class Context
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Mutant
4
2
  class Context
5
3
  # Scope context for mutation (Class or Module)
@@ -1,5 +1,7 @@
1
1
  module Mutant
2
+ # A simple delegator with opinions
2
3
  module Delegator
4
+ # Class level mixins
3
5
  module ClassMethods
4
6
 
5
7
  private
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Mutant
4
2
  # Class to create diffs from source code
5
3
  class Diff
@@ -8,7 +6,7 @@ module Mutant
8
6
  # Return source diff
9
7
  #
10
8
  # @return [String]
11
- # if there is a diff
9
+ # if there is exactly one diff
12
10
  #
13
11
  # @return [nil]
14
12
  # otherwise
@@ -16,19 +14,9 @@ module Mutant
16
14
  # @api private
17
15
  #
18
16
  def diff
19
- case diffs.length
20
- when 0
21
- nil
22
- when 1
23
- ::Diff::LCS::Hunk.new(old, new, diffs.first, max_length, 0)
24
- .diff(:unified) << "\n"
25
- else
26
- $stderr.puts(
27
- 'Mutation resulted in more than one diff, should not happen! ' \
28
- 'PLS report a bug!'
29
- )
30
- nil
31
- end
17
+ return unless diffs.length.equal?(1)
18
+ ::Diff::LCS::Hunk.new(old, new, diffs.first, max_length, 0)
19
+ .diff(:unified) << "\n"
32
20
  end
33
21
  memoize :diff
34
22
 
@@ -13,16 +13,16 @@ module Mutant
13
13
  *OPERATOR_METHODS.map(&:to_s)
14
14
  ).freeze
15
15
 
16
- SCOPE_PATTERN = /
17
- (?:#{SCOPE_OPERATOR})?#{SCOPE_NAME_PATTERN}
18
- (?:#{SCOPE_OPERATOR}#{SCOPE_NAME_PATTERN})*
19
- /x.freeze
16
+ SCOPE_PATTERN = /#{SCOPE_NAME_PATTERN}(?:#{SCOPE_OPERATOR}#{SCOPE_NAME_PATTERN})*/.freeze
20
17
 
21
18
  REGISTRY = {}
22
19
 
23
20
  # Initialize expression
24
21
  #
25
22
  # @param [MatchData] match
23
+ #
24
+ # @api private
25
+ #
26
26
  def initialize(*)
27
27
  super
28
28
  @syntax = match.to_s
@@ -42,6 +42,8 @@ module Mutant
42
42
  #
43
43
  # @return [Fixnum]
44
44
  #
45
+ # @api private
46
+ #
45
47
  def match_length(neddle)
46
48
  if eql?(neddle)
47
49
  syntax.length
@@ -99,9 +101,8 @@ module Mutant
99
101
  def self.expressions(input)
100
102
  REGISTRY.each_with_object([]) do |(regexp, klass), expressions|
101
103
  match = regexp.match(input)
102
- if match
103
- expressions << klass.new(match)
104
- end
104
+ next unless match
105
+ expressions << klass.new(match)
105
106
  end
106
107
  end
107
108
  private_class_method :expressions
@@ -9,15 +9,9 @@ module Mutant
9
9
  '#' => Matcher::Methods::Instance
10
10
  }.freeze
11
11
 
12
- regexp = /
13
- \A
14
- (?<scope_name>#{SCOPE_PATTERN})
15
- (?<scope_symbol>[.#])
16
- (?<method_name>#{METHOD_NAME_PATTERN})
17
- \z
18
- /x.freeze
19
-
20
- register(regexp)
12
+ register(
13
+ /\A(?<scope_name>#{SCOPE_PATTERN})(?<scope_symbol>[.#])(?<method_name>#{METHOD_NAME_PATTERN})\z/
14
+ )
21
15
 
22
16
  # Return method matcher
23
17
  #