mutant 0.5.18 → 0.5.19

Sign up to get free protection for your applications and to get access to all the features.
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
data/meta/rescue.rb CHANGED
@@ -3,27 +3,28 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'begin; rescue ExceptionA, ExceptionB => error; true; end'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  mutation 'begin; rescue ExceptionA, ExceptionB; true; end'
8
+ mutation 'begin; rescue self, ExceptionB => error; true; end'
9
+ mutation 'begin; rescue ExceptionA, self => error; true; end'
8
10
  mutation 'begin; rescue ExceptionA, ExceptionB => error; false; end'
9
11
  mutation 'begin; rescue ExceptionA, ExceptionB => error; nil; end'
10
- mutation 'begin; rescue ExceptionA => error; true; end'
11
- mutation 'begin; rescue ExceptionB => error; true; end'
12
12
  end
13
13
 
14
14
  Mutant::Meta::Example.add do
15
15
  source 'begin; rescue SomeException => error; true; end'
16
16
 
17
- mutation 'nil'
17
+ singleton_mutations
18
18
  mutation 'begin; rescue SomeException; true; end'
19
19
  mutation 'begin; rescue SomeException => error; false; end'
20
20
  mutation 'begin; rescue SomeException => error; nil; end'
21
+ mutation 'begin; rescue self => error; true; end'
21
22
  end
22
23
 
23
24
  Mutant::Meta::Example.add do
24
25
  source 'begin; rescue => error; true end'
25
26
 
26
- mutation 'nil'
27
+ singleton_mutations
27
28
  mutation 'begin; rescue => error; false; end'
28
29
  mutation 'begin; rescue => error; nil; end'
29
30
  mutation 'begin; rescue; true; end'
@@ -32,7 +33,7 @@ end
32
33
  Mutant::Meta::Example.add do
33
34
  source 'begin; rescue; true end'
34
35
 
35
- mutation 'nil'
36
+ singleton_mutations
36
37
  mutation 'begin; rescue; false; end'
37
38
  mutation 'begin; rescue; nil; end'
38
39
  end
data/meta/restarg.rb CHANGED
@@ -3,9 +3,11 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'foo(*bar)'
5
5
 
6
+ singleton_mutations
6
7
  mutation 'foo'
7
8
  mutation 'foo(nil)'
9
+ mutation 'foo(self)'
10
+ mutation 'foo(*self)'
8
11
  mutation 'foo(bar)'
9
12
  mutation 'foo(*nil)'
10
- mutation 'nil'
11
13
  end
data/meta/return.rb CHANGED
@@ -3,13 +3,14 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'return'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  end
8
8
 
9
9
  Mutant::Meta::Example.add do
10
10
  source 'return foo'
11
11
 
12
+ singleton_mutations
12
13
  mutation 'foo'
13
14
  mutation 'return nil'
14
- mutation 'nil'
15
+ mutation 'return self'
15
16
  end
data/meta/send.rb CHANGED
@@ -3,14 +3,14 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'reverse_each'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  mutation 'each'
8
8
  end
9
9
 
10
10
  Mutant::Meta::Example.add do
11
11
  source 'reverse_map'
12
12
 
13
- mutation 'nil'
13
+ singleton_mutations
14
14
  mutation 'map'
15
15
  mutation 'each'
16
16
  end
@@ -18,18 +18,20 @@ end
18
18
  Mutant::Meta::Example.add do
19
19
  source 'map'
20
20
 
21
- mutation 'nil'
21
+ singleton_mutations
22
22
  mutation 'each'
23
23
  end
24
24
 
25
25
  Mutant::Meta::Example.add do
26
26
  source 'foo == bar'
27
27
 
28
+ singleton_mutations
28
29
  mutation 'foo'
29
30
  mutation 'bar'
30
31
  mutation 'nil == bar'
32
+ mutation 'self == bar'
31
33
  mutation 'foo == nil'
32
- mutation 'nil'
34
+ mutation 'foo == self'
33
35
  mutation 'foo.eql?(bar)'
34
36
  mutation 'foo.equal?(bar)'
35
37
  end
@@ -37,43 +39,40 @@ end
37
39
  Mutant::Meta::Example.add do
38
40
  source 'foo.gsub(a, b)'
39
41
 
42
+ singleton_mutations
40
43
  mutation 'foo'
41
44
  mutation 'foo.gsub(a)'
42
45
  mutation 'foo.gsub(b)'
43
46
  mutation 'foo.gsub'
44
47
  mutation 'foo.sub(a, b)'
45
48
  mutation 'foo.gsub(a, nil)'
49
+ mutation 'foo.gsub(a, self)'
46
50
  mutation 'foo.gsub(nil, b)'
51
+ mutation 'foo.gsub(self, b)'
47
52
  mutation 'nil.gsub(a, b)'
48
- mutation 'nil'
53
+ mutation 'self.gsub(a, b)'
49
54
  end
50
55
 
51
56
  Mutant::Meta::Example.add do
52
57
  source 'foo.send(bar)'
53
58
 
59
+ singleton_mutations
54
60
  mutation 'foo.send'
55
61
  mutation 'foo.public_send(bar)'
56
62
  mutation 'bar'
57
63
  mutation 'foo'
64
+ mutation 'self.send(bar)'
58
65
  mutation 'foo.send(nil)'
66
+ mutation 'foo.send(self)'
59
67
  mutation 'nil.send(bar)'
60
- mutation 'nil'
61
68
  end
62
69
 
63
70
  Mutant::Meta::Example.add do
64
- source 'self.foo ||= expression'
71
+ source 'self.bar = baz'
65
72
 
66
- mutation 'self.foo ||= nil'
67
- mutation 'nil.foo ||= expression'
68
- mutation 'nil'
69
- end
70
-
71
- Mutant::Meta::Example.add do
72
- source 'self.bar=baz'
73
-
74
- mutation 'nil'
75
- mutation 'self.bar=nil'
76
- mutation 'self'
73
+ singleton_mutations
74
+ mutation 'self.bar = nil'
75
+ mutation 'self.bar = self'
77
76
  mutation 'self.bar'
78
77
  mutation 'baz'
79
78
  # This one could probably be removed
@@ -81,105 +80,107 @@ Mutant::Meta::Example.add do
81
80
  end
82
81
 
83
82
  Mutant::Meta::Example.add do
84
- source 'foo.bar=baz'
83
+ source 'foo.bar = baz'
85
84
 
85
+ singleton_mutations
86
86
  mutation 'foo'
87
- mutation 'nil'
88
- mutation 'foo.bar=nil'
87
+ mutation 'foo.bar = nil'
88
+ mutation 'foo.bar = self'
89
+ mutation 'self.bar = baz'
89
90
  mutation 'foo.bar'
90
91
  mutation 'baz'
91
92
  # This one could probably be removed
92
- mutation 'nil.bar=baz'
93
+ mutation 'nil.bar = baz'
93
94
  end
94
95
 
95
96
  Mutant::Meta::Example.add do
96
97
  source 'foo[bar]=baz'
97
98
 
99
+ singleton_mutations
98
100
  mutation 'foo'
99
- mutation 'nil'
100
101
  end
101
102
 
102
103
  Mutant::Meta::Example.add do
103
104
  source 'foo(*bar)'
104
105
 
106
+ singleton_mutations
105
107
  mutation 'foo'
106
108
  mutation 'foo(nil)'
107
109
  mutation 'foo(bar)'
110
+ mutation 'foo(self)'
108
111
  mutation 'foo(*nil)'
109
- mutation 'nil'
112
+ mutation 'foo(*self)'
110
113
  end
111
114
 
112
115
  Mutant::Meta::Example.add do
113
116
  source 'foo(&bar)'
114
117
 
118
+ singleton_mutations
115
119
  mutation 'foo'
116
- mutation 'nil'
117
120
  end
118
121
 
119
122
  Mutant::Meta::Example.add do
120
123
  source 'foo[*bar]'
121
124
 
125
+ singleton_mutations
122
126
  mutation 'foo'
123
- mutation 'nil'
124
127
  end
125
128
 
126
129
  Mutant::Meta::Example.add do
127
130
  source 'foo'
128
131
 
129
- mutation 'nil'
132
+ singleton_mutations
130
133
  end
131
134
 
132
135
  Mutant::Meta::Example.add do
133
136
  source 'self.foo'
134
137
 
138
+ singleton_mutations
135
139
  mutation 'foo'
136
- mutation 'self'
137
140
  mutation 'nil.foo'
138
- mutation 'nil'
139
141
  end
140
142
 
141
143
  Unparser::Constants::KEYWORDS.each do |keyword|
142
144
  Mutant::Meta::Example.add do
143
145
  source "self.#{keyword}"
144
146
 
147
+ singleton_mutations
145
148
  mutation "nil.#{keyword}"
146
- mutation 'nil'
147
- mutation 'self'
148
149
  end
149
150
  end
150
151
 
151
152
  Mutant::Meta::Example.add do
152
153
  source 'foo.bar'
153
154
 
155
+ singleton_mutations
154
156
  mutation 'foo'
155
157
  mutation 'nil.bar'
156
- mutation 'nil'
158
+ mutation 'self.bar'
157
159
  end
158
160
 
159
161
  Mutant::Meta::Example.add do
160
162
  source 'self.class.foo'
161
163
 
164
+ singleton_mutations
162
165
  mutation 'self.class'
163
166
  mutation 'self.foo'
164
167
  mutation 'nil.class.foo'
165
168
  mutation 'nil.foo'
166
- mutation 'nil'
167
169
  end
168
170
 
169
171
  Mutant::Meta::Example.add do
170
172
  source 'foo(nil)'
171
173
 
174
+ singleton_mutations
172
175
  mutation 'foo'
173
- mutation 'nil'
174
176
  end
175
177
 
176
178
  Mutant::Meta::Example.add do
177
179
  source 'self.foo(nil)'
178
180
 
179
- mutation 'self'
181
+ singleton_mutations
180
182
  mutation 'self.foo'
181
183
  mutation 'foo(nil)'
182
- mutation 'nil'
183
184
  mutation 'nil.foo(nil)'
184
185
  end
185
186
 
@@ -187,54 +188,50 @@ Unparser::Constants::KEYWORDS.each do |keyword|
187
188
  Mutant::Meta::Example.add do
188
189
  source "foo.#{keyword}(nil)"
189
190
 
191
+ singleton_mutations
192
+ mutation "self.#{keyword}(nil)"
190
193
  mutation "foo.#{keyword}"
191
194
  mutation 'foo'
192
195
  mutation "nil.#{keyword}(nil)"
193
- mutation 'nil'
194
196
  end
195
197
  end
196
198
 
197
199
  Mutant::Meta::Example.add do
198
200
  source 'foo(nil, nil)'
199
201
 
202
+ singleton_mutations
200
203
  mutation 'foo()'
201
204
  mutation 'foo(nil)'
202
- mutation 'nil'
203
205
  end
204
206
 
205
207
  Mutant::Meta::Example.add do
206
208
  source '(left - right) / foo'
207
209
 
210
+ singleton_mutations
208
211
  mutation 'foo'
209
212
  mutation '(left - right)'
210
213
  mutation 'left / foo'
211
214
  mutation 'right / foo'
212
215
  mutation '(left - right) / nil'
216
+ mutation '(left - right) / self'
213
217
  mutation '(left - nil) / foo'
218
+ mutation '(left - self) / foo'
214
219
  mutation '(nil - right) / foo'
220
+ mutation '(self - right) / foo'
215
221
  mutation 'nil / foo'
216
- mutation 'nil'
222
+ mutation 'self / foo'
217
223
  end
218
224
 
219
225
  (Mutant::BINARY_METHOD_OPERATORS - [:==, :eql?]).each do |operator|
220
226
  Mutant::Meta::Example.add do
221
227
  source "true #{operator} false"
222
228
 
229
+ singleton_mutations
230
+ mutation 'true'
231
+ mutation 'false'
223
232
  mutation "false #{operator} false"
224
233
  mutation "nil #{operator} false"
225
234
  mutation "true #{operator} true"
226
235
  mutation "true #{operator} nil"
227
- mutation 'true'
228
- mutation 'false'
229
- mutation 'nil'
230
- end
231
-
232
- Mutant::Meta::Example.add do
233
- source "left #{operator} right"
234
- mutation 'left'
235
- mutation 'right'
236
- mutation "left #{operator} nil"
237
- mutation "nil #{operator} right"
238
- mutation 'nil'
239
236
  end
240
237
  end
@@ -3,5 +3,5 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '"foo"'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  end
data/meta/super.rb CHANGED
@@ -3,24 +3,27 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'super'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  end
8
8
 
9
9
  Mutant::Meta::Example.add do
10
10
  source 'super()'
11
11
 
12
+ singleton_mutations
13
+ # this is zsuper a totally differend node thant super()
12
14
  mutation 'super'
13
- mutation 'nil'
14
15
  end
15
16
 
16
17
  Mutant::Meta::Example.add do
17
18
  source 'super(foo, bar)'
18
19
 
20
+ singleton_mutations
19
21
  mutation 'super'
20
22
  mutation 'super()'
21
23
  mutation 'super(foo)'
22
24
  mutation 'super(bar)'
23
25
  mutation 'super(foo, nil)'
26
+ mutation 'super(foo, self)'
24
27
  mutation 'super(nil, bar)'
25
- mutation 'nil'
28
+ mutation 'super(self, bar)'
26
29
  end
data/meta/symbol.rb CHANGED
@@ -3,6 +3,6 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source ':foo'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  mutation ':foo__mutant__'
8
8
  end
data/meta/true.rb ADDED
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ Mutant::Meta::Example.add do
4
+ source 'true'
5
+
6
+ mutation 'nil'
7
+ mutation 'false'
8
+ end
data/meta/until.rb ADDED
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ Mutant::Meta::Example.add do
4
+ source 'until true; foo; bar; end'
5
+
6
+ singleton_mutations
7
+ mutation 'until true; bar; end'
8
+ mutation 'until true; foo; end'
9
+ mutation 'until true; end'
10
+ mutation 'until false; foo; bar; end'
11
+ mutation 'until nil; foo; bar; end'
12
+ mutation 'until true; foo; nil; end'
13
+ mutation 'until true; foo; self; end'
14
+ mutation 'until true; nil; bar; end'
15
+ mutation 'until true; self; bar; end'
16
+ mutation 'until true; raise; end'
17
+ end
data/meta/while.rb CHANGED
@@ -3,6 +3,9 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'while true; foo; bar; end'
5
5
 
6
+ singleton_mutations
7
+ mutation 'while true; self; bar; end'
8
+ mutation 'while true; foo; self; end'
6
9
  mutation 'while true; bar; end'
7
10
  mutation 'while true; foo; end'
8
11
  mutation 'while true; end'
@@ -11,14 +14,13 @@ Mutant::Meta::Example.add do
11
14
  mutation 'while true; foo; nil; end'
12
15
  mutation 'while true; nil; bar; end'
13
16
  mutation 'while true; raise; end'
14
- mutation 'nil'
15
17
  end
16
18
 
17
19
  Mutant::Meta::Example.add do
18
20
  source 'while true; end'
19
21
 
22
+ singleton_mutations
20
23
  mutation 'while true; raise; end'
21
24
  mutation 'while false; end'
22
25
  mutation 'while nil; end'
23
- mutation 'nil'
24
26
  end