mutant 0.5.20 → 0.5.21

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2423eb3dea806c37511ba8f9e23e20215330d9a5
4
- data.tar.gz: b5c6e0e92cc025a1d70f61727567d3ccd64578c7
3
+ metadata.gz: bb04983424f2bdda11781922b9b9a90d8463fed9
4
+ data.tar.gz: f5cef219a943e5fbd397eda833de9417bcd22c98
5
5
  SHA512:
6
- metadata.gz: 0afc928d562d4f8adc32e1b1f7ba6c20544ee1c5e304c60772ab1fe5e7d648549a8e8b3c325ee7d828cc285f7083eb649d0344b90fb81c0b42f60cb78152034b
7
- data.tar.gz: a7d05e7b132dc61673c683630de8a503496167521e57e9b7e0c3d86e7049bd979f7201772af5d9e1b3bfc8980731373480725193c6f93afc89aafd084cd023f8
6
+ metadata.gz: 10a6082273ed23f530a06a28e19cf2aa8d00840b0844753e4bc797605145110d831a2e0b29516b5f0c1b1372ac2a9163ea67f7a7340fc7b13ba955e0dc6ca775
7
+ data.tar.gz: 3b5acb587ca255095568ac721b8fe733c8e35a1b54d723070a0d92d247bfcc7e3d08a52be4de0bc7925af25233e6e5b2bae7c557c6837dfb9fa373487056b0b9
data/Changelog.md CHANGED
@@ -1,4 +1,10 @@
1
- # v0.5.20 2014-06-15
1
+ # v0.5.21 2014-06-15
2
+
3
+ * Readd mutation of index assignments
4
+ * Remove a bunch of useless mutations to nil.something
5
+ * Readd mutation of index reference arguments
6
+
7
+ # v0.5.20 2014-06-14
2
8
 
3
9
  * Remove support for matchers prefixed with ::
4
10
  * Fix cases where mutated source diff was empty #198
data/TODO CHANGED
@@ -10,7 +10,6 @@ Mutations:
10
10
  * Replace nil or add "do not touch me object" to literal mutations.
11
11
  * Mutate options on Regexp literals
12
12
  * Add mutations for dynamic regexp symbol and string literals
13
- * Mutate "def foo; bar; end" to "def foo; self; end"?
14
13
  * Mutate Block catch "def foo(&block)" and block pass "foo(&block)"
15
14
  * Binary operator mutations
16
15
  * Add timeout to terminate infinite loops
@@ -22,15 +21,6 @@ Mutations:
22
21
  Loader:
23
22
  * Make sure loader does not change visibility of injected mutants
24
23
 
25
- Killers:
26
- * Move test framework specific stuff to strategy
27
- * Add a general master <=> killer IPC interface. So different strategies of isolation
28
- (fork, vs jruby runtime creation) will work without big impact.
29
-
30
- Strategy:
31
- * Aggregate warnings on missing spec files
32
- * Provide "expicit files to kill with" strategy
33
-
34
24
  Matcher:
35
25
  * Allow matches on attr_reader with literal name argument(s)?
36
26
  * Allow matches on define_method with literal name argument?
data/config/flay.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 18
3
- total_score: 903
3
+ total_score: 906
data/config/reek.yml CHANGED
@@ -111,7 +111,7 @@ TooManyStatements:
111
111
  - Mutant::CLI#parse
112
112
  - Mutant::CLI#initialize
113
113
  - Mutant::CLI#add_debug_options
114
- max_statements: 6
114
+ max_statements: 7
115
115
  UncommunicativeMethodName:
116
116
  enabled: true
117
117
  exclude:
@@ -19,9 +19,11 @@ module Mutant
19
19
  :== => [:eql?, :equal?]
20
20
  )
21
21
 
22
- INDEX_REFERENCE = :[]
23
- INDEX_ASSIGN = :[]=
24
- ASSIGN_SUFFIX = '='.freeze
22
+ INDEX_REFERENCE = :[]
23
+ INDEX_ASSIGN = :[]=
24
+ VARIABLE_ASSIGN = :'='
25
+ ASSIGNMENT_OPERATORS = [INDEX_ASSIGN, VARIABLE_ASSIGN].to_set.freeze
26
+ ATTRIBUTE_ASSIGNMENT = /\A[a-z\d_]+=\z/.freeze
25
27
 
26
28
  private
27
29
 
@@ -33,10 +35,7 @@ module Mutant
33
35
  #
34
36
  def dispatch
35
37
  emit_singletons
36
- case selector
37
- when INDEX_REFERENCE
38
- run(Index::Reference)
39
- when INDEX_ASSIGN
38
+ if selector.equal?(INDEX_ASSIGN)
40
39
  run(Index::Assign)
41
40
  else
42
41
  non_index_dispatch
@@ -77,8 +76,8 @@ module Mutant
77
76
  def normal_dispatch
78
77
  emit_naked_receiver
79
78
  emit_selector_replacement
80
- mutate_receiver
81
79
  emit_argument_propagation
80
+ mutate_receiver
82
81
  mutate_arguments
83
82
  end
84
83
 
@@ -101,20 +100,12 @@ module Mutant
101
100
  # @api private
102
101
  #
103
102
  def emit_naked_receiver
104
- return unless receiver
105
- op_assign = OP_ASSIGN.include?(parent_type)
106
- not_assignable = NOT_ASSIGNABLE.include?(receiver.type)
107
- return if op_assign and not_assignable
108
- emit(receiver)
103
+ emit(receiver) if receiver && !NOT_ASSIGNABLE.include?(receiver.type)
109
104
  end
110
105
 
111
106
  # Test for binary operator
112
107
  #
113
- # @return [true]
114
- # if send is a binary operator
115
- #
116
- # @return [false]
117
- # otherwise
108
+ # @return [Boolean]
118
109
  #
119
110
  # @api private
120
111
  #
@@ -124,15 +115,12 @@ module Mutant
124
115
 
125
116
  # Test for attribute assignment
126
117
  #
127
- # @return [true]
128
- # if node represetns and attribute assignment
129
- #
130
- # @return [false]
118
+ # @return [Boolean]
131
119
  #
132
120
  # @api private
133
121
  #
134
122
  def attribute_assignment?
135
- !BINARY_OPERATORS.include?(selector) && !UNARY_OPERATORS.include?(selector) && assignment? && !mlhs?
123
+ arguments.one? && ATTRIBUTE_ASSIGNMENT =~ selector
136
124
  end
137
125
 
138
126
  # Mutate arguments
@@ -156,10 +144,8 @@ module Mutant
156
144
  # @api private
157
145
  #
158
146
  def emit_argument_propagation
159
- return unless arguments.one?
160
147
  node = arguments.first
161
- return if NOT_STANDALONE.include?(node.type)
162
- emit(arguments.first)
148
+ emit(node) if arguments.one? && !NOT_STANDALONE.include?(node.type)
163
149
  end
164
150
 
165
151
  # Emit receiver mutations
@@ -171,7 +157,9 @@ module Mutant
171
157
  def mutate_receiver
172
158
  return unless receiver
173
159
  emit_implicit_self
174
- emit_receiver_mutations
160
+ emit_receiver_mutations do |node|
161
+ !n_nil?(node)
162
+ end
175
163
  end
176
164
 
177
165
  # Emit implicit self mutation
@@ -181,45 +169,26 @@ module Mutant
181
169
  # @api private
182
170
  #
183
171
  def emit_implicit_self
184
- emit_receiver(nil) if allow_implicit_self?
185
- end
186
-
187
- # Test if implicit self is allowed
188
- #
189
- # @return [Boolean]
190
- #
191
- # @api private
192
- #
193
- def allow_implicit_self?
194
- n_self?(receiver) &&
195
- !KEYWORDS.include?(selector) &&
196
- !attribute_assignment? &&
197
- !OP_ASSIGN.include?(parent_type)
172
+ emit_receiver(nil) if n_self?(receiver) && !(
173
+ KEYWORDS.include?(selector) ||
174
+ OP_ASSIGN.include?(parent_type) ||
175
+ attribute_assignment?
176
+ )
198
177
  end
199
178
 
200
179
  # Test for assignment
201
180
  #
202
- # FIXME: This also returns true for <= operator!
203
- #
204
- # @return [true]
205
- # if node represents attribute / element assignment
206
- #
207
- # @return [false]
208
- # otherwise
181
+ # @return [Boolean]
209
182
  #
210
183
  # @api private
211
184
  #
212
185
  def assignment?
213
- selector.to_s[-1] == ASSIGN_SUFFIX
186
+ arguments.one? && (ASSIGNMENT_OPERATORS.include?(selector) || attribute_assignment?)
214
187
  end
215
188
 
216
- # Test for mlhs
189
+ # Test if node is part of an mlhs
217
190
  #
218
- # @return [true]
219
- # if node is within an mlhs
220
- #
221
- # @return [false]
222
- # otherwise
191
+ # @return [Boolean]
223
192
  #
224
193
  # @api private
225
194
  #
@@ -229,11 +198,7 @@ module Mutant
229
198
 
230
199
  # Test for empty arguments
231
200
  #
232
- # @return [true]
233
- # if arguments are empty
234
- #
235
- # @return [false]
236
- # otherwise
201
+ # @return [Boolean]
237
202
  #
238
203
  # @api private
239
204
  #
@@ -244,4 +209,5 @@ module Mutant
244
209
  end # Send
245
210
  end # Node
246
211
  end # Mutator
212
+
247
213
  end # Mutant
@@ -2,8 +2,7 @@ module Mutant
2
2
  class Mutator
3
3
  class Node
4
4
  class Send
5
-
6
- # Mutator for sends that correspond to an attribute assignment
5
+ # Mutator for attribute assignments
7
6
  class AttributeAssignment < self
8
7
 
9
8
  private
@@ -42,7 +41,6 @@ module Mutant
42
41
  end
43
42
 
44
43
  end # AttributeAssignment
45
-
46
44
  end # Send
47
45
  end # Node
48
46
  end # Mutator
@@ -7,8 +7,14 @@ module Mutant
7
7
  # Base mutator for index operations
8
8
  class Index < self
9
9
 
10
- # Mutator for index references
11
- class Reference < self
10
+ # Mutator for index assignments
11
+ class Assign < self
12
+
13
+ define_named_child(:value, -1)
14
+
15
+ INDEX_RANGE = (2..-2).freeze
16
+
17
+ private
12
18
 
13
19
  # Perform dispatch
14
20
  #
@@ -17,22 +23,34 @@ module Mutant
17
23
  # @api private
18
24
  #
19
25
  def dispatch
20
- emit(receiver)
26
+ emit_naked_receiver
27
+ emit_value_mutations
28
+ emit_index_read
29
+ emit(value)
30
+ mutate_indices
21
31
  end
22
32
 
23
- end # Reference
24
-
25
- # Mutator for index assignments
26
- class Assign < self
33
+ # Mutate indices
34
+ #
35
+ # @return [undefined]
36
+ #
37
+ # @api private
38
+ #
39
+ def mutate_indices
40
+ INDEX_RANGE.begin.upto(children.length + INDEX_RANGE.end).each do |index|
41
+ delete_child(index)
42
+ mutate_child(index)
43
+ end
44
+ end
27
45
 
28
- # Perform dispatch
46
+ # Emit index read
29
47
  #
30
48
  # @return [undefined]
31
49
  #
32
50
  # @api private
33
51
  #
34
- def dispatch
35
- emit(receiver)
52
+ def emit_index_read
53
+ emit_type(receiver, :[], *children[INDEX_RANGE])
36
54
  end
37
55
 
38
56
  end # Assign
@@ -1,4 +1,4 @@
1
1
  module Mutant
2
2
  # The current mutant version
3
- VERSION = '0.5.20'.freeze
3
+ VERSION = '0.5.21'.freeze
4
4
  end # Mutant
@@ -65,13 +65,14 @@ module Mutant
65
65
 
66
66
  # Require file in zombie namespace
67
67
  #
68
- # @param [String] logical_name
68
+ # @param [#to_s] logical_name
69
69
  #
70
70
  # @return [self]
71
71
  #
72
72
  # @api private
73
73
  #
74
74
  def require(logical_name)
75
+ logical_name = logical_name.to_s
75
76
  @highjack.original.call(logical_name)
76
77
  return unless include?(logical_name)
77
78
  @zombified << logical_name
data/meta/op_assgn.rb CHANGED
@@ -9,7 +9,6 @@ Mutant::Meta::Example.add do
9
9
  mutation '@a.b += 0'
10
10
  mutation '@a.b += nil'
11
11
  mutation '@a.b += self'
12
- mutation 'nil.b += 1'
13
12
  mutation 'self.b += 1'
14
13
  # TODO: fix invalid AST
15
14
  # This should not get emitted as invalid AST with valid unparsed source
data/meta/regex.rb CHANGED
@@ -15,7 +15,6 @@ Mutant::Meta::Example.add do
15
15
  mutation '//' # match all
16
16
  mutation '/#{foo}n/'
17
17
  mutation '/a\A/' # match nothing
18
- mutation '/#{nil.bar}n/'
19
18
  mutation '/#{self.bar}n/'
20
19
  mutation '/#{nil}n/'
21
20
  mutation '/#{self}n/'
data/meta/send.rb CHANGED
@@ -49,7 +49,6 @@ Mutant::Meta::Example.add do
49
49
  mutation 'foo.gsub(a, self)'
50
50
  mutation 'foo.gsub(nil, b)'
51
51
  mutation 'foo.gsub(self, b)'
52
- mutation 'nil.gsub(a, b)'
53
52
  mutation 'self.gsub(a, b)'
54
53
  end
55
54
 
@@ -64,7 +63,6 @@ Mutant::Meta::Example.add do
64
63
  mutation 'self.send(bar)'
65
64
  mutation 'foo.send(nil)'
66
65
  mutation 'foo.send(self)'
67
- mutation 'nil.send(bar)'
68
66
  end
69
67
 
70
68
  Mutant::Meta::Example.add do
@@ -76,7 +74,6 @@ Mutant::Meta::Example.add do
76
74
  mutation 'self.bar'
77
75
  mutation 'baz'
78
76
  # This one could probably be removed
79
- mutation 'nil.bar=baz'
80
77
  end
81
78
 
82
79
  Mutant::Meta::Example.add do
@@ -90,14 +87,20 @@ Mutant::Meta::Example.add do
90
87
  mutation 'foo.bar'
91
88
  mutation 'baz'
92
89
  # This one could probably be removed
93
- mutation 'nil.bar = baz'
94
90
  end
95
91
 
96
92
  Mutant::Meta::Example.add do
97
- source 'foo[bar]=baz'
93
+ source 'foo[bar] = baz'
98
94
 
99
95
  singleton_mutations
100
96
  mutation 'foo'
97
+ mutation 'foo[bar]'
98
+ mutation 'foo[bar] = self'
99
+ mutation 'foo[bar] = nil'
100
+ mutation 'foo[nil] = baz'
101
+ mutation 'foo[self] = baz'
102
+ mutation 'foo[] = baz'
103
+ mutation 'baz'
101
104
  end
102
105
 
103
106
  Mutant::Meta::Example.add do
@@ -119,13 +122,6 @@ Mutant::Meta::Example.add do
119
122
  mutation 'foo'
120
123
  end
121
124
 
122
- Mutant::Meta::Example.add do
123
- source 'foo[*bar]'
124
-
125
- singleton_mutations
126
- mutation 'foo'
127
- end
128
-
129
125
  Mutant::Meta::Example.add do
130
126
  source 'foo'
131
127
 
@@ -137,7 +133,6 @@ Mutant::Meta::Example.add do
137
133
 
138
134
  singleton_mutations
139
135
  mutation 'foo'
140
- mutation 'nil.foo'
141
136
  end
142
137
 
143
138
  Unparser::Constants::KEYWORDS.each do |keyword|
@@ -145,7 +140,6 @@ Unparser::Constants::KEYWORDS.each do |keyword|
145
140
  source "self.#{keyword}"
146
141
 
147
142
  singleton_mutations
148
- mutation "nil.#{keyword}"
149
143
  end
150
144
  end
151
145
 
@@ -154,7 +148,6 @@ Mutant::Meta::Example.add do
154
148
 
155
149
  singleton_mutations
156
150
  mutation 'foo'
157
- mutation 'nil.bar'
158
151
  mutation 'self.bar'
159
152
  end
160
153
 
@@ -164,8 +157,6 @@ Mutant::Meta::Example.add do
164
157
  singleton_mutations
165
158
  mutation 'self.class'
166
159
  mutation 'self.foo'
167
- mutation 'nil.class.foo'
168
- mutation 'nil.foo'
169
160
  end
170
161
 
171
162
  Mutant::Meta::Example.add do
@@ -181,7 +172,6 @@ Mutant::Meta::Example.add do
181
172
  singleton_mutations
182
173
  mutation 'self.foo'
183
174
  mutation 'foo(nil)'
184
- mutation 'nil.foo(nil)'
185
175
  end
186
176
 
187
177
  Unparser::Constants::KEYWORDS.each do |keyword|
@@ -192,7 +182,6 @@ Unparser::Constants::KEYWORDS.each do |keyword|
192
182
  mutation "self.#{keyword}(nil)"
193
183
  mutation "foo.#{keyword}"
194
184
  mutation 'foo'
195
- mutation "nil.#{keyword}(nil)"
196
185
  end
197
186
  end
198
187
 
@@ -222,6 +211,44 @@ Mutant::Meta::Example.add do
222
211
  mutation 'self / foo'
223
212
  end
224
213
 
214
+ Mutant::Meta::Example.add do
215
+ source 'foo[1]'
216
+
217
+ singleton_mutations
218
+ mutation '1'
219
+ mutation 'foo'
220
+ mutation 'foo[]'
221
+ mutation 'self[1]'
222
+ mutation 'foo[0]'
223
+ mutation 'foo[2]'
224
+ mutation 'foo[-1]'
225
+ mutation 'foo[nil]'
226
+ mutation 'foo[self]'
227
+ end
228
+
229
+ Mutant::Meta::Example.add do
230
+ source 'self.foo[]'
231
+
232
+ singleton_mutations
233
+ mutation 'self.foo'
234
+ mutation 'self[]'
235
+ mutation 'foo[]'
236
+ end
237
+
238
+ Mutant::Meta::Example.add do
239
+ source 'foo[*bar]'
240
+
241
+ singleton_mutations
242
+ mutation 'foo'
243
+ mutation 'foo[]'
244
+ mutation 'foo[nil]'
245
+ mutation 'foo[self]'
246
+ mutation 'foo[bar]'
247
+ mutation 'foo[*self]'
248
+ mutation 'foo[*nil]'
249
+ mutation 'self[*bar]'
250
+ end
251
+
225
252
  (Mutant::BINARY_METHOD_OPERATORS - [:==, :eql?]).each do |operator|
226
253
  Mutant::Meta::Example.add do
227
254
  source "true #{operator} false"
data/mutant.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
29
29
  gem.add_runtime_dependency('morpher', '~> 0.2.3')
30
30
  gem.add_runtime_dependency('procto', '~> 0.0.2')
31
31
  gem.add_runtime_dependency('abstract_type', '~> 0.0.7')
32
- gem.add_runtime_dependency('unparser', '~> 0.1.13')
32
+ gem.add_runtime_dependency('unparser', '~> 0.1.14')
33
33
  gem.add_runtime_dependency('ice_nine', '~> 0.11.0')
34
34
  gem.add_runtime_dependency('adamantium', '~> 0.2.0')
35
35
  gem.add_runtime_dependency('memoizable', '~> 0.4.2')
@@ -97,7 +97,7 @@ describe 'Mutant on ruby corpus' do
97
97
  TMP.mkdir unless TMP.directory?
98
98
  if repo_path.exist?
99
99
  Dir.chdir(repo_path) do
100
- system(%w[git pull origin master])
100
+ system(%w[git pull -f origin master])
101
101
  system(%w[git clean -f -d -x])
102
102
  end
103
103
  else
@@ -31,4 +31,4 @@
31
31
  mutation_coverage: true
32
32
  mutation_generation: true
33
33
  exclude: []
34
- expect_coverage: 99.81
34
+ expect_coverage: 100.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.20
4
+ version: 0.5.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-14 00:00:00.000000000 Z
11
+ date: 2014-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.1.13
103
+ version: 0.1.14
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.1.13
110
+ version: 0.1.14
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: ice_nine
113
113
  requirement: !ruby/object:Gem::Requirement