mutant 0.5.18 → 0.5.19

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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +7 -0
  3. data/README.md +2 -2
  4. data/config/flay.yml +1 -1
  5. data/lib/mutant.rb +4 -1
  6. data/lib/mutant/meta/example/dsl.rb +11 -0
  7. data/lib/mutant/mutator/node.rb +29 -5
  8. data/lib/mutant/mutator/node/and_asgn.rb +34 -0
  9. data/lib/mutant/mutator/node/binary.rb +1 -1
  10. data/lib/mutant/mutator/node/block.rb +1 -1
  11. data/lib/mutant/mutator/node/break.rb +29 -0
  12. data/lib/mutant/mutator/node/case.rb +1 -1
  13. data/lib/mutant/mutator/node/conditional_loop.rb +1 -1
  14. data/lib/mutant/mutator/node/const.rb +1 -1
  15. data/lib/mutant/mutator/node/defined.rb +30 -0
  16. data/lib/mutant/mutator/node/dstr.rb +1 -1
  17. data/lib/mutant/mutator/node/dsym.rb +1 -1
  18. data/lib/mutant/mutator/node/generic.rb +1 -1
  19. data/lib/mutant/mutator/node/if.rb +4 -2
  20. data/lib/mutant/mutator/node/kwbegin.rb +1 -1
  21. data/lib/mutant/mutator/node/literal/array.rb +1 -1
  22. data/lib/mutant/mutator/node/literal/fixnum.rb +1 -1
  23. data/lib/mutant/mutator/node/literal/float.rb +1 -1
  24. data/lib/mutant/mutator/node/literal/hash.rb +1 -1
  25. data/lib/mutant/mutator/node/literal/range.rb +1 -1
  26. data/lib/mutant/mutator/node/literal/regex.rb +1 -1
  27. data/lib/mutant/mutator/node/literal/string.rb +1 -1
  28. data/lib/mutant/mutator/node/literal/symbol.rb +1 -1
  29. data/lib/mutant/mutator/node/masgn.rb +1 -1
  30. data/lib/mutant/mutator/node/match_current_line.rb +1 -1
  31. data/lib/mutant/mutator/node/named_value/access.rb +1 -1
  32. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +1 -1
  33. data/lib/mutant/mutator/node/{loop_control.rb → next.rb} +5 -9
  34. data/lib/mutant/mutator/node/op_asgn.rb +9 -4
  35. data/lib/mutant/mutator/node/or_asgn.rb +6 -2
  36. data/lib/mutant/mutator/node/resbody.rb +2 -2
  37. data/lib/mutant/mutator/node/return.rb +1 -1
  38. data/lib/mutant/mutator/node/send.rb +1 -1
  39. data/lib/mutant/mutator/node/splat.rb +1 -1
  40. data/lib/mutant/mutator/node/super.rb +1 -1
  41. data/lib/mutant/mutator/node/yield.rb +1 -1
  42. data/lib/mutant/mutator/node/zsuper.rb +1 -1
  43. data/lib/mutant/node_helpers.rb +6 -5
  44. data/lib/mutant/version.rb +1 -1
  45. data/meta/and.rb +1 -1
  46. data/meta/and_asgn.rb +3 -1
  47. data/meta/array.rb +2 -2
  48. data/meta/block.rb +6 -4
  49. data/meta/block_pass.rb +1 -1
  50. data/meta/blockarg.rb +1 -1
  51. data/meta/break.rb +1 -2
  52. data/meta/case.rb +104 -183
  53. data/meta/cbase.rb +1 -1
  54. data/meta/const.rb +1 -1
  55. data/meta/cvar.rb +1 -1
  56. data/meta/cvasgn.rb +1 -1
  57. data/meta/{define.rb → def.rb} +2 -1
  58. data/meta/dstr.rb +4 -1
  59. data/meta/dsym.rb +4 -2
  60. data/meta/ensure.rb +1 -1
  61. data/meta/false.rb +8 -0
  62. data/meta/float.rb +3 -4
  63. data/meta/gvar.rb +1 -1
  64. data/meta/gvasgn.rb +1 -1
  65. data/meta/hash.rb +1 -2
  66. data/meta/if.rb +25 -27
  67. data/meta/{fixnum.rb → int.rb} +1 -2
  68. data/meta/ivasgn.rb +1 -1
  69. data/meta/kwbegin.rb +1 -1
  70. data/meta/lvar.rb +2 -0
  71. data/meta/lvasgn.rb +1 -1
  72. data/meta/masgn.rb +1 -1
  73. data/meta/match_current_line.rb +1 -1
  74. data/meta/next.rb +1 -1
  75. data/meta/op_assgn.rb +3 -1
  76. data/meta/{binary.rb → or.rb} +1 -1
  77. data/meta/or_asgn.rb +4 -2
  78. data/meta/range.rb +6 -2
  79. data/meta/regex.rb +4 -2
  80. data/meta/rescue.rb +7 -6
  81. data/meta/restarg.rb +3 -1
  82. data/meta/return.rb +3 -2
  83. data/meta/send.rb +48 -51
  84. data/meta/{string.rb → str.rb} +1 -1
  85. data/meta/super.rb +6 -3
  86. data/meta/symbol.rb +1 -1
  87. data/meta/true.rb +8 -0
  88. data/meta/until.rb +17 -0
  89. data/meta/while.rb +4 -2
  90. data/meta/yield.rb +1 -1
  91. data/spec/spec_helper.rb +1 -1
  92. metadata +13 -8
  93. data/meta/unless.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e86610168e1a64b920f694f5854137186fb808e0
4
- data.tar.gz: e33eeafaebdb1a32042f56e03ed0794e25056f16
3
+ metadata.gz: b345e5eb8a65a538f350534528ca7c327bf2dde1
4
+ data.tar.gz: b516b255a58425b77916f19dc5640c2e4e849393
5
5
  SHA512:
6
- metadata.gz: 6237bcc40f7b53097546148fe68488f7b8af9e7c5e9b348cc3fa2811a3fb860f9b92b551ad3daf7aed87158061cc0ade88e894154352f54c6b50a2b0effee5d9
7
- data.tar.gz: 42a09a5d0011978606d9ee12fae5bc1b9d4f2919a11aa783dcdc088f22127edd99fbb66a42c1ef7ab2c04efbc842b15c2e8f13af0ffa33ae3c481059ef4495b6
6
+ metadata.gz: 6e1bcd22f9acf5400057b7dcac381f7c29ddf2dda558a422ed8b8d5d2c48189eeee17d3deee583cb0865ee3e2077f552b2451bc5743625f29739dca5bfb7021a
7
+ data.tar.gz: b242006807e001093b1f22ef974c22900987901263ef39fe4d0e6ef651fe3b54ee79c8fa6a0fb46367228b7cb8e45822c60c0de250f5cd0ef31a3d039d19c93e
data/Changelog.md CHANGED
@@ -1,3 +1,10 @@
1
+ # v0.5.19 2014-06-06
2
+
3
+ Changes:
4
+
5
+ * Do not emit more powerful rescue matchers #183
6
+ * Do not emit more powerful loop control #201
7
+
1
8
  # v0.5.18 2014-06-04
2
9
 
3
10
  Changes:
data/README.md CHANGED
@@ -4,7 +4,7 @@ mutant
4
4
  [![Build Status](https://secure.travis-ci.org/mbj/mutant.png?branch=master)](http://travis-ci.org/mbj/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
- [![Inline docs](http://inch-pages.github.io/github/mbj/mutant.png)](http://inch-pages.github.io/github/mbj/mutant)
7
+ [![Inline docs](http://inch-ci.org/github/mbj/mutant.png)](http://inch-ci.org/github/mbj/mutant)
8
8
 
9
9
  Mutant is a mutation testing tool for ruby.
10
10
 
@@ -27,7 +27,7 @@ There are some presentations about mutant in the wild:
27
27
 
28
28
  * [RailsConf 2014](http://railsconf.com/) / http://confreaks.com/videos/3333-railsconf-mutation-testing-with-mutant
29
29
  * [Wrocloverb 2014](http://wrocloverb.com/) / https://www.youtube.com/watch?v=rz-lFKEioLk
30
- * [Eurocamp-2013](http://2013.eurucamp.org/) / FrOSCon-2013 http://slid.es/markusschirp/mutation-testing
30
+ * [eurucamp 2013](http://2013.eurucamp.org/) / FrOSCon-2013 http://slid.es/markusschirp/mutation-testing
31
31
  * [Cologne.rb](http://www.colognerb.de/topics/mutation-testing-mit-mutant) / https://github.com/DonSchado/colognerb-on-mutant/blob/master/mutation_testing_slides.pdf
32
32
 
33
33
  Blog-Posts
data/config/flay.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 18
3
- total_score: 849
3
+ total_score: 883
data/lib/mutant.rb CHANGED
@@ -156,9 +156,12 @@ require 'mutant/mutator/node/kwbegin'
156
156
  require 'mutant/mutator/node/named_value/access'
157
157
  require 'mutant/mutator/node/named_value/constant_assignment'
158
158
  require 'mutant/mutator/node/named_value/variable_assignment'
159
- require 'mutant/mutator/node/loop_control'
159
+ require 'mutant/mutator/node/next'
160
+ require 'mutant/mutator/node/break'
160
161
  require 'mutant/mutator/node/noop'
161
162
  require 'mutant/mutator/node/or_asgn'
163
+ require 'mutant/mutator/node/and_asgn'
164
+ require 'mutant/mutator/node/defined'
162
165
  require 'mutant/mutator/node/op_asgn'
163
166
  require 'mutant/mutator/node/conditional_loop'
164
167
  require 'mutant/mutator/node/yield'
@@ -74,6 +74,17 @@ module Mutant
74
74
  self
75
75
  end
76
76
 
77
+ # Add singleotn mutations
78
+ #
79
+ # @return [undefined]
80
+ #
81
+ # @api private
82
+ #
83
+ def singleton_mutations
84
+ mutation 'nil'
85
+ mutation 'self'
86
+ end
87
+
77
88
  # Helper method to coerce input to node
78
89
  #
79
90
  # @param [String,Parser::AST::Node] input
@@ -23,8 +23,8 @@ module Mutant
23
23
  children.at(index)
24
24
  end
25
25
 
26
- define_method("emit_#{name}_mutations") do
27
- mutate_child(index)
26
+ define_method("emit_#{name}_mutations") do |&block|
27
+ mutate_child(index, &block)
28
28
  end
29
29
 
30
30
  define_method("emit_#{name}") do |node|
@@ -118,10 +118,13 @@ module Mutant
118
118
  #
119
119
  # @api private
120
120
  #
121
- def mutate_child(index, mutator = Mutator)
121
+ def mutate_child(index, mutator = Mutator, &block)
122
+ block ||= lambda { |_node| true }
122
123
  child = children.at(index)
123
124
  mutator.each(child, self) do |mutation|
124
- emit_child_update(index, mutation)
125
+ if block.call(mutation)
126
+ emit_child_update(index, mutation)
127
+ end
125
128
  end
126
129
  end
127
130
 
@@ -166,7 +169,28 @@ module Mutant
166
169
  emit(new_self(*children))
167
170
  end
168
171
 
169
- # Emit a new AST node with NilLiteral class
172
+ # Emit singleton literals
173
+ #
174
+ # @return [undefined]
175
+ #
176
+ # @api private
177
+ #
178
+ def emit_singletons
179
+ emit_nil
180
+ emit_self
181
+ end
182
+
183
+ # Emit a literal self
184
+ #
185
+ # @return [undefined]
186
+ #
187
+ # @api private
188
+ #
189
+ def emit_self
190
+ emit(N_SELF)
191
+ end
192
+
193
+ # Emit a literal nil
170
194
  #
171
195
  # @return [undefined]
172
196
  #
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ module Mutant
4
+ class Mutator
5
+ class Node
6
+
7
+ # OpAsgn mutator
8
+ class AndAsgn < self
9
+
10
+ handle(:and_asgn)
11
+
12
+ children :left, :right
13
+
14
+ private
15
+
16
+ # Emit mutations
17
+ #
18
+ # @return [undefined]
19
+ #
20
+ # @api private
21
+ #
22
+ def dispatch
23
+ emit_singletons
24
+ emit_left_mutations do |mutation|
25
+ !mutation.type.equal?(:self)
26
+ end
27
+ emit_right_mutations
28
+ end
29
+
30
+ end # OrAsgn
31
+ end # Node
32
+ end # Mutator
33
+ end # Mutant
34
+
@@ -24,7 +24,7 @@ module Mutant
24
24
  # @api private
25
25
  #
26
26
  def dispatch
27
- emit_nil
27
+ emit_singletons
28
28
  emit(left)
29
29
  emit(right)
30
30
  mutate_operator
@@ -19,6 +19,7 @@ module Mutant
19
19
  # @api private
20
20
  #
21
21
  def dispatch
22
+ emit_singletons
22
23
  emit(send)
23
24
  emit_arguments_mutations
24
25
  if body
@@ -26,7 +27,6 @@ module Mutant
26
27
  end
27
28
  emit_body(nil)
28
29
  emit_body(RAISE)
29
- emit_nil
30
30
  end
31
31
 
32
32
  end # Block
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ module Mutant
4
+ class Mutator
5
+ class Node
6
+
7
+ # Mutator for loop control keywords
8
+ class Break < Generic
9
+
10
+ handle(:break)
11
+
12
+ private
13
+
14
+ # Emit mutations
15
+ #
16
+ # @return [undefined]
17
+ #
18
+ # @api private
19
+ #
20
+ def dispatch
21
+ super
22
+ emit_singletons
23
+ children.each_index(&method(:delete_child))
24
+ end
25
+
26
+ end # Break
27
+ end # Node
28
+ end # Mutator
29
+ end # Mutant
@@ -20,10 +20,10 @@ module Mutant
20
20
  # @api private
21
21
  #
22
22
  def dispatch
23
+ emit_singletons
23
24
  emit_condition_mutations if condition
24
25
  emit_when_mutations
25
26
  emit_else_mutations
26
- emit_nil
27
27
  end
28
28
 
29
29
  # Emit when mutations
@@ -20,11 +20,11 @@ module Mutant
20
20
  # @api private
21
21
  #
22
22
  def dispatch
23
+ emit_singletons
23
24
  emit_condition_mutations
24
25
  emit_body_mutations if body
25
26
  emit_body(nil)
26
27
  emit_body(RAISE)
27
- emit_nil
28
28
  end
29
29
 
30
30
  end # While
@@ -18,7 +18,7 @@ module Mutant
18
18
  # @api private
19
19
  #
20
20
  def dispatch
21
- emit_nil unless parent_type == :const
21
+ emit_singletons unless parent_type == :const
22
22
  emit_type(nil, *children.drop(1))
23
23
  children.each_with_index do |child, index|
24
24
  mutate_child(index) if child.kind_of?(Parser::AST::Node)
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ module Mutant
4
+ class Mutator
5
+ class Node
6
+ # Namespace for define mutations
7
+ class Defined < self
8
+
9
+ handle(:defined?)
10
+
11
+ children :expression
12
+
13
+ private
14
+
15
+ # Emit mutations
16
+ #
17
+ # @return [undefined]
18
+ #
19
+ # @api private
20
+ #
21
+ def dispatch
22
+ emit_expression_mutations do |node|
23
+ !node.type.equal?(:self)
24
+ end
25
+ end
26
+
27
+ end # Defined
28
+ end # Node
29
+ end # Mutator
30
+ end # Mutant
@@ -19,7 +19,7 @@ module Mutant
19
19
  #
20
20
  def dispatch
21
21
  super
22
- emit_nil
22
+ emit_singletons
23
23
  end
24
24
 
25
25
  end # Dstr
@@ -19,7 +19,7 @@ module Mutant
19
19
  #
20
20
  def dispatch
21
21
  super
22
- emit_nil
22
+ emit_singletons
23
23
  end
24
24
 
25
25
  end # Dsym
@@ -10,7 +10,7 @@ module Mutant
10
10
  # These nodes still need a dedicated mutator,
11
11
  # your contribution is that close!
12
12
  handle(
13
- :ensure, :redo, :defined?, :regopt, :retry, :arg_expr,
13
+ :ensure, :redo, :regopt, :retry, :arg_expr,
14
14
  :kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
15
15
  :alias, :for, :xstr, :back_ref, :class,
16
16
  :sclass, :match_with_lvasgn, :while_post,
@@ -19,10 +19,10 @@ module Mutant
19
19
  # @api private
20
20
  #
21
21
  def dispatch
22
+ emit_singletons
22
23
  mutate_condition
23
24
  mutate_if_branch
24
25
  mutate_else_branch
25
- emit_nil
26
26
  end
27
27
 
28
28
  # Emit conditon mutations
@@ -32,7 +32,9 @@ module Mutant
32
32
  # @api private
33
33
  #
34
34
  def mutate_condition
35
- emit_condition_mutations
35
+ emit_condition_mutations do |condition|
36
+ !condition.type.eql?(:self)
37
+ end
36
38
  emit_type(n_not(condition), if_branch, else_branch) unless condition.type == :match_current_line
37
39
  emit_type(N_TRUE, if_branch, else_branch)
38
40
  emit_type(N_FALSE, if_branch, else_branch)
@@ -19,7 +19,7 @@ module Mutant
19
19
  #
20
20
  def dispatch
21
21
  super
22
- emit_nil
22
+ emit_singletons
23
23
  end
24
24
 
25
25
  end # Kwbegin
@@ -18,7 +18,7 @@ module Mutant
18
18
  # @api private
19
19
  #
20
20
  def dispatch
21
- emit_nil
21
+ emit_singletons
22
22
  emit_type
23
23
  mutate_body
24
24
  if children.one?
@@ -18,7 +18,7 @@ module Mutant
18
18
  # @api private
19
19
  #
20
20
  def dispatch
21
- emit_nil
21
+ emit_singletons
22
22
  emit_values(values)
23
23
  end
24
24
 
@@ -18,7 +18,7 @@ module Mutant
18
18
  # @api private
19
19
  #
20
20
  def dispatch
21
- emit_nil
21
+ emit_singletons
22
22
  emit_values(values)
23
23
  emit_special_cases
24
24
  end
@@ -18,7 +18,7 @@ module Mutant
18
18
  # @api private
19
19
  #
20
20
  def dispatch
21
- emit_nil
21
+ emit_singletons
22
22
  emit_type
23
23
  mutate_body
24
24
  end
@@ -26,7 +26,7 @@ module Mutant
26
26
  # @api private
27
27
  #
28
28
  def dispatch
29
- emit_nil
29
+ emit_singletons
30
30
  emit_inverse
31
31
  emit_lower_bound_mutations
32
32
  emit_upper_bound_mutations
@@ -31,7 +31,7 @@ module Mutant
31
31
  # @api private
32
32
  #
33
33
  def dispatch
34
- emit_nil unless parent_type == :match_current_line
34
+ emit_singletons unless parent_type == :match_current_line
35
35
  children.each_with_index do |child, index|
36
36
  mutate_child(index) unless child.type == :str
37
37
  end
@@ -18,7 +18,7 @@ module Mutant
18
18
  # @api private
19
19
  #
20
20
  def dispatch
21
- emit_nil
21
+ emit_singletons
22
22
  end
23
23
 
24
24
  end # String
@@ -22,7 +22,7 @@ module Mutant
22
22
  # @api private
23
23
  #
24
24
  def dispatch
25
- emit_nil
25
+ emit_singletons
26
26
  Mutator::Util::Symbol.each(value, self) do |value|
27
27
  emit_type(value)
28
28
  end