mutant 0.2.1 → 0.2.2

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.
data/Changelog.md CHANGED
@@ -1,4 +1,10 @@
1
- # v0.2.1 xxx
1
+ # v0.2.2 2012-12-07
2
+
3
+ * [feature] Add a shitload of operator expansions for dm2 strategy
4
+
5
+ [Compare v0.2.1..v0.2.2](https://github.com/mbj/mutant/compare/v0.2.1...v0.2.2)
6
+
7
+ # v0.2.1 2012-12-07
2
8
 
3
9
  * [fixed] Crash on unavailable source location
4
10
  * [fixed] Incorrect handling of if and unless statements
@@ -56,6 +56,42 @@ module Mutant
56
56
  mutation.subject.matcher
57
57
  end
58
58
 
59
+ MAPPING = {
60
+ :<=> => :spaceship_operator,
61
+ :=== => :case_equality_operator,
62
+ :[]= => :element_writer,
63
+ :[] => :element_reader,
64
+ :<= => :less_than_or_equal_to_operator,
65
+ :>= => :greater_than_or_equal_to_operator,
66
+ :~@ => :unary_match_operator,
67
+ :+@ => :unary_addition_operator,
68
+ :-@ => :unary_substraction_operator,
69
+ :== => :equality_operator,
70
+ :!~ => :nomatch_operator,
71
+ :!= => :inequality_operator,
72
+ :=~ => :match_operator,
73
+ :<< => :left_shift_operator,
74
+ :>> => :right_shift_operator,
75
+ :** => :exponentation_operator,
76
+ :* => :multiplication_operator,
77
+ :% => :modulo_operator,
78
+ :/ => :division_operator,
79
+ :| => :bitwise_or_operator,
80
+ :! => :negation_operator,
81
+ :^ => :bitwise_xor_operator,
82
+ :& => :bitwise_and_operator,
83
+ :< => :less_than_operator,
84
+ :> => :greater_than_operator,
85
+ :+ => :addition_operator,
86
+ :- => :substraction_operator
87
+ }
88
+
89
+ EXPANSIONS = {
90
+ /\?\z/ => '_predicate',
91
+ /=\z/ => '_writer',
92
+ /!\z/ => '_bang'
93
+ }
94
+
59
95
  # Return spec file
60
96
  #
61
97
  # @return [String]
@@ -63,15 +99,34 @@ module Mutant
63
99
  # @api private
64
100
  #
65
101
  def spec_file
66
- method_name.to_s.
67
- gsub(/\A\[\]\z/, 'element_reader').
68
- gsub(/\A\[\]=\z/, 'element_writer').
69
- gsub(/\?\z/, '_predicate').
70
- gsub(/=\z/, '_writer').
71
- gsub(/!\z/, '_bang') + '_spec.rb'
102
+ "#{mapped_name || expanded_name}_spec.rb"
72
103
  end
73
104
  memoize :spec_file
74
105
 
106
+ # Return mapped name
107
+ #
108
+ # @return [Symbol]
109
+ # if name was mapped
110
+ #
111
+ # @return [nil]
112
+ # otherwise
113
+ #
114
+ def mapped_name
115
+ MAPPING[method_name]
116
+ end
117
+
118
+ # Return expanded name
119
+ #
120
+ # @return [Symbol]
121
+ #
122
+ # @api private
123
+ #
124
+ def expanded_name
125
+ EXPANSIONS.inject(method_name) do |name, (regexp, expansion)|
126
+ name.to_s.gsub(regexp, expansion)
127
+ end.to_sym
128
+ end
129
+
75
130
  # Return method name
76
131
  #
77
132
  # @return [Symbol]
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.2.1'
5
+ gem.version = '0.2.2'
6
6
  gem.authors = [ 'Markus Schirp' ]
7
7
  gem.email = [ 'mbj@seonic.net' ]
8
8
  gem.description = 'Mutation testing for ruby under rubinius'
@@ -16,15 +16,190 @@ describe Mutant::Strategy::Rspec::ExampleLookup, '#spec_file' do
16
16
  it { should be_frozen }
17
17
  end
18
18
 
19
+ context 'negation operator' do
20
+ let(:method_name) { :! }
21
+ let(:expected_spec_file) { 'negation_operator_spec.rb' }
22
+
23
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
24
+ end
25
+
26
+ context 'with unary match method' do
27
+ let(:method_name) { :~@ }
28
+ let(:expected_spec_file) { 'unary_match_operator_spec.rb' }
29
+
30
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
31
+ end
32
+
33
+ context 'with unary substraction method' do
34
+ let(:method_name) { :-@ }
35
+ let(:expected_spec_file) { 'unary_substraction_operator_spec.rb' }
36
+
37
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
38
+ end
39
+
40
+ context 'with unary addition method' do
41
+ let(:method_name) { :+@ }
42
+ let(:expected_spec_file) { 'unary_addition_operator_spec.rb' }
43
+
44
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
45
+ end
46
+
47
+ context 'with bitwise xor method' do
48
+ let(:method_name) { :^ }
49
+ let(:expected_spec_file) { 'bitwise_xor_operator_spec.rb' }
50
+
51
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
52
+ end
53
+
54
+ context 'with bitwise or method' do
55
+ let(:method_name) { :| }
56
+ let(:expected_spec_file) { 'bitwise_or_operator_spec.rb' }
57
+
58
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
59
+ end
60
+
61
+ context 'with bitwise and method' do
62
+ let(:method_name) { :& }
63
+ let(:expected_spec_file) { 'bitwise_and_operator_spec.rb' }
64
+
65
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
66
+ end
67
+
68
+ context 'with spaceship method' do
69
+ let(:method_name) { :<=> }
70
+ let(:expected_spec_file) { 'spaceship_operator_spec.rb' }
71
+
72
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
73
+ end
74
+
75
+ context 'with case equality operator method' do
76
+ let(:method_name) { :=== }
77
+ let(:expected_spec_file) { 'case_equality_operator_spec.rb' }
78
+
79
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
80
+ end
81
+
82
+ context 'with modulo operator method' do
83
+ let(:method_name) { :% }
84
+ let(:expected_spec_file) { 'modulo_operator_spec.rb' }
85
+
86
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
87
+ end
88
+
89
+ context 'with exponentation operator method' do
90
+ let(:method_name) { :** }
91
+ let(:expected_spec_file) { 'exponentation_operator_spec.rb' }
92
+
93
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
94
+ end
95
+
96
+ context 'with substraction operator method' do
97
+ let(:method_name) { :- }
98
+ let(:expected_spec_file) { 'substraction_operator_spec.rb' }
99
+
100
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
101
+ end
102
+
103
+ context 'with addition operator method' do
104
+ let(:method_name) { :+ }
105
+ let(:expected_spec_file) { 'addition_operator_spec.rb' }
106
+
107
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
108
+ end
109
+
110
+ context 'with greater than or equal to operator method' do
111
+ let(:method_name) { :>= }
112
+ let(:expected_spec_file) { 'greater_than_or_equal_to_operator_spec.rb' }
113
+
114
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
115
+ end
116
+
117
+ context 'with less than or equal to operator method' do
118
+ let(:method_name) { :<= }
119
+ let(:expected_spec_file) { 'less_than_or_equal_to_operator_spec.rb' }
120
+
121
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
122
+ end
123
+
124
+ context 'with greater than operator method' do
125
+ let(:method_name) { :> }
126
+ let(:expected_spec_file) { 'greater_than_operator_spec.rb' }
127
+
128
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
129
+ end
130
+
131
+ context 'with less than operator method' do
132
+ let(:method_name) { :< }
133
+ let(:expected_spec_file) { 'less_than_operator_spec.rb' }
134
+
135
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
136
+ end
137
+
138
+ context 'with right shift operator method' do
139
+ let(:method_name) { :>> }
140
+ let(:expected_spec_file) { 'right_shift_operator_spec.rb' }
141
+
142
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
143
+ end
144
+
145
+ context 'with left shift operator method' do
146
+ let(:method_name) { :<< }
147
+ let(:expected_spec_file) { 'left_shift_operator_spec.rb' }
148
+
149
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
150
+ end
151
+
152
+ context 'with division operator method' do
153
+ let(:method_name) { :/ }
154
+ let(:expected_spec_file) { 'division_operator_spec.rb' }
155
+
156
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
157
+ end
158
+
159
+ context 'with multiplication operator method' do
160
+ let(:method_name) { :* }
161
+ let(:expected_spec_file) { 'multiplication_operator_spec.rb' }
162
+
163
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
164
+ end
165
+
166
+ context 'with nomatch operator method' do
167
+ let(:method_name) { :!~ }
168
+ let(:expected_spec_file) { 'nomatch_operator_spec.rb' }
169
+
170
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
171
+ end
172
+
173
+ context 'with match operator method' do
174
+ let(:method_name) { :=~ }
175
+ let(:expected_spec_file) { 'match_operator_spec.rb' }
176
+
177
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
178
+ end
179
+
180
+ context 'with inequality operator method' do
181
+ let(:method_name) { :!= }
182
+ let(:expected_spec_file) { 'inequality_operator_spec.rb' }
183
+
184
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
185
+ end
186
+
187
+ context 'with equality operator method' do
188
+ let(:method_name) { :== }
189
+ let(:expected_spec_file) { 'equality_operator_spec.rb' }
190
+
191
+ it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
192
+ end
193
+
19
194
  context 'with element reader method' do
20
- let(:method_name) { '[]' }
195
+ let(:method_name) { :[] }
21
196
  let(:expected_spec_file) { 'element_reader_spec.rb' }
22
197
 
23
198
  it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
24
199
  end
25
200
 
26
201
  context 'with element writer method' do
27
- let(:method_name) { '[]=' }
202
+ let(:method_name) { :[]= }
28
203
 
29
204
  let(:expected_spec_file) { 'element_writer_spec.rb' }
30
205
 
@@ -32,28 +207,28 @@ describe Mutant::Strategy::Rspec::ExampleLookup, '#spec_file' do
32
207
  end
33
208
 
34
209
  context 'with writer method' do
35
- let(:method_name) { 'foo=' }
210
+ let(:method_name) { :foo= }
36
211
  let(:expected_spec_file) { 'foo_writer_spec.rb' }
37
212
 
38
213
  it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
39
214
  end
40
215
 
41
216
  context 'with bang method' do
42
- let(:method_name) { 'foo!' }
217
+ let(:method_name) { :foo! }
43
218
  let(:expected_spec_file) { 'foo_bang_spec.rb' }
44
219
 
45
220
  it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
46
221
  end
47
222
 
48
223
  context 'with predicate method' do
49
- let(:method_name) { 'foo?' }
224
+ let(:method_name) { :foo? }
50
225
  let(:expected_spec_file) { 'foo_predicate_spec.rb' }
51
226
 
52
227
  it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
53
228
  end
54
229
 
55
230
  context 'with regular method' do
56
- let(:method_name) { 'foo' }
231
+ let(:method_name) { :foo }
57
232
  let(:expected_spec_file) { 'foo_spec.rb' }
58
233
 
59
234
  it_should_behave_like 'Mutant::Strategy::Rspec::ExampleLookup#spec_file'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-07 00:00:00.000000000 Z
12
+ date: 2012-12-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: to_source