mutant 0.3.0.beta19 → 0.3.0.beta20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd13dcc39d401fa798781aa0bf540654ccda03d3
4
- data.tar.gz: 32b01710b1a1214b94996389fbd95cb2e06eca15
3
+ metadata.gz: abfb952112bd4c445ed4733853df50923258451a
4
+ data.tar.gz: afcc91b4102ab14ed8844f72a649851c58d08b75
5
5
  SHA512:
6
- metadata.gz: 08e171e88fd7fd7dbae3130694c983ca35db23f9b8018f395e0bb1ba8c6f5e43876e9fe510d54b0d405f4d651f2129688baf40ad4002a2bf72f417dbbda84d13
7
- data.tar.gz: e483bea1d72eeb4c5010589fe68cb73e05b5da52c8735d1b4fb76c118728d424a7d18100754ea5667d802c1122d666b7884b9b72a389031c478e28a16b291568
6
+ metadata.gz: eef08c62d860f904a82b88ebd26ec9f14117e4dc82fdefd5932c26181736564fc4a8621917a6783a9921e42aac3e1fdad3192fa307a6aedbb8aaec4c4f45961c
7
+ data.tar.gz: 3ad28104cfa6e15e5a75e2c255fb4fa11c8b2f4596e3f042b4f54f643b01f195177be34b4ebf8a83763815f6985674a25cbaee09c52ccf18e2b62d5846872148
data/config/flay.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 16
3
- total_score: 719
3
+ total_score: 730
@@ -5,16 +5,14 @@ module Mutant
5
5
  # Generic mutator
6
6
  class Generic < self
7
7
 
8
- handle(:self)
9
-
10
8
  # These nodes still need a dedicated mutator,
11
9
  # your contribution is that close!
12
10
  handle(
13
- :zsuper, :not, :or, :and, :defined,
14
- :next, :break, :match, :gvar, :cvar, :ensure,
11
+ :not, :or, :and, :defined,
12
+ :next, :break, :match, :ensure,
15
13
  :dstr, :dsym, :yield, :rescue, :redo, :defined?,
16
- :const, :blockarg, :block_pass, :op_asgn, :and_asgn,
17
- :regopt, :ivar, :restarg, :casgn, :resbody, :retry, :arg_expr,
14
+ :blockarg, :block_pass, :op_asgn, :and_asgn,
15
+ :regopt, :restarg, :resbody, :retry, :arg_expr,
18
16
  :kwrestarg, :kwoptarg, :kwarg, :undef, :module, :cbase, :empty,
19
17
  :alias, :for, :xstr, :back_ref, :nth_ref, :class,
20
18
  :sclass, :match_with_lvasgn, :match_current_line, :or_asgn, :kwbegin
@@ -30,8 +28,7 @@ module Mutant
30
28
  #
31
29
  def dispatch
32
30
  children.each_with_index do |child, index|
33
- next unless child.kind_of?(Parser::AST::Node)
34
- mutate_child(index)
31
+ mutate_child(index) if child.kind_of?(Parser::AST::Node)
35
32
  end
36
33
  end
37
34
 
@@ -0,0 +1,27 @@
1
+ module Mutant
2
+ class Mutator
3
+ class Node
4
+ module NamedValue
5
+
6
+ # Mutation emitter to handle named value access nodes
7
+ class Access < Node
8
+
9
+ handle(:gvar, :cvar, :ivar, :lvar, :const, :self)
10
+
11
+ private
12
+
13
+ # Emit mutations
14
+ #
15
+ # @return [undefined]
16
+ #
17
+ # @api private
18
+ #
19
+ def dispatch
20
+ emit_nil
21
+ end
22
+
23
+ end # Access
24
+ end # NamedValue
25
+ end # Node
26
+ end # Mutator
27
+ end # Mutant
@@ -0,0 +1,42 @@
1
+ module Mutant
2
+ class Mutator
3
+ class Node
4
+ module NamedValue
5
+
6
+ # Mutation emitter to handle constant assignment nodes
7
+ class ConstantAssignment < Node
8
+
9
+ children :cbase, :name, :value
10
+
11
+ handle :casgn
12
+
13
+ private
14
+
15
+ # Perform dispatch
16
+ #
17
+ # @return [undefined]
18
+ #
19
+ # @api private
20
+ #
21
+ def dispatch
22
+ mutate_name
23
+ emit_value_mutations if value
24
+ end
25
+
26
+ # Emit name mutations
27
+ #
28
+ # @return [undefined]
29
+ #
30
+ # @api private
31
+ #
32
+ def mutate_name
33
+ Mutator::Util::Symbol.each(name, self) do |name|
34
+ emit_name(name.upcase)
35
+ end
36
+ end
37
+
38
+ end # ConstantAssignment
39
+ end # NamedValue
40
+ end # Node
41
+ end # Mutator
42
+ end # Mutant
@@ -1,11 +1,10 @@
1
1
  module Mutant
2
2
  class Mutator
3
3
  class Node
4
- # Mutator base class for assignments
5
- class Assignment < self
4
+ module NamedValue
6
5
 
7
- # Mutator for variable assignment
8
- class Variable < self
6
+ # Mutation emitter to handle variable assignment nodes
7
+ class VariableAssignment < Node
9
8
 
10
9
  children :name, :value
11
10
 
@@ -40,12 +39,12 @@ module Mutant
40
39
  def mutate_name
41
40
  prefix = MAP.fetch(node.type)
42
41
  Mutator::Util::Symbol.each(name, self) do |name|
43
- emit_name("#{prefix}#{name}")
42
+ emit_name(prefix + name.to_s)
44
43
  end
45
44
  end
46
45
 
47
- end # Variable
48
- end # Assignment
46
+ end # VariableAssignment
47
+ end # NamedValue
49
48
  end # Node
50
49
  end # Mutator
51
50
  end # Mutant
@@ -2,7 +2,7 @@ module Mutant
2
2
  class Mutator
3
3
  class Node
4
4
 
5
- # Mutator for super with parantheses
5
+ # Mutator for super with parentheses
6
6
  class Super < self
7
7
 
8
8
  handle(:super)
@@ -2,10 +2,10 @@ module Mutant
2
2
  class Mutator
3
3
  class Node
4
4
 
5
- # Mutation emitter to handle local variable nodes
6
- class LocalVariable < self
5
+ # Mutator for super without parentheses
6
+ class ZSuper < self
7
7
 
8
- handle(:lvar)
8
+ handle(:zsuper)
9
9
 
10
10
  private
11
11
 
@@ -19,7 +19,7 @@ module Mutant
19
19
  emit_nil
20
20
  end
21
21
 
22
- end # LocalVariable
22
+ end # ZSuper
23
23
  end # Node
24
24
  end # Mutator
25
25
  end # Mutant
@@ -115,7 +115,7 @@ module Mutant
115
115
  #
116
116
  def print_generic_stats
117
117
  stats = generic_stats.to_a.sort_by(&:last)
118
- info('Nodes handled by genric mutator (type:occurances):')
118
+ info('Nodes handled by generic mutator (type:occurrences):')
119
119
  stats.reverse_each do |type, amount|
120
120
  info('%-10s: %d', type, amount)
121
121
  end
data/lib/mutant.rb CHANGED
@@ -54,17 +54,18 @@ require 'mutant/mutator/node/literal/array'
54
54
  require 'mutant/mutator/node/literal/hash'
55
55
  require 'mutant/mutator/node/literal/regex'
56
56
  require 'mutant/mutator/node/literal/nil'
57
- require 'mutant/mutator/node/assignment'
58
57
  require 'mutant/mutator/node/argument'
59
58
  require 'mutant/mutator/node/arguments'
60
59
  require 'mutant/mutator/node/begin'
61
- require 'mutant/mutator/node/lvar'
60
+ require 'mutant/mutator/node/named_value/access'
61
+ require 'mutant/mutator/node/named_value/constant_assignment'
62
+ require 'mutant/mutator/node/named_value/variable_assignment'
62
63
  require 'mutant/mutator/node/while'
63
64
  require 'mutant/mutator/node/super'
65
+ require 'mutant/mutator/node/zsuper'
64
66
  require 'mutant/mutator/node/send'
65
67
  require 'mutant/mutator/node/send/binary'
66
68
  require 'mutant/mutator/node/when'
67
- require 'mutant/mutator/node/assignment'
68
69
  require 'mutant/mutator/node/define'
69
70
  require 'mutant/mutator/node/mlhs'
70
71
  require 'mutant/mutator/node/masgn'
data/mutant.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'mutant'
5
- gem.version = '0.3.0.beta19'
5
+ gem.version = '0.3.0.beta20'
6
6
  gem.authors = [ 'Markus Schirp' ]
7
7
  gem.email = [ 'mbj@schirp-dso.com' ]
8
8
 
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
4
+
5
+ before do
6
+ Mutant::Random.stub(:hex_string => :random)
7
+ end
8
+
9
+ context 'global variable' do
10
+ let(:source) { '$a = nil; $a' }
11
+
12
+ let(:mutations) do
13
+ mutants = []
14
+ mutants << '$a = nil; nil'
15
+ mutants << '$a = nil'
16
+ mutants << '$a'
17
+ mutants << '$a = ::Object.new; $a'
18
+ mutants << '$srandom = nil; $a'
19
+ end
20
+
21
+ it_should_behave_like 'a mutator'
22
+ end
23
+
24
+ context 'class variable' do
25
+ let(:source) { '@@a = nil; @@a' }
26
+
27
+ let(:mutations) do
28
+ mutants = []
29
+ mutants << '@@a = nil; nil'
30
+ mutants << '@@a = nil'
31
+ mutants << '@@a'
32
+ mutants << '@@a = ::Object.new; @@a'
33
+ mutants << '@@srandom = nil; @@a'
34
+ end
35
+ end
36
+
37
+ context 'instance variable' do
38
+ let(:source) { '@a = nil; @a' }
39
+
40
+ let(:mutations) do
41
+ mutants = []
42
+ mutants << '@a = nil; nil'
43
+ mutants << '@a = nil'
44
+ mutants << '@a'
45
+ mutants << '@a = ::Object.new; @a'
46
+ mutants << '@srandom = nil; @a'
47
+ end
48
+
49
+ it_should_behave_like 'a mutator'
50
+ end
51
+
52
+ context 'local variable' do
53
+ let(:source) { 'a = nil; a' }
54
+
55
+ let(:mutations) do
56
+ mutants = []
57
+ mutants << 'a = nil; nil'
58
+ mutants << 'a = nil'
59
+ mutants << 'a'
60
+ mutants << 'a = ::Object.new; a'
61
+ mutants << 'srandom = nil; a'
62
+ end
63
+
64
+ it_should_behave_like 'a mutator'
65
+ end
66
+
67
+ context 'constant' do
68
+ let(:source) { 'A' }
69
+
70
+ let(:mutations) do
71
+ mutants = []
72
+ mutants << 'nil'
73
+ end
74
+
75
+ it_should_behave_like 'a mutator'
76
+ end
77
+
78
+ context 'self' do
79
+ let(:source) { 'self' }
80
+
81
+ let(:mutations) do
82
+ mutants = []
83
+ mutants << 'nil'
84
+ end
85
+
86
+ it_should_behave_like 'a mutator'
87
+ end
88
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
4
+
5
+ before do
6
+ Mutant::Random.stub(:hex_string => :random)
7
+ end
8
+
9
+ let(:source) { 'A = true' }
10
+
11
+ let(:mutations) do
12
+ mutations = []
13
+
14
+ mutations << 'SRANDOM = true'
15
+ mutations << 'A = false'
16
+ mutations << 'A = nil'
17
+ end
18
+
19
+ it_should_behave_like 'a mutator'
20
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Mutant::Mutator::Node::Assignment, 'mutations' do
3
+ describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
4
4
 
5
5
  before do
6
6
  Mutant::Random.stub(:hex_string => :random)
@@ -9,6 +9,7 @@ describe Mutant::Mutator, 'send' do
9
9
  let(:mutations) do
10
10
  mutations = []
11
11
  mutations << 'foo ||= expression'
12
+ mutations << 'nil.foo ||= expression'
12
13
  end
13
14
 
14
15
  it_should_behave_like 'a mutator'
@@ -74,6 +75,7 @@ describe Mutant::Mutator, 'send' do
74
75
  mutations = []
75
76
  mutations << 'foo'
76
77
  mutations << 'self'
78
+ mutations << 'nil.foo'
77
79
  end
78
80
 
79
81
  it_should_behave_like 'a mutator'
@@ -111,6 +113,7 @@ describe Mutant::Mutator, 'send' do
111
113
  mutations = []
112
114
  mutations << 'self.class'
113
115
  mutations << 'self.foo'
116
+ mutations << 'nil.class.foo'
114
117
  end
115
118
 
116
119
  it_should_behave_like 'a mutator'
@@ -142,6 +145,7 @@ describe Mutant::Mutator, 'send' do
142
145
  mutations << 'foo(nil)'
143
146
  mutations << 'nil'
144
147
  mutations << 'self.foo(::Object.new)'
148
+ mutations << 'nil.foo(nil)'
145
149
  end
146
150
 
147
151
  it_should_behave_like 'a mutator'
@@ -5,7 +5,12 @@ describe Mutant::Mutator, 'super' do
5
5
  context 'with no arguments' do
6
6
  let(:source) { 'super' }
7
7
 
8
- it_should_behave_like 'a noop mutator'
8
+ let(:mutations) do
9
+ mutations = []
10
+ mutations << 'nil'
11
+ end
12
+
13
+ it_should_behave_like 'a mutator'
9
14
  end
10
15
 
11
16
  context 'with explicit empty arguments' do
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.3.0.beta19
4
+ version: 0.3.0.beta20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-22 00:00:00.000000000 Z
11
+ date: 2013-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -221,7 +221,6 @@ files:
221
221
  - lib/mutant/mutator/node.rb
222
222
  - lib/mutant/mutator/node/argument.rb
223
223
  - lib/mutant/mutator/node/arguments.rb
224
- - lib/mutant/mutator/node/assignment.rb
225
224
  - lib/mutant/mutator/node/begin.rb
226
225
  - lib/mutant/mutator/node/block.rb
227
226
  - lib/mutant/mutator/node/case.rb
@@ -240,9 +239,11 @@ files:
240
239
  - lib/mutant/mutator/node/literal/regex.rb
241
240
  - lib/mutant/mutator/node/literal/string.rb
242
241
  - lib/mutant/mutator/node/literal/symbol.rb
243
- - lib/mutant/mutator/node/lvar.rb
244
242
  - lib/mutant/mutator/node/masgn.rb
245
243
  - lib/mutant/mutator/node/mlhs.rb
244
+ - lib/mutant/mutator/node/named_value/access.rb
245
+ - lib/mutant/mutator/node/named_value/constant_assignment.rb
246
+ - lib/mutant/mutator/node/named_value/variable_assignment.rb
246
247
  - lib/mutant/mutator/node/return.rb
247
248
  - lib/mutant/mutator/node/send.rb
248
249
  - lib/mutant/mutator/node/send/binary.rb
@@ -250,6 +251,7 @@ files:
250
251
  - lib/mutant/mutator/node/super.rb
251
252
  - lib/mutant/mutator/node/when.rb
252
253
  - lib/mutant/mutator/node/while.rb
254
+ - lib/mutant/mutator/node/zsuper.rb
253
255
  - lib/mutant/mutator/registry.rb
254
256
  - lib/mutant/mutator/util.rb
255
257
  - lib/mutant/mutator/util/array.rb
@@ -319,7 +321,6 @@ files:
319
321
  - spec/unit/mutant/mutator/each_spec.rb
320
322
  - spec/unit/mutant/mutator/emit_new_spec.rb
321
323
  - spec/unit/mutant/mutator/emit_spec.rb
322
- - spec/unit/mutant/mutator/node/assignment/mutation_spec.rb
323
324
  - spec/unit/mutant/mutator/node/begin/mutation_spec.rb
324
325
  - spec/unit/mutant/mutator/node/block/mutation_spec.rb
325
326
  - spec/unit/mutant/mutator/node/case/mutation_spec.rb
@@ -335,13 +336,14 @@ files:
335
336
  - spec/unit/mutant/mutator/node/literal/regex_spec.rb
336
337
  - spec/unit/mutant/mutator/node/literal/string_spec.rb
337
338
  - spec/unit/mutant/mutator/node/literal/symbol_spec.rb
338
- - spec/unit/mutant/mutator/node/lvar/mutation_spec.rb
339
339
  - spec/unit/mutant/mutator/node/masgn/mutation_spec.rb
340
+ - spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb
341
+ - spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb
342
+ - spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb
340
343
  - spec/unit/mutant/mutator/node/return/mutation_spec.rb
341
344
  - spec/unit/mutant/mutator/node/send/mutation_spec.rb
342
345
  - spec/unit/mutant/mutator/node/super/mutation_spec.rb
343
346
  - spec/unit/mutant/mutator/node/while/mutation_spec.rb
344
- - spec/unit/mutant/mutator/self_spec.rb
345
347
  - spec/unit/mutant/runner/config/subjects_spec.rb
346
348
  - spec/unit/mutant/runner/config/success_predicate_spec.rb
347
349
  - spec/unit/mutant/runner/mutation/killer_spec.rb
@@ -427,7 +429,6 @@ test_files:
427
429
  - spec/unit/mutant/mutator/each_spec.rb
428
430
  - spec/unit/mutant/mutator/emit_new_spec.rb
429
431
  - spec/unit/mutant/mutator/emit_spec.rb
430
- - spec/unit/mutant/mutator/node/assignment/mutation_spec.rb
431
432
  - spec/unit/mutant/mutator/node/begin/mutation_spec.rb
432
433
  - spec/unit/mutant/mutator/node/block/mutation_spec.rb
433
434
  - spec/unit/mutant/mutator/node/case/mutation_spec.rb
@@ -443,13 +444,14 @@ test_files:
443
444
  - spec/unit/mutant/mutator/node/literal/regex_spec.rb
444
445
  - spec/unit/mutant/mutator/node/literal/string_spec.rb
445
446
  - spec/unit/mutant/mutator/node/literal/symbol_spec.rb
446
- - spec/unit/mutant/mutator/node/lvar/mutation_spec.rb
447
447
  - spec/unit/mutant/mutator/node/masgn/mutation_spec.rb
448
+ - spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb
449
+ - spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb
450
+ - spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb
448
451
  - spec/unit/mutant/mutator/node/return/mutation_spec.rb
449
452
  - spec/unit/mutant/mutator/node/send/mutation_spec.rb
450
453
  - spec/unit/mutant/mutator/node/super/mutation_spec.rb
451
454
  - spec/unit/mutant/mutator/node/while/mutation_spec.rb
452
- - spec/unit/mutant/mutator/self_spec.rb
453
455
  - spec/unit/mutant/runner/config/subjects_spec.rb
454
456
  - spec/unit/mutant/runner/config/success_predicate_spec.rb
455
457
  - spec/unit/mutant/runner/mutation/killer_spec.rb
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Mutant::Mutator, 'lvar' do
4
-
5
- before do
6
- Mutant::Random.stub(:hex_string => 'random')
7
- end
8
-
9
- let(:source) { 'a = nil; a' }
10
-
11
- let(:mutations) do
12
- mutants = []
13
- mutants << 'a = nil; nil'
14
- mutants << 'a = nil'
15
- mutants << 'a'
16
- mutants << 'a = ::Object.new; a'
17
- mutants << 'srandom = nil; a'
18
- end
19
-
20
- it_should_behave_like 'a mutator'
21
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Mutant::Mutator, 'self' do
4
- let(:source) { 'self' }
5
-
6
- it_should_behave_like 'a noop mutator'
7
- end