heckle 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -1
- data/README.txt +9 -5
- data/bin/heckle +3 -5
- data/lib/heckle.rb +0 -3
- data/lib/heckle/base.rb +6 -3
- data/lib/test_unit_heckler.rb +10 -4
- data/sample/lib/heckled.rb +4 -0
- data/test/fixtures/heckled.rb +2 -2
- data/test/test_heckle.rb +132 -124
- metadata +3 -3
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 1.1.1 / 2006-12-20
|
2
|
+
|
3
|
+
* 3 bug fixes:
|
4
|
+
* Load tests properly when supplying method name.
|
5
|
+
* Make sure random symbols have at least one character.
|
6
|
+
* Removed all extra warnings from the unit tests. Consolidated and cleaned.
|
7
|
+
|
1
8
|
== 1.1.0 / 2006-12-19
|
2
9
|
|
3
10
|
* 12 major enhancements:
|
@@ -18,4 +25,3 @@
|
|
18
25
|
|
19
26
|
* 1 major enhancement
|
20
27
|
* Birthday!
|
21
|
-
|
data/README.txt
CHANGED
@@ -4,20 +4,24 @@ heckle
|
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
Heckle is a mutation tester. It modifies your code and runs your tests to make sure they fail. The idea is that if code can be changed and your tests don't notice, either that code isn't being covered or it doesn't do anything.
|
8
|
+
|
9
|
+
It's like hiring a white-hat hacker to try to break into your server and making sure you detect it. You learn the most by trying to break things and watching the outcome in an act of unit test sadism.
|
9
10
|
|
10
11
|
== FEATURES/PROBLEMS:
|
11
12
|
|
12
|
-
*
|
13
|
+
* Mutates booleans, numbers, strings, symbols, ranges, regexes and branches (if, while, unless, until)
|
14
|
+
* Able to mutate entire classes, or individual methods
|
15
|
+
* Can not yet mutate class methods
|
13
16
|
|
14
17
|
== SYNOPSYS:
|
15
18
|
|
16
|
-
|
19
|
+
% heckle -v Autotest
|
17
20
|
|
18
21
|
== REQUIREMENTS:
|
19
22
|
|
20
|
-
+
|
23
|
+
+ ruby2ruby 1.1.2 or greater
|
24
|
+
+ ParseTree 1.6.1 or greater
|
21
25
|
|
22
26
|
== INSTALL:
|
23
27
|
|
data/bin/heckle
CHANGED
@@ -17,6 +17,7 @@ opts = OptionParser.new do |opts|
|
|
17
17
|
|
18
18
|
opts.on( "-h", "--help", "Show this message") do |opt|
|
19
19
|
puts opts
|
20
|
+
exit 0
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
@@ -30,8 +31,5 @@ unless impl then
|
|
30
31
|
exit 1
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
else
|
36
|
-
TestUnitHeckler.validate(impl)
|
37
|
-
end
|
34
|
+
TestUnitHeckler.validate(impl, meth)
|
35
|
+
|
data/lib/heckle.rb
CHANGED
data/lib/heckle/base.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'parse_tree'
|
2
|
+
require 'ruby2ruby'
|
3
|
+
|
1
4
|
class String
|
2
5
|
def to_class
|
3
6
|
split(/::/).inject(Object) { |klass, name| klass.const_get(name) }
|
@@ -5,7 +8,7 @@ class String
|
|
5
8
|
end
|
6
9
|
|
7
10
|
module Heckle
|
8
|
-
VERSION = '1.1.
|
11
|
+
VERSION = '1.1.1'
|
9
12
|
|
10
13
|
class Base < SexpProcessor
|
11
14
|
MUTATABLE_NODES = [:if, :lit, :str, :true, :false, :while, :until]
|
@@ -306,7 +309,7 @@ module Heckle
|
|
306
309
|
end
|
307
310
|
|
308
311
|
def rand_string
|
309
|
-
size = rand(
|
312
|
+
size = rand(50)
|
310
313
|
str = ""
|
311
314
|
size.times { str << rand(126).chr }
|
312
315
|
str
|
@@ -315,7 +318,7 @@ module Heckle
|
|
315
318
|
def rand_symbol
|
316
319
|
letters = ('a'..'z').to_a + ('A'..'Z').to_a
|
317
320
|
str = ""
|
318
|
-
rand(
|
321
|
+
(rand(50) + 1).times { str << letters[rand(letters.size)] }
|
319
322
|
:"#{str}"
|
320
323
|
end
|
321
324
|
|
data/lib/test_unit_heckler.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'test/unit/autorunner'
|
4
4
|
require 'heckle'
|
5
|
+
$: << 'lib' << 'test'
|
5
6
|
|
6
7
|
class TestUnitHeckler < Heckle::Base
|
7
8
|
@@test_pattern = 'test/test_*.rb'
|
@@ -16,12 +17,17 @@ class TestUnitHeckler < Heckle::Base
|
|
16
17
|
Dir.glob(@@test_pattern).each {|test| require test}
|
17
18
|
end
|
18
19
|
|
19
|
-
def self.validate(klass_name)
|
20
|
+
def self.validate(klass_name, method_name = nil)
|
20
21
|
load_test_files
|
21
22
|
klass = klass_name.to_class
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
|
24
|
+
if method_name
|
25
|
+
self.new(klass_name, method_name).test_and_validate
|
26
|
+
else
|
27
|
+
klass.instance_methods(false).each do |method_name|
|
28
|
+
heckler = self.new(klass_name, method_name)
|
29
|
+
heckler.test_and_validate
|
30
|
+
end
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
data/sample/lib/heckled.rb
CHANGED
data/test/fixtures/heckled.rb
CHANGED
data/test/test_heckle.rb
CHANGED
@@ -6,11 +6,34 @@ require 'test/unit' if $0 == __FILE__
|
|
6
6
|
require 'test_unit_heckler'
|
7
7
|
require 'heckled'
|
8
8
|
|
9
|
+
module Heckle
|
10
|
+
class Base
|
11
|
+
def rand(*args)
|
12
|
+
5
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method :old_rand_string, :rand_string
|
16
|
+
def rand_string
|
17
|
+
"l33t h4x0r"
|
18
|
+
end
|
19
|
+
|
20
|
+
alias_method :old_rand_number, :rand_number
|
21
|
+
def rand_number(*args)
|
22
|
+
5
|
23
|
+
end
|
24
|
+
|
25
|
+
alias_method :old_rand_symbol, :rand_symbol
|
26
|
+
def rand_symbol
|
27
|
+
:"l33t h4x0r"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
9
32
|
class TestHeckle < Test::Unit::TestCase
|
10
33
|
def setup
|
11
34
|
@heckler = Heckle::Base.new("Heckled", "uses_many_things")
|
12
35
|
end
|
13
|
-
|
36
|
+
|
14
37
|
def test_should_set_original_tree
|
15
38
|
expected = [:defn,
|
16
39
|
:uses_many_things,
|
@@ -30,10 +53,10 @@ class TestHeckle < Test::Unit::TestCase
|
|
30
53
|
[:return, [:false]]],
|
31
54
|
true],
|
32
55
|
[:lvar, :i]]]]]
|
33
|
-
|
56
|
+
|
34
57
|
assert_equal expected, @heckler.original_tree
|
35
58
|
end
|
36
|
-
|
59
|
+
|
37
60
|
def test_should_grab_mutatees_from_method
|
38
61
|
# expected is from tree of uses_while
|
39
62
|
expected = {
|
@@ -59,10 +82,10 @@ class TestHeckle < Test::Unit::TestCase
|
|
59
82
|
true]],
|
60
83
|
:until => [[:until, [:vcall, :some_func], [:vcall, :some_other_func], true]]
|
61
84
|
}
|
62
|
-
|
85
|
+
|
63
86
|
assert_equal expected, @heckler.mutatees
|
64
87
|
end
|
65
|
-
|
88
|
+
|
66
89
|
def test_should_count_mutatees_left
|
67
90
|
assert_equal 10, @heckler.mutations_left
|
68
91
|
end
|
@@ -70,80 +93,68 @@ class TestHeckle < Test::Unit::TestCase
|
|
70
93
|
def test_reset
|
71
94
|
original_tree = @heckler.current_tree.deep_clone
|
72
95
|
original_mutatees = @heckler.mutatees.deep_clone
|
73
|
-
|
96
|
+
|
74
97
|
3.times { @heckler.process(@heckler.current_tree) }
|
75
|
-
|
98
|
+
|
76
99
|
assert_not_equal original_tree, @heckler.current_tree
|
77
100
|
assert_not_equal original_mutatees, @heckler.mutatees
|
78
|
-
|
101
|
+
|
79
102
|
@heckler.reset
|
80
103
|
assert_equal original_tree[2], @heckler.current_tree[2][1]
|
81
104
|
assert_equal original_mutatees, @heckler.mutatees
|
82
105
|
end
|
83
|
-
|
106
|
+
|
84
107
|
def test_reset_tree
|
85
108
|
original_tree = @heckler.current_tree.deep_clone
|
86
|
-
|
109
|
+
|
87
110
|
@heckler.process(@heckler.current_tree)
|
88
|
-
assert_not_equal original_tree, @heckler.current_tree
|
89
|
-
|
111
|
+
assert_not_equal original_tree, @heckler.current_tree
|
112
|
+
|
90
113
|
@heckler.reset_tree
|
91
114
|
assert_equal original_tree, @heckler.current_tree
|
92
115
|
end
|
93
|
-
|
116
|
+
|
94
117
|
def test_reset_should_work_over_several_process_calls
|
95
118
|
original_tree = @heckler.current_tree.deep_clone
|
96
119
|
original_mutatees = @heckler.mutatees.deep_clone
|
97
|
-
|
120
|
+
|
98
121
|
@heckler.process(@heckler.current_tree)
|
99
122
|
assert_not_equal original_tree, @heckler.current_tree
|
100
123
|
assert_not_equal original_mutatees, @heckler.mutatees
|
101
|
-
|
124
|
+
|
102
125
|
@heckler.reset
|
103
126
|
assert_equal original_tree, @heckler.current_tree
|
104
127
|
assert_equal original_mutatees, @heckler.mutatees
|
105
|
-
|
128
|
+
|
106
129
|
3.times { @heckler.process(@heckler.current_tree) }
|
107
130
|
assert_not_equal original_tree, @heckler.current_tree
|
108
131
|
assert_not_equal original_mutatees, @heckler.mutatees
|
109
|
-
|
132
|
+
|
110
133
|
@heckler.reset
|
111
134
|
assert_equal original_tree, @heckler.current_tree
|
112
135
|
assert_equal original_mutatees, @heckler.mutatees
|
113
136
|
end
|
114
|
-
|
137
|
+
|
115
138
|
def test_reset_mutatees
|
116
139
|
original_mutatees = @heckler.mutatees.deep_clone
|
117
|
-
|
140
|
+
|
118
141
|
@heckler.process(@heckler.current_tree)
|
119
142
|
assert_not_equal original_mutatees, @heckler.mutatees
|
120
|
-
|
143
|
+
|
121
144
|
@heckler.reset_mutatees
|
122
145
|
assert_equal original_mutatees, @heckler.mutatees
|
123
146
|
end
|
124
|
-
|
147
|
+
|
125
148
|
def teardown
|
126
149
|
@heckler.reset
|
127
150
|
end
|
128
151
|
end
|
129
152
|
|
130
|
-
module Heckle
|
131
|
-
class Base
|
132
|
-
def rand(*args)
|
133
|
-
5
|
134
|
-
end
|
135
|
-
|
136
|
-
def rand_number(*args)
|
137
|
-
5
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
153
|
class TestHeckleNumbers < Test::Unit::TestCase
|
143
154
|
def setup
|
144
155
|
@heckler = Heckle::Base.new("Heckled", "uses_numeric_literals")
|
145
156
|
end
|
146
|
-
|
157
|
+
|
147
158
|
def test_literals_should_flip_one_at_a_time
|
148
159
|
assert_equal 3, @heckler.mutations_left
|
149
160
|
expected = [:defn,
|
@@ -154,12 +165,12 @@ class TestHeckleNumbers < Test::Unit::TestCase
|
|
154
165
|
[:lasgn, :i, [:lit, 6]],
|
155
166
|
[:lasgn, :i, [:call, [:lvar, :i], :+, [:array, [:lit, 2147483648]]]],
|
156
167
|
[:lasgn, :i, [:call, [:lvar, :i], :-, [:array, [:lit, 3.5]]]]]]]
|
157
|
-
|
168
|
+
|
158
169
|
@heckler.process(@heckler.current_tree)
|
159
170
|
assert_equal expected, @heckler.current_tree
|
160
|
-
|
171
|
+
|
161
172
|
@heckler.reset_tree
|
162
|
-
|
173
|
+
|
163
174
|
expected = [:defn,
|
164
175
|
:uses_numeric_literals,
|
165
176
|
[:scope,
|
@@ -168,12 +179,12 @@ class TestHeckleNumbers < Test::Unit::TestCase
|
|
168
179
|
[:lasgn, :i, [:lit, 1]],
|
169
180
|
[:lasgn, :i, [:call, [:lvar, :i], :+, [:array, [:lit, 2147483653]]]],
|
170
181
|
[:lasgn, :i, [:call, [:lvar, :i], :-, [:array, [:lit, 3.5]]]]]]]
|
171
|
-
|
182
|
+
|
172
183
|
@heckler.process(@heckler.current_tree)
|
173
184
|
assert_equal expected, @heckler.current_tree
|
174
|
-
|
185
|
+
|
175
186
|
@heckler.reset_tree
|
176
|
-
|
187
|
+
|
177
188
|
expected = [:defn,
|
178
189
|
:uses_numeric_literals,
|
179
190
|
[:scope,
|
@@ -182,29 +193,21 @@ class TestHeckleNumbers < Test::Unit::TestCase
|
|
182
193
|
[:lasgn, :i, [:lit, 1]],
|
183
194
|
[:lasgn, :i, [:call, [:lvar, :i], :+, [:array, [:lit, 2147483648]]]],
|
184
195
|
[:lasgn, :i, [:call, [:lvar, :i], :-, [:array, [:lit, 8.5]]]]]]]
|
185
|
-
|
196
|
+
|
186
197
|
@heckler.process(@heckler.current_tree)
|
187
198
|
assert_equal expected, @heckler.current_tree
|
188
199
|
end
|
189
|
-
|
200
|
+
|
190
201
|
def teardown
|
191
202
|
@heckler.reset
|
192
203
|
end
|
193
204
|
end
|
194
205
|
|
195
|
-
module Heckle
|
196
|
-
class Base
|
197
|
-
def rand_symbol
|
198
|
-
:"l33t h4x0r"
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
206
|
class TestHeckleSymbols < Test::Unit::TestCase
|
204
207
|
def setup
|
205
208
|
@heckler = Heckle::Base.new("Heckled", "uses_symbols")
|
206
209
|
end
|
207
|
-
|
210
|
+
|
208
211
|
def test_default_structure
|
209
212
|
expected = [:defn,
|
210
213
|
:uses_symbols,
|
@@ -216,8 +219,8 @@ class TestHeckleSymbols < Test::Unit::TestCase
|
|
216
219
|
[:lasgn, :i, [:lit, :and_blah]]]]]
|
217
220
|
assert_equal expected, @heckler.current_tree
|
218
221
|
end
|
219
|
-
|
220
|
-
|
222
|
+
|
223
|
+
|
221
224
|
def test_should_randomize_symbol
|
222
225
|
expected = [:defn,
|
223
226
|
:uses_symbols,
|
@@ -229,9 +232,9 @@ class TestHeckleSymbols < Test::Unit::TestCase
|
|
229
232
|
[:lasgn, :i, [:lit, :and_blah]]]]]
|
230
233
|
@heckler.process(@heckler.current_tree)
|
231
234
|
assert_equal expected, @heckler.current_tree
|
232
|
-
|
235
|
+
|
233
236
|
@heckler.reset_tree
|
234
|
-
|
237
|
+
|
235
238
|
expected = [:defn,
|
236
239
|
:uses_symbols,
|
237
240
|
[:scope,
|
@@ -242,9 +245,9 @@ class TestHeckleSymbols < Test::Unit::TestCase
|
|
242
245
|
[:lasgn, :i, [:lit, :and_blah]]]]]
|
243
246
|
@heckler.process(@heckler.current_tree)
|
244
247
|
assert_equal expected, @heckler.current_tree
|
245
|
-
|
248
|
+
|
246
249
|
@heckler.reset_tree
|
247
|
-
|
250
|
+
|
248
251
|
expected = [:defn,
|
249
252
|
:uses_symbols,
|
250
253
|
[:scope,
|
@@ -262,7 +265,7 @@ class TestHeckleRegexes < Test::Unit::TestCase
|
|
262
265
|
def setup
|
263
266
|
@heckler = Heckle::Base.new("Heckled", "uses_regexes")
|
264
267
|
end
|
265
|
-
|
268
|
+
|
266
269
|
def test_default_structure
|
267
270
|
expected = [:defn,
|
268
271
|
:uses_regexes,
|
@@ -274,8 +277,8 @@ class TestHeckleRegexes < Test::Unit::TestCase
|
|
274
277
|
[:lasgn, :i, [:lit, /123/]]]]]
|
275
278
|
assert_equal expected, @heckler.current_tree
|
276
279
|
end
|
277
|
-
|
278
|
-
|
280
|
+
|
281
|
+
|
279
282
|
def test_should_randomize_symbol
|
280
283
|
expected = [:defn,
|
281
284
|
:uses_regexes,
|
@@ -287,9 +290,9 @@ class TestHeckleRegexes < Test::Unit::TestCase
|
|
287
290
|
[:lasgn, :i, [:lit, /123/]]]]]
|
288
291
|
@heckler.process(@heckler.current_tree)
|
289
292
|
assert_equal expected, @heckler.current_tree
|
290
|
-
|
293
|
+
|
291
294
|
@heckler.reset_tree
|
292
|
-
|
295
|
+
|
293
296
|
expected = [:defn,
|
294
297
|
:uses_regexes,
|
295
298
|
[:scope,
|
@@ -300,9 +303,9 @@ class TestHeckleRegexes < Test::Unit::TestCase
|
|
300
303
|
[:lasgn, :i, [:lit, /123/]]]]]
|
301
304
|
@heckler.process(@heckler.current_tree)
|
302
305
|
assert_equal expected, @heckler.current_tree
|
303
|
-
|
306
|
+
|
304
307
|
@heckler.reset_tree
|
305
|
-
|
308
|
+
|
306
309
|
expected = [:defn,
|
307
310
|
:uses_regexes,
|
308
311
|
[:scope,
|
@@ -320,7 +323,7 @@ class TestHeckleRanges < Test::Unit::TestCase
|
|
320
323
|
def setup
|
321
324
|
@heckler = Heckle::Base.new("Heckled", "uses_ranges")
|
322
325
|
end
|
323
|
-
|
326
|
+
|
324
327
|
def test_default_structure
|
325
328
|
expected = [:defn,
|
326
329
|
:uses_ranges,
|
@@ -332,7 +335,7 @@ class TestHeckleRanges < Test::Unit::TestCase
|
|
332
335
|
[:lasgn, :i, [:lit, 1..4]]]]]
|
333
336
|
assert_equal expected, @heckler.current_tree
|
334
337
|
end
|
335
|
-
|
338
|
+
|
336
339
|
def test_should_randomize_symbol
|
337
340
|
expected = [:defn,
|
338
341
|
:uses_ranges,
|
@@ -344,9 +347,9 @@ class TestHeckleRanges < Test::Unit::TestCase
|
|
344
347
|
[:lasgn, :i, [:lit, 1..4]]]]]
|
345
348
|
@heckler.process(@heckler.current_tree)
|
346
349
|
assert_equal expected, @heckler.current_tree
|
347
|
-
|
350
|
+
|
348
351
|
@heckler.reset_tree
|
349
|
-
|
352
|
+
|
350
353
|
expected = [:defn,
|
351
354
|
:uses_ranges,
|
352
355
|
[:scope,
|
@@ -357,9 +360,9 @@ class TestHeckleRanges < Test::Unit::TestCase
|
|
357
360
|
[:lasgn, :i, [:lit, 1..4]]]]]
|
358
361
|
@heckler.process(@heckler.current_tree)
|
359
362
|
assert_equal expected, @heckler.current_tree
|
360
|
-
|
363
|
+
|
361
364
|
@heckler.reset_tree
|
362
|
-
|
365
|
+
|
363
366
|
expected = [:defn,
|
364
367
|
:uses_ranges,
|
365
368
|
[:scope,
|
@@ -382,7 +385,7 @@ class TestHeckleSameLiteral < Test::Unit::TestCase
|
|
382
385
|
def teardown
|
383
386
|
@heckler.reset
|
384
387
|
end
|
385
|
-
|
388
|
+
|
386
389
|
def test_original_tree
|
387
390
|
expected = [:defn,
|
388
391
|
:uses_the_same_literal,
|
@@ -392,10 +395,10 @@ class TestHeckleSameLiteral < Test::Unit::TestCase
|
|
392
395
|
[:lasgn, :i, [:lit, 1]],
|
393
396
|
[:lasgn, :i, [:lit, 1]],
|
394
397
|
[:lasgn, :i, [:lit, 1]]]]]]
|
395
|
-
|
398
|
+
|
396
399
|
assert_equal expected, @heckler.current_tree
|
397
400
|
end
|
398
|
-
|
401
|
+
|
399
402
|
def test_literals_should_flip_one_at_a_time
|
400
403
|
# structure of uses_numeric_literals with first literal +5 (from stubbed rand)
|
401
404
|
expected = [:defn,
|
@@ -406,12 +409,12 @@ class TestHeckleSameLiteral < Test::Unit::TestCase
|
|
406
409
|
[:lasgn, :i, [:lit, 6]],
|
407
410
|
[:lasgn, :i, [:lit, 1]],
|
408
411
|
[:lasgn, :i, [:lit, 1]]]]]
|
409
|
-
|
412
|
+
|
410
413
|
@heckler.process(@heckler.current_tree)
|
411
414
|
assert_equal expected, @heckler.current_tree
|
412
|
-
|
415
|
+
|
413
416
|
@heckler.reset_tree
|
414
|
-
|
417
|
+
|
415
418
|
expected = [:defn,
|
416
419
|
:uses_the_same_literal,
|
417
420
|
[:scope,
|
@@ -420,12 +423,12 @@ class TestHeckleSameLiteral < Test::Unit::TestCase
|
|
420
423
|
[:lasgn, :i, [:lit, 1]],
|
421
424
|
[:lasgn, :i, [:lit, 6]],
|
422
425
|
[:lasgn, :i, [:lit, 1]]]]]
|
423
|
-
|
426
|
+
|
424
427
|
@heckler.process(@heckler.current_tree)
|
425
428
|
assert_equal expected, @heckler.current_tree
|
426
|
-
|
429
|
+
|
427
430
|
@heckler.reset_tree
|
428
|
-
|
431
|
+
|
429
432
|
expected = [:defn,
|
430
433
|
:uses_the_same_literal,
|
431
434
|
[:scope,
|
@@ -434,29 +437,21 @@ class TestHeckleSameLiteral < Test::Unit::TestCase
|
|
434
437
|
[:lasgn, :i, [:lit, 1]],
|
435
438
|
[:lasgn, :i, [:lit, 1]],
|
436
439
|
[:lasgn, :i, [:lit, 6]]]]]
|
437
|
-
|
440
|
+
|
438
441
|
@heckler.process(@heckler.current_tree)
|
439
442
|
assert_equal expected, @heckler.current_tree
|
440
443
|
end
|
441
444
|
end
|
442
445
|
|
443
|
-
module Heckle
|
444
|
-
class Base
|
445
|
-
def rand_string
|
446
|
-
"l33t h4x0r"
|
447
|
-
end
|
448
|
-
end
|
449
|
-
end
|
450
|
-
|
451
446
|
class TestHeckleStrings < Test::Unit::TestCase
|
452
447
|
def setup
|
453
448
|
@heckler = Heckle::Base.new("Heckled", "uses_strings")
|
454
449
|
end
|
455
|
-
|
450
|
+
|
456
451
|
def teardown
|
457
452
|
@heckler.reset
|
458
453
|
end
|
459
|
-
|
454
|
+
|
460
455
|
def test_default_structure
|
461
456
|
expected = [:defn,
|
462
457
|
:uses_strings,
|
@@ -468,7 +463,7 @@ class TestHeckleStrings < Test::Unit::TestCase
|
|
468
463
|
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hi, Frank"]]]]]]
|
469
464
|
assert_equal expected, @heckler.current_tree
|
470
465
|
end
|
471
|
-
|
466
|
+
|
472
467
|
def test_should_heckle_string_literals
|
473
468
|
expected = [:defn,
|
474
469
|
:uses_strings,
|
@@ -480,9 +475,9 @@ class TestHeckleStrings < Test::Unit::TestCase
|
|
480
475
|
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hi, Frank"]]]]]]
|
481
476
|
@heckler.process(@heckler.current_tree)
|
482
477
|
assert_equal expected, @heckler.current_tree
|
483
|
-
|
478
|
+
|
484
479
|
@heckler.reset_tree
|
485
|
-
|
480
|
+
|
486
481
|
expected = [:defn,
|
487
482
|
:uses_strings,
|
488
483
|
[:scope,
|
@@ -491,12 +486,12 @@ class TestHeckleStrings < Test::Unit::TestCase
|
|
491
486
|
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hello, Robert"]]],
|
492
487
|
[:call, [:ivar, :@names], :<<, [:array, [:str, "l33t h4x0r"]]],
|
493
488
|
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hi, Frank"]]]]]]
|
494
|
-
|
489
|
+
|
495
490
|
@heckler.process(@heckler.current_tree)
|
496
491
|
assert_equal expected, @heckler.current_tree
|
497
|
-
|
492
|
+
|
498
493
|
@heckler.reset_tree
|
499
|
-
|
494
|
+
|
500
495
|
expected = [:defn,
|
501
496
|
:uses_strings,
|
502
497
|
[:scope,
|
@@ -505,7 +500,7 @@ class TestHeckleStrings < Test::Unit::TestCase
|
|
505
500
|
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hello, Robert"]]],
|
506
501
|
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hello, Jeff"]]],
|
507
502
|
[:call, [:ivar, :@names], :<<, [:array, [:str, "l33t h4x0r"]]]]]]
|
508
|
-
|
503
|
+
|
509
504
|
@heckler.process(@heckler.current_tree)
|
510
505
|
assert_equal expected, @heckler.current_tree
|
511
506
|
end
|
@@ -515,11 +510,11 @@ class TestHeckleIfs < Test::Unit::TestCase
|
|
515
510
|
def setup
|
516
511
|
@heckler = Heckle::Base.new("Heckled", "uses_if")
|
517
512
|
end
|
518
|
-
|
513
|
+
|
519
514
|
def teardown
|
520
515
|
@heckler.reset
|
521
516
|
end
|
522
|
-
|
517
|
+
|
523
518
|
def test_default_structure
|
524
519
|
expected = [:defn,
|
525
520
|
:uses_if,
|
@@ -530,11 +525,11 @@ class TestHeckleIfs < Test::Unit::TestCase
|
|
530
525
|
[:vcall, :some_func],
|
531
526
|
[:if, [:vcall, :some_other_func], [:return], nil],
|
532
527
|
nil]]]]
|
533
|
-
|
534
|
-
|
528
|
+
|
529
|
+
|
535
530
|
assert_equal expected, @heckler.current_tree
|
536
531
|
end
|
537
|
-
|
532
|
+
|
538
533
|
def test_should_flip_if_to_unless
|
539
534
|
expected = [:defn,
|
540
535
|
:uses_if,
|
@@ -544,13 +539,13 @@ class TestHeckleIfs < Test::Unit::TestCase
|
|
544
539
|
[:if,
|
545
540
|
[:vcall, :some_func],
|
546
541
|
[:if, [:vcall, :some_other_func], nil, [:return]],
|
547
|
-
nil]]]]
|
548
|
-
|
542
|
+
nil]]]]
|
543
|
+
|
549
544
|
@heckler.process(@heckler.current_tree)
|
550
545
|
assert_equal expected, @heckler.current_tree
|
551
|
-
|
546
|
+
|
552
547
|
@heckler.reset_tree
|
553
|
-
|
548
|
+
|
554
549
|
expected = [:defn,
|
555
550
|
:uses_if,
|
556
551
|
[:scope,
|
@@ -559,8 +554,8 @@ class TestHeckleIfs < Test::Unit::TestCase
|
|
559
554
|
[:if,
|
560
555
|
[:vcall, :some_func],
|
561
556
|
nil,
|
562
|
-
[:if, [:vcall, :some_other_func], [:return], nil]]]]]
|
563
|
-
|
557
|
+
[:if, [:vcall, :some_other_func], [:return], nil]]]]]
|
558
|
+
|
564
559
|
@heckler.process(@heckler.current_tree)
|
565
560
|
assert_equal expected, @heckler.current_tree
|
566
561
|
end
|
@@ -570,26 +565,39 @@ class TestHeckleBooleans < Test::Unit::TestCase
|
|
570
565
|
def setup
|
571
566
|
@heckler = Heckle::Base.new("Heckled", "uses_boolean")
|
572
567
|
end
|
573
|
-
|
568
|
+
|
574
569
|
def teardown
|
575
570
|
@heckler.reset
|
576
571
|
end
|
577
|
-
|
572
|
+
|
578
573
|
def test_default_structure
|
579
|
-
expected = [:defn, :uses_boolean,
|
574
|
+
expected = [:defn, :uses_boolean,
|
575
|
+
[:scope,
|
576
|
+
[:block,
|
577
|
+
[:args],
|
578
|
+
[:lasgn, :a, [:true]],
|
579
|
+
[:lasgn, :b, [:false]]]]]
|
580
580
|
assert_equal expected, @heckler.current_tree
|
581
581
|
end
|
582
|
-
|
583
|
-
|
582
|
+
|
583
|
+
|
584
584
|
def test_should_flip_true_to_false_and_false_to_true
|
585
|
-
expected = [:defn, :uses_boolean,
|
586
|
-
|
585
|
+
expected = [:defn, :uses_boolean,
|
586
|
+
[:scope,
|
587
|
+
[:block,
|
588
|
+
[:args],
|
589
|
+
[:lasgn, :a, [:false]],
|
590
|
+
[:lasgn, :b, [:false]]]]]
|
591
|
+
|
587
592
|
@heckler.process(@heckler.current_tree)
|
588
593
|
assert_equal expected, @heckler.current_tree
|
589
|
-
|
594
|
+
|
590
595
|
@heckler.reset_tree
|
591
|
-
|
592
|
-
|
596
|
+
|
597
|
+
# flip both bools from above to true
|
598
|
+
expected[2][1][2][2][0] = :true
|
599
|
+
expected[2][1][3][2][0] = :true
|
600
|
+
|
593
601
|
@heckler.process(@heckler.current_tree)
|
594
602
|
assert_equal expected, @heckler.current_tree
|
595
603
|
end
|
@@ -599,11 +607,11 @@ class TestHeckleWhile < Test::Unit::TestCase
|
|
599
607
|
def setup
|
600
608
|
@heckler = Heckle::Base.new("Heckled", "uses_while")
|
601
609
|
end
|
602
|
-
|
610
|
+
|
603
611
|
def teardown
|
604
612
|
@heckler.reset
|
605
613
|
end
|
606
|
-
|
614
|
+
|
607
615
|
def test_default_structure
|
608
616
|
expected = [:defn,
|
609
617
|
:uses_while,
|
@@ -613,7 +621,7 @@ class TestHeckleWhile < Test::Unit::TestCase
|
|
613
621
|
[:while, [:vcall, :some_func], [:vcall, :some_other_func], true]]]]
|
614
622
|
assert_equal expected, @heckler.current_tree
|
615
623
|
end
|
616
|
-
|
624
|
+
|
617
625
|
def test_flips_while_to_until
|
618
626
|
expected = [:defn,
|
619
627
|
:uses_while,
|
@@ -630,11 +638,11 @@ class TestHeckleUntil < Test::Unit::TestCase
|
|
630
638
|
def setup
|
631
639
|
@heckler = Heckle::Base.new("Heckled", "uses_until")
|
632
640
|
end
|
633
|
-
|
641
|
+
|
634
642
|
def teardown
|
635
643
|
@heckler.reset
|
636
644
|
end
|
637
|
-
|
645
|
+
|
638
646
|
def test_default_structure
|
639
647
|
expected = [:defn,
|
640
648
|
:uses_until,
|
@@ -644,7 +652,7 @@ class TestHeckleUntil < Test::Unit::TestCase
|
|
644
652
|
[:until, [:vcall, :some_func], [:vcall, :some_other_func], true]]]]
|
645
653
|
assert_equal expected, @heckler.current_tree
|
646
654
|
end
|
647
|
-
|
655
|
+
|
648
656
|
def test_flips_until_to_while
|
649
657
|
expected = [:defn,
|
650
658
|
:uses_until,
|
metadata
CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: heckle
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.1.
|
7
|
-
date: 2006-12-
|
6
|
+
version: 1.1.1
|
7
|
+
date: 2006-12-20 00:00:00 -08:00
|
8
8
|
summary: Unit Test Sadism
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: ryand-ruby@zenspider.com
|
12
12
|
homepage: " http://www.rubyforge.org/projects/seattlerb"
|
13
13
|
rubyforge_project: seattlerb
|
14
|
-
description:
|
14
|
+
description: Heckle is a mutation tester. It modifies your code and runs your tests to make sure they fail. The idea is that if code can be changed and your tests don't notice, either that code isn't being covered or it doesn't do anything.
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|