ryanbriones-ZenTest 3.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +523 -0
- data/Manifest.txt +69 -0
- data/README.txt +110 -0
- data/Rakefile +68 -0
- data/articles/Article.css +721 -0
- data/articles/getting_started_with_autotest.html +532 -0
- data/articles/how_to_use_zentest.txt +393 -0
- data/bin/autotest +55 -0
- data/bin/multiruby +40 -0
- data/bin/multiruby_setup +68 -0
- data/bin/rails_test_audit +80 -0
- data/bin/unit_diff +38 -0
- data/bin/zentest +28 -0
- data/example.txt +42 -0
- data/example1.rb +7 -0
- data/example2.rb +15 -0
- data/example_dot_autotest.rb +45 -0
- data/lib/autotest.rb +654 -0
- data/lib/autotest/autoupdate.rb +26 -0
- data/lib/autotest/camping.rb +37 -0
- data/lib/autotest/cctray.rb +57 -0
- data/lib/autotest/discover.rb +6 -0
- data/lib/autotest/emacs.rb +35 -0
- data/lib/autotest/email_notify.rb +66 -0
- data/lib/autotest/fixtures.rb +12 -0
- data/lib/autotest/growl.rb +28 -0
- data/lib/autotest/heckle.rb +14 -0
- data/lib/autotest/html_report.rb +31 -0
- data/lib/autotest/jabber_notify.rb +111 -0
- data/lib/autotest/kdenotify.rb +14 -0
- data/lib/autotest/menu.rb +51 -0
- data/lib/autotest/migrate.rb +7 -0
- data/lib/autotest/notify.rb +34 -0
- data/lib/autotest/once.rb +9 -0
- data/lib/autotest/pretty.rb +83 -0
- data/lib/autotest/rails.rb +81 -0
- data/lib/autotest/rcov.rb +22 -0
- data/lib/autotest/redgreen.rb +21 -0
- data/lib/autotest/restart.rb +11 -0
- data/lib/autotest/screen.rb +73 -0
- data/lib/autotest/shame.rb +45 -0
- data/lib/autotest/snarl.rb +51 -0
- data/lib/autotest/timestamp.rb +9 -0
- data/lib/functional_test_matrix.rb +92 -0
- data/lib/multiruby.rb +401 -0
- data/lib/test/rails.rb +295 -0
- data/lib/test/rails/controller_test_case.rb +382 -0
- data/lib/test/rails/functional_test_case.rb +79 -0
- data/lib/test/rails/helper_test_case.rb +64 -0
- data/lib/test/rails/ivar_proxy.rb +31 -0
- data/lib/test/rails/pp_html_document.rb +74 -0
- data/lib/test/rails/rake_tasks.rb +50 -0
- data/lib/test/rails/render_tree.rb +93 -0
- data/lib/test/rails/test_case.rb +28 -0
- data/lib/test/rails/view_test_case.rb +597 -0
- data/lib/test/zentest_assertions.rb +134 -0
- data/lib/unit_diff.rb +259 -0
- data/lib/zentest.rb +566 -0
- data/lib/zentest_mapping.rb +99 -0
- data/test/test_autotest.rb +449 -0
- data/test/test_help.rb +36 -0
- data/test/test_rails_autotest.rb +229 -0
- data/test/test_rails_controller_test_case.rb +58 -0
- data/test/test_rails_helper_test_case.rb +48 -0
- data/test/test_rails_view_test_case.rb +275 -0
- data/test/test_unit_diff.rb +319 -0
- data/test/test_zentest.rb +566 -0
- data/test/test_zentest_assertions.rb +128 -0
- data/test/test_zentest_mapping.rb +222 -0
- metadata +151 -0
@@ -0,0 +1,319 @@
|
|
1
|
+
#!/usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
$TESTING = true
|
7
|
+
|
8
|
+
require 'unit_diff'
|
9
|
+
|
10
|
+
class TestUnitDiff < Test::Unit::TestCase
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@diff = UnitDiff.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_input
|
17
|
+
header = "Loaded suite ./blah\nStarted\nFF\nFinished in 0.035332 seconds.\n\n"
|
18
|
+
input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n 2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n<\"line1\"> expected but was\n<\"line2\\nline3\\n\\n\">.\n\n2 tests, 2 assertions, 2 failures, 0 errors\n"
|
19
|
+
|
20
|
+
# TODO: I think I'd like a separate footer array as well
|
21
|
+
expected = [[[" 1) Failure:\n", "test_test1(TestBlah) [./blah.rb:25]:\n", "<\"line1\\nline2\\nline3\\n\"> expected but was\n", "<\"line4\\nline5\\nline6\\n\">.\n"],
|
22
|
+
[" 2) Failure:\n", "test_test2(TestBlah) [./blah.rb:29]:\n", "<\"line1\"> expected but was\n", "<\"line2\\nline3\\n\\n\">.\n"]],
|
23
|
+
["\n", "2 tests, 2 assertions, 2 failures, 0 errors\n"]]
|
24
|
+
|
25
|
+
util_unit_diff(header, input, expected, :parse_input)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_input_miniunit
|
29
|
+
header = "Loaded suite -e\nStarted\nF\nFinished in 0.035332 seconds.\n\n"
|
30
|
+
input = "#{header} 1) Failure:
|
31
|
+
test_blah(TestBlah) [./blah.rb:25]:
|
32
|
+
Expected ['a', 'b', 'c'], not ['a', 'c', 'b'].
|
33
|
+
|
34
|
+
1 tests, 1 assertions, 1 failures, 0 errors
|
35
|
+
"
|
36
|
+
|
37
|
+
expected = [[[" 1) Failure:\n",
|
38
|
+
"test_blah(TestBlah) [./blah.rb:25]:\n",
|
39
|
+
"Expected ['a', 'b', 'c'], not ['a', 'c', 'b'].\n"]],
|
40
|
+
["\n", "1 tests, 1 assertions, 1 failures, 0 errors\n"]]
|
41
|
+
|
42
|
+
util_unit_diff(header, input, expected, :parse_input)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_input_mspec
|
46
|
+
header = <<-HEADER
|
47
|
+
Started
|
48
|
+
.......F
|
49
|
+
Finished in 0.1 seconds
|
50
|
+
|
51
|
+
HEADER
|
52
|
+
|
53
|
+
failure = <<-FAILURE
|
54
|
+
1)
|
55
|
+
The unless expression should fail FAILED
|
56
|
+
Expected nil to equal "baz":
|
57
|
+
FAILURE
|
58
|
+
|
59
|
+
backtrace = <<-BACKTRACE
|
60
|
+
PositiveExpectation#== at spec/mspec.rb:217
|
61
|
+
main.__script__ {} at spec/language/unless_spec.rb:49
|
62
|
+
Proc#call at kernel/core/proc.rb:127
|
63
|
+
SpecRunner#it at spec/mspec.rb:368
|
64
|
+
main.it at spec/mspec.rb:412
|
65
|
+
main.__script__ {} at spec/language/unless_spec.rb:48
|
66
|
+
Proc#call at kernel/core/proc.rb:127
|
67
|
+
SpecRunner#describe at spec/mspec.rb:378
|
68
|
+
main.describe at spec/mspec.rb:408
|
69
|
+
main.__script__ at spec/language/unless_spec.rb:3
|
70
|
+
CompiledMethod#as_script at kernel/bootstrap/primitives.rb:41
|
71
|
+
main.load at kernel/core/compile.rb:150
|
72
|
+
main.__script__ {} at last_mspec.rb:11
|
73
|
+
Array#each {} at kernel/core/array.rb:545
|
74
|
+
Integer(Fixnum)#times at kernel/core/integer.rb:15
|
75
|
+
Array#each at kernel/core/array.rb:545
|
76
|
+
main.__script__ at last_mspec.rb:16
|
77
|
+
CompiledMethod#as_script at kernel/bootstrap/primitives.rb:41
|
78
|
+
main.load at kernel/core/compile.rb:150
|
79
|
+
main.__script__ at kernel/loader.rb:145
|
80
|
+
BACKTRACE
|
81
|
+
|
82
|
+
footer = "\n8 examples, 1 failures\n"
|
83
|
+
input = header + failure + backtrace + footer
|
84
|
+
|
85
|
+
expected_backtrace = backtrace.split("\n").map {|l| "#{l}\n"}
|
86
|
+
expected = [[["1)\n", "The unless expression should fail FAILED\n",
|
87
|
+
"Expected nil to equal \"baz\":\n",
|
88
|
+
*expected_backtrace]],
|
89
|
+
["\n", "8 examples, 1 failures\n"]]
|
90
|
+
util_unit_diff(header, input, expected, :parse_input)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_input_mspec_multiline
|
94
|
+
header = <<-HEADER
|
95
|
+
Started
|
96
|
+
.......F
|
97
|
+
Finished in 0.1 seconds
|
98
|
+
|
99
|
+
HEADER
|
100
|
+
|
101
|
+
failure = <<-FAILURE
|
102
|
+
1)
|
103
|
+
Compiler compiles a case without an argument FAILED
|
104
|
+
Expected #<TestGenerator [[:push, :false], [:gif, #<Label 5>], [:push_literal, "foo"], [:string_dup], [:goto, #<Label 19>], [:set_label, #<Label 5>], [:push, :nil], [:gif, #<Label 10>], [:push_literal, "foo"], [:string_dup], [:goto, #<Label 19>], [:set_label, #<Label 10>], [:push, 2], [:push, 1], [:send, :==, 1, false], [:gif, #<Label 17>], [:push_literal, "bar"], [:string_dup], [:goto, #<Label 19>], [:set_label, #<Label 17>], [:push_literal, "baz"], [:string_dup], [:set_label, #<Label 19>]]
|
105
|
+
to equal #<TestGenerator [[:push, false], [:gif, #<Label 5>], [:push, "foo"], [:string_dup], [:goto, #<Label 6>], [:set_label, #<Label 5>], [:push, nil], [:set_label, #<Label 6>], [:pop], [:push, nil], [:gif, #<Label 12>], [:push, "foo"], [:string_dup], [:goto, #<Label 13>], [:set_label, #<Label 12>], [:push, nil], [:set_label, #<Label 13>], [:pop], [:push, 2], [:push, 1], [:send, :==, 1], [:gif, #<Label 21>], [:push, "bar"], [:string_dup], [:goto, #<Label 23>], [:set_label, #<Label 21>], [:push_literal, "baz"], [:string_dup], [:set_label, #<Label 23>], [:sret]]:
|
106
|
+
FAILURE
|
107
|
+
|
108
|
+
backtrace = <<-BACKTRACE
|
109
|
+
PositiveExpectation#== at spec/mspec.rb:216
|
110
|
+
main.gen at ./compiler2/spec/helper.rb:125
|
111
|
+
main.__script__ {} at compiler2/spec/control_spec.rb:448
|
112
|
+
BACKTRACE
|
113
|
+
|
114
|
+
footer = "\n8 examples, 1 failures\n"
|
115
|
+
input = header + failure + backtrace + footer
|
116
|
+
|
117
|
+
expected_backtrace = backtrace.split("\n").map {|l| "#{l}\n"}
|
118
|
+
expected_failure = failure.split("\n").map {|l| "#{l}\n"}
|
119
|
+
expected = [[[*(expected_failure + expected_backtrace)]],
|
120
|
+
["\n", "8 examples, 1 failures\n"]]
|
121
|
+
util_unit_diff(header, input, expected, :parse_input)
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_unit_diff_empty # simulates broken pipe at the least
|
125
|
+
input = ""
|
126
|
+
expected = ""
|
127
|
+
util_unit_diff("", "", "")
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_parse_diff_angles
|
131
|
+
input = [" 1) Failure:\n",
|
132
|
+
"test_test1(TestBlah) [./blah.rb:25]:\n",
|
133
|
+
"<\"<html>\"> expected but was\n",
|
134
|
+
"<\"<body>\">.\n"
|
135
|
+
]
|
136
|
+
|
137
|
+
expected = [[" 1) Failure:\n", "test_test1(TestBlah) [./blah.rb:25]:\n"],
|
138
|
+
["<html>"],
|
139
|
+
["<body>"],
|
140
|
+
[]]
|
141
|
+
|
142
|
+
assert_equal expected, @diff.parse_diff(input)
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_parse_diff_miniunit
|
146
|
+
input = [" 1) Failure:\n",
|
147
|
+
"test_blah(TestBlah) [./blah.rb:25]:\n",
|
148
|
+
"Expected ['a', 'b', 'c'], not ['a', 'c', 'b'].\n"]
|
149
|
+
|
150
|
+
expected = [[" 1) Failure:\n", "test_blah(TestBlah) [./blah.rb:25]:\n"],
|
151
|
+
["['a', 'b', 'c']"],
|
152
|
+
["['a', 'c', 'b']"],
|
153
|
+
[]]
|
154
|
+
|
155
|
+
assert_equal expected, @diff.parse_diff(input)
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_parse_diff_miniunit_multiline
|
159
|
+
input = [" 1) Failure:\n",
|
160
|
+
"test_blah(TestBlah) [./blah.rb:25]:\n",
|
161
|
+
"Expected ['a',\n'b',\n'c'], not ['a',\n'c',\n'b'].\n"]
|
162
|
+
|
163
|
+
expected = [[" 1) Failure:\n", "test_blah(TestBlah) [./blah.rb:25]:\n"],
|
164
|
+
["['a',\n'b',\n'c']"],
|
165
|
+
["['a',\n'c',\n'b']"],
|
166
|
+
[]]
|
167
|
+
|
168
|
+
assert_equal expected, @diff.parse_diff(input)
|
169
|
+
end
|
170
|
+
def test_parse_diff1
|
171
|
+
input = [" 1) Failure:\n",
|
172
|
+
"test_test1(TestBlah) [./blah.rb:25]:\n",
|
173
|
+
"<\"line1\\nline2\\nline3\\n\"> expected but was\n",
|
174
|
+
"<\"line4\\nline5\\nline6\\n\">.\n"
|
175
|
+
]
|
176
|
+
|
177
|
+
expected = [[" 1) Failure:\n", "test_test1(TestBlah) [./blah.rb:25]:\n"], ["line1\\nline2\\nline3\\n"], ["line4\\nline5\\nline6\\n"], []]
|
178
|
+
|
179
|
+
assert_equal expected, @diff.parse_diff(input)
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_parse_diff2
|
183
|
+
input = [" 2) Failure:\n",
|
184
|
+
"test_test2(TestBlah) [./blah.rb:29]:\n",
|
185
|
+
"<\"line1\"> expected but was\n",
|
186
|
+
"<\"line2\\nline3\\n\\n\">.\n"
|
187
|
+
]
|
188
|
+
|
189
|
+
expected = [[" 2) Failure:\n",
|
190
|
+
"test_test2(TestBlah) [./blah.rb:29]:\n"],
|
191
|
+
["line1"],
|
192
|
+
["line2\\nline3\\n\\n"],
|
193
|
+
[]
|
194
|
+
]
|
195
|
+
|
196
|
+
assert_equal expected, @diff.parse_diff(input)
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_parse_diff3
|
200
|
+
input = [" 13) Failure:\n",
|
201
|
+
"test_case_stmt(TestRubyToRubyC) [./r2ctestcase.rb:1198]:\n",
|
202
|
+
"Unknown expected data.\n",
|
203
|
+
"<false> is not true.\n"]
|
204
|
+
|
205
|
+
expected = [[" 13) Failure:\n", "test_case_stmt(TestRubyToRubyC) [./r2ctestcase.rb:1198]:\n", "Unknown expected data.\n"], ["<false> is not true.\n"], nil, []]
|
206
|
+
|
207
|
+
assert_equal expected, @diff.parse_diff(input)
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_parse_diff_suspect_equals
|
211
|
+
input = ["1) Failure:\n",
|
212
|
+
"test_util_capture(AssertionsTest) [test/test_zentest_assertions.rb:53]:\n",
|
213
|
+
"<\"out\"> expected but was\n",
|
214
|
+
"<\"out\">.\n"]
|
215
|
+
expected = [["1) Failure:\n",
|
216
|
+
"test_util_capture(AssertionsTest) [test/test_zentest_assertions.rb:53]:\n"],
|
217
|
+
["out"],
|
218
|
+
["out"], []]
|
219
|
+
|
220
|
+
assert_equal expected, @diff.parse_diff(input)
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_parse_diff_NOT_suspect_equals
|
224
|
+
input = ["1) Failure:\n",
|
225
|
+
"test_util_capture(AssertionsTest) [test/test_zentest_assertions.rb:53]:\n",
|
226
|
+
"<\"out\"> expected but was\n",
|
227
|
+
"<\"out\\n\">.\n"]
|
228
|
+
expected = [["1) Failure:\n",
|
229
|
+
"test_util_capture(AssertionsTest) [test/test_zentest_assertions.rb:53]:\n"],
|
230
|
+
["out"],
|
231
|
+
["out\\n"], []]
|
232
|
+
|
233
|
+
assert_equal expected, @diff.parse_diff(input)
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_parse_diff_mspec
|
237
|
+
input = ["1)\n", "The unless expression should fail FAILED\n",
|
238
|
+
"Expected nil to equal \"baz\":\n",
|
239
|
+
" PositiveExpectation#== at spec/mspec.rb:217\n"]
|
240
|
+
|
241
|
+
expected = [["1)\n", "The unless expression should fail FAILED\n"],
|
242
|
+
["nil"],
|
243
|
+
["\"baz\""],
|
244
|
+
[" PositiveExpectation#== at spec/mspec.rb:217"]]
|
245
|
+
|
246
|
+
assert_equal expected, @diff.parse_diff(input)
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_parse_diff_mspec_multiline
|
250
|
+
input = ["1)\n", "The unless expression should fail FAILED\n",
|
251
|
+
"Expected #<TestGenerator [[:push, :true],\n", " [:dup]\n", "]\n",
|
252
|
+
"to equal #<TestGenerator [[:pop],\n", " [:dup]\n", "]:\n",
|
253
|
+
" PositiveExpectation#== at spec/mspec.rb:217\n"]
|
254
|
+
|
255
|
+
expected = [["1)\n", "The unless expression should fail FAILED\n"],
|
256
|
+
["#<TestGenerator [[:push, :true],\n", " [:dup]\n", "]"],
|
257
|
+
["#<TestGenerator [[:pop],\n", " [:dup]\n", "]"],
|
258
|
+
[" PositiveExpectation#== at spec/mspec.rb:217"]]
|
259
|
+
|
260
|
+
assert_equal expected, @diff.parse_diff(input)
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_unit_diff_angles
|
264
|
+
header = "Loaded suite ./blah\nStarted\nF\nFinished in 0.035332 seconds.\n\n"
|
265
|
+
input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"<html>\"> expected but was\n<\"<body>\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors\n"
|
266
|
+
expected = "1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1c1\n< <html>\n---\n> <body>\n\n1 tests, 1 assertions, 1 failures, 0 errors"
|
267
|
+
|
268
|
+
util_unit_diff(header, input, expected)
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_unit_diff1
|
272
|
+
header = "Loaded suite ./blah\nStarted\nF\nFinished in 0.035332 seconds.\n\n"
|
273
|
+
input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors\n"
|
274
|
+
expected = "1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1,3c1,3\n< line1\n< line2\n< line3\n---\n> line4\n> line5\n> line6\n\n1 tests, 1 assertions, 1 failures, 0 errors"
|
275
|
+
|
276
|
+
util_unit_diff(header, input, expected)
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_unit_diff2
|
280
|
+
header = "Loaded suite ./blah\nStarted\nFF\nFinished in 0.035332 seconds.\n\n"
|
281
|
+
input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n 2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n<\"line1\"> expected but was\n<\"line2\\nline3\\n\\n\">.\n\n2 tests, 2 assertions, 2 failures, 0 errors\n"
|
282
|
+
expected = "1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1,3c1,3\n< line1\n< line2\n< line3\n---\n> line4\n> line5\n> line6\n\n2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n1c1,4\n< line1\n---\n> line2\n> line3\n> \n> \n\n2 tests, 2 assertions, 2 failures, 0 errors"
|
283
|
+
|
284
|
+
util_unit_diff(header, input, expected)
|
285
|
+
end
|
286
|
+
|
287
|
+
def test_unit_diff3
|
288
|
+
header = ""
|
289
|
+
input = " 13) Failure:\ntest_case_stmt(TestRubyToRubyC) [./r2ctestcase.rb:1198]:\nUnknown expected data.\n<false> is not true.\n"
|
290
|
+
expected = "13) Failure:\ntest_case_stmt(TestRubyToRubyC) [./r2ctestcase.rb:1198]:\nUnknown expected data.\n<false> is not true."
|
291
|
+
|
292
|
+
util_unit_diff(header, input, expected)
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_unit_diff_suspect_equals
|
296
|
+
header = "Loaded suite ./blah\nStarted\n.............................................F............................................\nFinished in 0.834671 seconds.\n\n"
|
297
|
+
footer = "90 tests, 241 assertions, 1 failures, 0 errors"
|
298
|
+
input = "#{header} 1) Failure:\ntest_unit_diff_suspect_equals(TestUnitDiff) [./test/test_unit_diff.rb:122]:\n<\"out\"> expected but was\n<\"out\">.\n\n#{footer}"
|
299
|
+
expected = "1) Failure:\ntest_unit_diff_suspect_equals(TestUnitDiff) [./test/test_unit_diff.rb:122]:\n[no difference--suspect ==]\n\n#{footer}"
|
300
|
+
|
301
|
+
util_unit_diff(header, input, expected)
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_unit_diff_NOT_suspect_equals
|
305
|
+
header = "Loaded suite ./blah\nStarted\n.\nFinished in 0.0 seconds.\n\n"
|
306
|
+
input = "#{header} 1) Failure:\ntest_blah(TestBlah)\n<\"out\"> expected but was\n<\"out\\n\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors"
|
307
|
+
expected = "1) Failure:\ntest_blah(TestBlah)\n1a2\n> \n\n1 tests, 1 assertions, 1 failures, 0 errors"
|
308
|
+
|
309
|
+
util_unit_diff(header, input, expected)
|
310
|
+
end
|
311
|
+
|
312
|
+
def util_unit_diff(header, input, expected, msg=:unit_diff)
|
313
|
+
output = StringIO.new("")
|
314
|
+
actual = @diff.send(msg, StringIO.new(input), output)
|
315
|
+
assert_equal header, output.string, "header output"
|
316
|
+
assert_equal expected, actual
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
@@ -0,0 +1,566 @@
|
|
1
|
+
#!/usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
if defined? RUBY_ENGINE then
|
4
|
+
warn "rubinius does not support features required by zentest. Skipping tests"
|
5
|
+
return
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'test/unit' unless defined? $ZENTEST and $ZENTEST
|
9
|
+
|
10
|
+
$TESTING = true
|
11
|
+
|
12
|
+
# I do this so I can still run ZenTest against the tests and itself...
|
13
|
+
require 'zentest' unless defined? $ZENTEST
|
14
|
+
|
15
|
+
class TrueClass # stupid YAML is breaking my tests. Enters via Test::Rails
|
16
|
+
remove_method :taguri, :taguri=, :to_yaml rescue nil
|
17
|
+
end
|
18
|
+
|
19
|
+
# These are just classes set up for quick testing.
|
20
|
+
# TODO: need to test a compound class name Mod::Cls
|
21
|
+
|
22
|
+
class Cls1 # ZenTest SKIP
|
23
|
+
def meth1; end
|
24
|
+
def self.meth2; end
|
25
|
+
end
|
26
|
+
|
27
|
+
class TestCls1 # ZenTest SKIP
|
28
|
+
def setup; end
|
29
|
+
def teardown; end
|
30
|
+
def test_meth1; end
|
31
|
+
def test_meth2; assert(true, "something"); end
|
32
|
+
end
|
33
|
+
|
34
|
+
class SuperDuper # ZenTest SKIP
|
35
|
+
def self.cls_inherited; end
|
36
|
+
def inherited; end
|
37
|
+
def overridden; end
|
38
|
+
end
|
39
|
+
|
40
|
+
class LowlyOne < SuperDuper # ZenTest SKIP
|
41
|
+
def self.cls_extended; end
|
42
|
+
def overridden; end
|
43
|
+
def extended; end
|
44
|
+
def pretty_print; end
|
45
|
+
def pretty_print_cycle; end
|
46
|
+
end
|
47
|
+
|
48
|
+
# This is the good case where there are no missing methods on either side.
|
49
|
+
|
50
|
+
class Blah0
|
51
|
+
def missingtest; end
|
52
|
+
def notmissing1; end
|
53
|
+
def notmissing2; end
|
54
|
+
|
55
|
+
# found by zentest on testcase1.rb
|
56
|
+
def missingimpl; end
|
57
|
+
end
|
58
|
+
|
59
|
+
class TestBlah0
|
60
|
+
def setup; end
|
61
|
+
def teardown; end
|
62
|
+
|
63
|
+
def test_notmissing1
|
64
|
+
assert(true, "a test")
|
65
|
+
end
|
66
|
+
def test_notmissing2_ext1
|
67
|
+
assert(true, "a test")
|
68
|
+
end
|
69
|
+
def test_notmissing2_ext2
|
70
|
+
flunk("a failed test")
|
71
|
+
end
|
72
|
+
def test_missingimpl; end
|
73
|
+
def test_missingtest; end
|
74
|
+
end
|
75
|
+
|
76
|
+
class Blah1
|
77
|
+
def missingtest; end
|
78
|
+
def notmissing1; end
|
79
|
+
def notmissing2; end
|
80
|
+
end
|
81
|
+
|
82
|
+
class TestBlah1
|
83
|
+
def test_notmissing1; end
|
84
|
+
def test_notmissing2_ext1; end
|
85
|
+
def test_notmissing2_ext2; end
|
86
|
+
def test_missingimpl; Blah1.new.missingimpl; end
|
87
|
+
def test_integration_blah1; end
|
88
|
+
def test_integration_blah2; end
|
89
|
+
def test_integration_blah3; end
|
90
|
+
end
|
91
|
+
|
92
|
+
module Something2
|
93
|
+
class Blah2
|
94
|
+
def missingtest; end
|
95
|
+
def notmissing1; end
|
96
|
+
def notmissing2; end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
module TestSomething2
|
101
|
+
class TestBlah2
|
102
|
+
def test_notmissing1; end
|
103
|
+
def test_notmissing2_ext1; end
|
104
|
+
def test_notmissing2_ext2; end
|
105
|
+
def test_missingimpl; end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# only test classes
|
110
|
+
class TestBlah3
|
111
|
+
def test_missingimpl; end
|
112
|
+
end
|
113
|
+
# only regular classes
|
114
|
+
class Blah4
|
115
|
+
def missingtest1; end
|
116
|
+
def missingtest2; end
|
117
|
+
end
|
118
|
+
|
119
|
+
# subclassing a builtin class
|
120
|
+
class MyHash5 < Hash
|
121
|
+
def []; end
|
122
|
+
def missingtest1; end
|
123
|
+
end
|
124
|
+
|
125
|
+
# nested class
|
126
|
+
module MyModule6
|
127
|
+
class MyClass6
|
128
|
+
def []; end
|
129
|
+
def missingtest1; end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# nested class
|
134
|
+
module MyModule7; end # in 1.9+ you'll not need this
|
135
|
+
class MyModule7::MyClass7
|
136
|
+
def []; end
|
137
|
+
def missingtest1; end
|
138
|
+
end
|
139
|
+
|
140
|
+
class MyClass8
|
141
|
+
def self.foobar; end
|
142
|
+
def MyClass8.foobaz; end
|
143
|
+
end
|
144
|
+
|
145
|
+
class TestTrueClass; end
|
146
|
+
|
147
|
+
class TestZenTest < Test::Unit::TestCase
|
148
|
+
|
149
|
+
def setup
|
150
|
+
@tester = ZenTest.new()
|
151
|
+
end
|
152
|
+
|
153
|
+
############################################################
|
154
|
+
# Utility Methods
|
155
|
+
|
156
|
+
def util_simple_setup
|
157
|
+
@tester.klasses = {
|
158
|
+
"Something" =>
|
159
|
+
{
|
160
|
+
"method1" => true,
|
161
|
+
"method1!" => true,
|
162
|
+
"method1=" => true,
|
163
|
+
"method1?" => true,
|
164
|
+
"attrib" => true,
|
165
|
+
"attrib=" => true,
|
166
|
+
"equal?" => true,
|
167
|
+
"self.method3" => true,
|
168
|
+
"self.[]" => true,
|
169
|
+
},
|
170
|
+
}
|
171
|
+
@tester.test_klasses = {
|
172
|
+
"TestSomething" =>
|
173
|
+
{
|
174
|
+
"test_class_method4" => true,
|
175
|
+
"test_method2" => true,
|
176
|
+
"setup" => true,
|
177
|
+
"teardown" => true,
|
178
|
+
"test_class_index" => true,
|
179
|
+
},
|
180
|
+
}
|
181
|
+
@tester.inherited_methods = @tester.test_klasses.merge(@tester.klasses)
|
182
|
+
@generated_code = "
|
183
|
+
require 'test/unit' unless defined? $ZENTEST and $ZENTEST
|
184
|
+
|
185
|
+
class Something
|
186
|
+
def self.method4(*args)
|
187
|
+
raise NotImplementedError, 'Need to write self.method4'
|
188
|
+
end
|
189
|
+
|
190
|
+
def method2(*args)
|
191
|
+
raise NotImplementedError, 'Need to write method2'
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
class TestSomething < Test::Unit::TestCase
|
196
|
+
def test_class_method3
|
197
|
+
raise NotImplementedError, 'Need to write test_class_method3'
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_attrib
|
201
|
+
raise NotImplementedError, 'Need to write test_attrib'
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_attrib_equals
|
205
|
+
raise NotImplementedError, 'Need to write test_attrib_equals'
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_equal_eh
|
209
|
+
raise NotImplementedError, 'Need to write test_equal_eh'
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_method1
|
213
|
+
raise NotImplementedError, 'Need to write test_method1'
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_method1_bang
|
217
|
+
raise NotImplementedError, 'Need to write test_method1_bang'
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_method1_eh
|
221
|
+
raise NotImplementedError, 'Need to write test_method1_eh'
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_method1_equals
|
225
|
+
raise NotImplementedError, 'Need to write test_method1_equals'
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
# Number of errors detected: 10
|
230
|
+
"
|
231
|
+
end
|
232
|
+
|
233
|
+
############################################################
|
234
|
+
# Accessors & Adders:
|
235
|
+
|
236
|
+
def test_initialize
|
237
|
+
refute_nil(@tester, "Tester must be initialized")
|
238
|
+
# TODO: should do more at this stage
|
239
|
+
end
|
240
|
+
|
241
|
+
############################################################
|
242
|
+
# Converters and Testers:
|
243
|
+
|
244
|
+
def test_is_test_class
|
245
|
+
# classes
|
246
|
+
assert(@tester.is_test_class(TestCls1),
|
247
|
+
"All test classes must start with Test")
|
248
|
+
assert(!@tester.is_test_class(Cls1),
|
249
|
+
"Classes not starting with Test must not be test classes")
|
250
|
+
# strings
|
251
|
+
assert(@tester.is_test_class("TestCls1"),
|
252
|
+
"All test classes must start with Test")
|
253
|
+
assert(@tester.is_test_class("TestMod::TestCls1"),
|
254
|
+
"All test modules must start with test as well")
|
255
|
+
assert(!@tester.is_test_class("Cls1"),
|
256
|
+
"Classes not starting with Test must not be test classes")
|
257
|
+
assert(!@tester.is_test_class("NotTestMod::TestCls1"),
|
258
|
+
"Modules not starting with Test must not be test classes")
|
259
|
+
assert(!@tester.is_test_class("NotTestMod::NotTestCls1"),
|
260
|
+
"All names must start with Test to be test classes")
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_is_test_class_reversed
|
264
|
+
old = $r
|
265
|
+
$r = true
|
266
|
+
assert(@tester.is_test_class("Cls1Test"),
|
267
|
+
"Reversed: All test classes must end with Test")
|
268
|
+
assert(@tester.is_test_class("ModTest::Cls1Test"),
|
269
|
+
"Reversed: All test classes must end with Test")
|
270
|
+
assert(!@tester.is_test_class("TestMod::TestCls1"),
|
271
|
+
"Reversed: All test classes must end with Test")
|
272
|
+
$r = old
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_convert_class_name
|
276
|
+
|
277
|
+
assert_equal('Cls1', @tester.convert_class_name(TestCls1))
|
278
|
+
assert_equal('TestCls1', @tester.convert_class_name(Cls1))
|
279
|
+
|
280
|
+
assert_equal('Cls1', @tester.convert_class_name('TestCls1'))
|
281
|
+
assert_equal('TestCls1', @tester.convert_class_name('Cls1'))
|
282
|
+
|
283
|
+
assert_equal('TestModule::TestCls1',
|
284
|
+
@tester.convert_class_name('Module::Cls1'))
|
285
|
+
assert_equal('Module::Cls1',
|
286
|
+
@tester.convert_class_name('TestModule::TestCls1'))
|
287
|
+
end
|
288
|
+
|
289
|
+
def test_convert_class_name_reversed
|
290
|
+
old = $r
|
291
|
+
$r = true
|
292
|
+
|
293
|
+
assert_equal('Cls1', @tester.convert_class_name("Cls1Test"))
|
294
|
+
assert_equal('Cls1Test', @tester.convert_class_name(Cls1))
|
295
|
+
|
296
|
+
assert_equal('Cls1', @tester.convert_class_name('Cls1Test'))
|
297
|
+
assert_equal('Cls1Test', @tester.convert_class_name('Cls1'))
|
298
|
+
|
299
|
+
assert_equal('ModuleTest::Cls1Test',
|
300
|
+
@tester.convert_class_name('Module::Cls1'))
|
301
|
+
assert_equal('Module::Cls1',
|
302
|
+
@tester.convert_class_name('ModuleTest::Cls1Test'))
|
303
|
+
$r = old
|
304
|
+
end
|
305
|
+
|
306
|
+
############################################################
|
307
|
+
# Missing Classes and Methods:
|
308
|
+
|
309
|
+
def test_missing_methods_empty
|
310
|
+
missing = @tester.missing_methods
|
311
|
+
assert_equal({}, missing)
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_add_missing_method_normal
|
315
|
+
@tester.add_missing_method("SomeClass", "some_method")
|
316
|
+
missing = @tester.missing_methods
|
317
|
+
assert_equal({"SomeClass" => { "some_method" => true } }, missing)
|
318
|
+
end
|
319
|
+
|
320
|
+
def test_add_missing_method_duplicates
|
321
|
+
@tester.add_missing_method("SomeClass", "some_method")
|
322
|
+
@tester.add_missing_method("SomeClass", "some_method")
|
323
|
+
@tester.add_missing_method("SomeClass", "some_method")
|
324
|
+
missing = @tester.missing_methods
|
325
|
+
assert_equal({"SomeClass" => { "some_method" => true } }, missing)
|
326
|
+
end
|
327
|
+
|
328
|
+
def test_analyze_simple
|
329
|
+
self.util_simple_setup
|
330
|
+
|
331
|
+
@tester.analyze
|
332
|
+
missing = @tester.missing_methods
|
333
|
+
expected = {
|
334
|
+
"Something" => {
|
335
|
+
"method2" => true,
|
336
|
+
"self.method4" => true,
|
337
|
+
},
|
338
|
+
"TestSomething" => {
|
339
|
+
"test_class_method3" => true,
|
340
|
+
"test_attrib" => true,
|
341
|
+
"test_attrib_equals" => true,
|
342
|
+
"test_equal_eh" => true,
|
343
|
+
"test_method1" => true,
|
344
|
+
"test_method1_eh"=>true,
|
345
|
+
"test_method1_bang"=>true,
|
346
|
+
"test_method1_equals"=>true,
|
347
|
+
}
|
348
|
+
}
|
349
|
+
assert_equal(expected, missing)
|
350
|
+
end
|
351
|
+
|
352
|
+
def test_create_method
|
353
|
+
list = @tester.create_method(" ", 1, "wobble")
|
354
|
+
assert_equal([" def wobble(*args)",
|
355
|
+
" raise NotImplementedError, 'Need to write wobble'",
|
356
|
+
" end"],list)
|
357
|
+
end
|
358
|
+
|
359
|
+
def test_methods_and_tests
|
360
|
+
@tester.process_class("ZenTest")
|
361
|
+
@tester.process_class("TestZenTest")
|
362
|
+
m,t = @tester.methods_and_tests("ZenTest", "TestZenTest")
|
363
|
+
assert(m.include?("methods_and_tests"))
|
364
|
+
assert(t.include?("test_methods_and_tests"))
|
365
|
+
end
|
366
|
+
|
367
|
+
def test_generate_code_simple
|
368
|
+
self.util_simple_setup
|
369
|
+
|
370
|
+
@tester.analyze
|
371
|
+
str = @tester.generate_code[1..-1].join("\n")
|
372
|
+
exp = @generated_code
|
373
|
+
|
374
|
+
assert_equal(exp, str)
|
375
|
+
end
|
376
|
+
|
377
|
+
def test_get_class_good
|
378
|
+
assert_equal(Object, @tester.get_class("Object"))
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_get_class_bad
|
382
|
+
assert_nil(@tester.get_class("ZZZObject"))
|
383
|
+
end
|
384
|
+
|
385
|
+
def test_get_inherited_methods_for_subclass
|
386
|
+
expect = { "inherited" => true, "overridden" => true }
|
387
|
+
result = @tester.get_inherited_methods_for("LowlyOne", false)
|
388
|
+
|
389
|
+
assert_equal(expect, result)
|
390
|
+
end
|
391
|
+
|
392
|
+
def test_get_inherited_methods_for_subclass_full
|
393
|
+
expect = Object.instance_methods + %w( inherited overridden )
|
394
|
+
expect.map! { |m| m.to_s }
|
395
|
+
result = @tester.get_inherited_methods_for("LowlyOne", true)
|
396
|
+
|
397
|
+
assert_equal(expect.sort, result.keys.sort)
|
398
|
+
end
|
399
|
+
|
400
|
+
def test_get_inherited_methods_for_superclass
|
401
|
+
expect = { }
|
402
|
+
result = @tester.get_inherited_methods_for("SuperDuper", false)
|
403
|
+
|
404
|
+
assert_equal(expect.keys.sort, result.keys.sort)
|
405
|
+
end
|
406
|
+
|
407
|
+
def test_get_inherited_methods_for_superclass_full
|
408
|
+
expect = Object.instance_methods.map { |m| m.to_s }
|
409
|
+
result = @tester.get_inherited_methods_for("SuperDuper", true)
|
410
|
+
|
411
|
+
assert_equal(expect.sort, result.keys.sort)
|
412
|
+
end
|
413
|
+
|
414
|
+
def test_get_methods_for_subclass
|
415
|
+
expect = {
|
416
|
+
"self.cls_extended" => true,
|
417
|
+
"overridden" => true,
|
418
|
+
"extended" => true
|
419
|
+
}
|
420
|
+
result = @tester.get_methods_for("LowlyOne")
|
421
|
+
|
422
|
+
assert_equal(expect, result)
|
423
|
+
end
|
424
|
+
|
425
|
+
def test_get_methods_for_subclass_full
|
426
|
+
expect = {
|
427
|
+
"self.cls_inherited" => true,
|
428
|
+
"self.cls_extended" => true,
|
429
|
+
"overridden" => true,
|
430
|
+
"extended" => true
|
431
|
+
}
|
432
|
+
result = @tester.get_methods_for("LowlyOne", true)
|
433
|
+
|
434
|
+
assert_equal(expect, result)
|
435
|
+
end
|
436
|
+
|
437
|
+
def test_get_methods_for_superclass
|
438
|
+
expect = {
|
439
|
+
"self.cls_inherited" => true,
|
440
|
+
"overridden" => true,
|
441
|
+
"inherited" => true }
|
442
|
+
result = @tester.get_methods_for("SuperDuper")
|
443
|
+
|
444
|
+
assert_equal(expect, result)
|
445
|
+
end
|
446
|
+
|
447
|
+
def test_result
|
448
|
+
self.util_simple_setup
|
449
|
+
|
450
|
+
@tester.analyze
|
451
|
+
@tester.generate_code
|
452
|
+
str = @tester.result.split($/, 2).last
|
453
|
+
exp = @generated_code
|
454
|
+
|
455
|
+
assert_equal(exp, str)
|
456
|
+
end
|
457
|
+
|
458
|
+
def test_load_file
|
459
|
+
# HACK raise NotImplementedError, 'Need to write test_load_file'
|
460
|
+
end
|
461
|
+
|
462
|
+
def test_scan_files
|
463
|
+
# HACK raise NotImplementedError, 'Need to write test_scan_files'
|
464
|
+
end
|
465
|
+
|
466
|
+
def test_process_class
|
467
|
+
assert_equal({}, @tester.klasses)
|
468
|
+
assert_equal({}, @tester.test_klasses)
|
469
|
+
assert_equal({}, @tester.inherited_methods["SuperDuper"])
|
470
|
+
@tester.process_class("SuperDuper")
|
471
|
+
assert_equal({"SuperDuper"=> {
|
472
|
+
"self.cls_inherited"=>true,
|
473
|
+
"inherited"=>true,
|
474
|
+
"overridden"=>true}},
|
475
|
+
@tester.klasses)
|
476
|
+
assert_equal({}, @tester.test_klasses)
|
477
|
+
assert_equal({}, @tester.inherited_methods["SuperDuper"])
|
478
|
+
end
|
479
|
+
|
480
|
+
def test_klasses_equals
|
481
|
+
self.util_simple_setup
|
482
|
+
assert_equal({"Something"=> {
|
483
|
+
"self.method3"=>true,
|
484
|
+
"equal?"=>true,
|
485
|
+
"attrib="=>true,
|
486
|
+
"self.[]"=>true,
|
487
|
+
"method1"=>true,
|
488
|
+
"method1="=>true,
|
489
|
+
"method1?"=>true,
|
490
|
+
"method1!"=>true,
|
491
|
+
"method1"=>true,
|
492
|
+
"attrib"=>true}}, @tester.klasses)
|
493
|
+
@tester.klasses= {"whoopie" => {}}
|
494
|
+
assert_equal({"whoopie"=> {}}, @tester.klasses)
|
495
|
+
end
|
496
|
+
|
497
|
+
# REFACTOR: this should probably be cleaned up and on ZenTest side
|
498
|
+
def util_testcase(*klasses)
|
499
|
+
zentest = ZenTest.new
|
500
|
+
klasses.each do |klass|
|
501
|
+
zentest.process_class(klass)
|
502
|
+
end
|
503
|
+
zentest.analyze
|
504
|
+
zentest.generate_code
|
505
|
+
return zentest.result.split("\n")[1..-1].join("\n")
|
506
|
+
end
|
507
|
+
|
508
|
+
def test_testcase0
|
509
|
+
expected = '# Number of errors detected: 0'
|
510
|
+
assert_equal expected, util_testcase("Blah0", "TestBlah0")
|
511
|
+
end
|
512
|
+
|
513
|
+
def test_testcase1
|
514
|
+
expected = "\nrequire 'test/unit' unless defined? $ZENTEST and $ZENTEST\n\nclass Blah1\n def missingimpl(*args)\n raise NotImplementedError, 'Need to write missingimpl'\n end\nend\n\nclass TestBlah1 < Test::Unit::TestCase\n def test_missingtest\n raise NotImplementedError, 'Need to write test_missingtest'\n end\nend\n\n# Number of errors detected: 2"
|
515
|
+
|
516
|
+
assert_equal expected, util_testcase("Blah1", "TestBlah1")
|
517
|
+
end
|
518
|
+
|
519
|
+
def test_testcase2
|
520
|
+
expected = "\nrequire 'test/unit' unless defined? $ZENTEST and $ZENTEST\n\nmodule Something2\n class Blah2\n def missingimpl(*args)\n raise NotImplementedError, 'Need to write missingimpl'\n end\n end\nend\n\nmodule TestSomething2\n class TestBlah2 < Test::Unit::TestCase\n def test_missingtest\n raise NotImplementedError, 'Need to write test_missingtest'\n end\n end\nend\n\n# Number of errors detected: 2"
|
521
|
+
|
522
|
+
assert_equal expected, util_testcase("Something2::Blah2", "TestSomething2::TestBlah2")
|
523
|
+
end
|
524
|
+
|
525
|
+
def test_testcase3
|
526
|
+
expected = "\nrequire 'test/unit' unless defined? $ZENTEST and $ZENTEST\n\nclass Blah3\n def missingimpl(*args)\n raise NotImplementedError, 'Need to write missingimpl'\n end\nend\n\n# Number of errors detected: 1"
|
527
|
+
|
528
|
+
assert_equal expected, util_testcase("TestBlah3")
|
529
|
+
end
|
530
|
+
|
531
|
+
def test_testcase4
|
532
|
+
expected = "\nrequire 'test/unit' unless defined? $ZENTEST and $ZENTEST\n\nclass TestBlah4 < Test::Unit::TestCase\n def test_missingtest1\n raise NotImplementedError, 'Need to write test_missingtest1'\n end\n\n def test_missingtest2\n raise NotImplementedError, 'Need to write test_missingtest2'\n end\nend\n\n# Number of errors detected: 3"
|
533
|
+
|
534
|
+
assert_equal expected, util_testcase("Blah4")
|
535
|
+
end
|
536
|
+
|
537
|
+
def test_testcase5
|
538
|
+
expected = "\nrequire 'test/unit' unless defined? $ZENTEST and $ZENTEST\n\nclass TestMyHash5 < Test::Unit::TestCase\n def test_index\n raise NotImplementedError, 'Need to write test_index'\n end\n\n def test_missingtest1\n raise NotImplementedError, 'Need to write test_missingtest1'\n end\nend\n\n# Number of errors detected: 3"
|
539
|
+
|
540
|
+
assert_equal expected, util_testcase("MyHash5")
|
541
|
+
end
|
542
|
+
|
543
|
+
def test_testcase6
|
544
|
+
expected = "\nrequire 'test/unit' unless defined? $ZENTEST and $ZENTEST\n\nmodule TestMyModule6\n class TestMyClass6 < Test::Unit::TestCase\n def test_index\n raise NotImplementedError, 'Need to write test_index'\n end\n\n def test_missingtest1\n raise NotImplementedError, 'Need to write test_missingtest1'\n end\n end\nend\n\n# Number of errors detected: 3"
|
545
|
+
|
546
|
+
assert_equal expected, util_testcase("MyModule6::MyClass6")
|
547
|
+
end
|
548
|
+
|
549
|
+
def test_testcase7
|
550
|
+
expected = "\nrequire 'test/unit' unless defined? $ZENTEST and $ZENTEST\n\nmodule TestMyModule7\n class TestMyClass7 < Test::Unit::TestCase\n def test_index\n raise NotImplementedError, 'Need to write test_index'\n end\n\n def test_missingtest1\n raise NotImplementedError, 'Need to write test_missingtest1'\n end\n end\nend\n\n# Number of errors detected: 3"
|
551
|
+
|
552
|
+
assert_equal expected, util_testcase("MyModule7::MyClass7")
|
553
|
+
end
|
554
|
+
|
555
|
+
def test_testcase8
|
556
|
+
expected = "\nrequire 'test/unit' unless defined? $ZENTEST and $ZENTEST\n\nclass TestMyClass8 < Test::Unit::TestCase\n def test_class_foobar\n raise NotImplementedError, 'Need to write test_class_foobar'\n end\n\n def test_class_foobaz\n raise NotImplementedError, 'Need to write test_class_foobaz'\n end\nend\n\n# Number of errors detected: 3"
|
557
|
+
|
558
|
+
assert_equal expected, util_testcase("MyClass8")
|
559
|
+
end
|
560
|
+
|
561
|
+
def test_testcase9
|
562
|
+
expected = "\nrequire 'test/unit' unless defined? $ZENTEST and $ZENTEST\n\nclass TestTrueClass < Test::Unit::TestCase\n def test_and\n raise NotImplementedError, 'Need to write test_and'\n end\n\n def test_carat\n raise NotImplementedError, 'Need to write test_carat'\n end\n\n def test_or\n raise NotImplementedError, 'Need to write test_or'\n end\n\n def test_to_s\n raise NotImplementedError, 'Need to write test_to_s'\n end\nend\n\n# Number of errors detected: 4"
|
563
|
+
|
564
|
+
assert_equal expected, util_testcase("TestTrueClass")
|
565
|
+
end
|
566
|
+
end
|