rroonga 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.ja.rdoc +46 -0
- data/NEWS.rdoc +46 -0
- data/README.ja.rdoc +2 -2
- data/README.rdoc +2 -3
- data/Rakefile +148 -11
- data/example/bookmark.rb +94 -91
- data/ext/groonga/extconf.rb +25 -25
- data/ext/groonga/groonga.def +2 -0
- data/ext/groonga/mkmf.log +7 -7
- data/ext/groonga/rb-grn-column.c +66 -0
- data/ext/groonga/rb-grn-context.c +92 -5
- data/ext/groonga/rb-grn-database.c +24 -1
- data/ext/groonga/rb-grn-exception.c +15 -0
- data/ext/groonga/rb-grn-hash.c +2 -2
- data/ext/groonga/rb-grn-index-column.c +8 -4
- data/ext/groonga/rb-grn-object.c +4 -2
- data/ext/groonga/rb-grn-patricia-trie.c +2 -2
- data/ext/groonga/rb-grn-snippet.c +1 -0
- data/ext/groonga/rb-grn-table-key-support.c +22 -19
- data/ext/groonga/rb-grn-table.c +63 -5
- data/ext/groonga/rb-grn.h +1 -1
- data/ext/groonga/rb-groonga.c +1 -0
- data/extconf.rb +1 -1
- data/html/developer.html +8 -2
- data/html/favicon.ico +0 -0
- data/html/favicon.svg +591 -0
- data/html/index.html +71 -8
- data/html/logo.svg +612 -0
- data/html/ranguba.css +92 -7
- data/html/readme.svg +256 -0
- data/lib/groonga/expression-builder.rb +8 -4
- data/lib/groonga/record.rb +77 -7
- data/lib/groonga/schema.rb +429 -100
- data/rroonga-build.rb +1 -1
- data/test/run-test.rb +1 -1
- data/test/test-array.rb +4 -0
- data/test/test-context.rb +8 -0
- data/test/test-database.rb +8 -1
- data/test/test-expression-builder.rb +14 -0
- data/test/test-fix-size-column.rb +4 -0
- data/test/test-hash.rb +10 -4
- data/test/test-index-column.rb +11 -0
- data/test/test-patricia-trie.rb +7 -1
- data/test/test-record.rb +14 -0
- data/test/test-remote.rb +3 -2
- data/test/test-schema-create-table.rb +32 -2
- data/test/test-schema.rb +108 -11
- data/test/test-table-select-normalize.rb +7 -3
- data/test/test-table-select.rb +12 -0
- data/test/test-table.rb +7 -0
- data/test/test-variable-size-column.rb +4 -0
- data/test-unit/Rakefile +40 -0
- data/test-unit/TODO +5 -0
- data/test-unit/bin/testrb +5 -0
- data/test-unit/html/classic.html +15 -0
- data/test-unit/html/index.html +25 -0
- data/test-unit/html/index.html.ja +27 -0
- data/test-unit/lib/test/unit/assertionfailederror.rb +25 -0
- data/test-unit/lib/test/unit/assertions.rb +1230 -0
- data/test-unit/lib/test/unit/attribute.rb +125 -0
- data/test-unit/lib/test/unit/autorunner.rb +360 -0
- data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
- data/test-unit/lib/test/unit/collector/dir.rb +108 -0
- data/test-unit/lib/test/unit/collector/load.rb +144 -0
- data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
- data/test-unit/lib/test/unit/collector.rb +36 -0
- data/test-unit/lib/test/unit/color-scheme.rb +102 -0
- data/test-unit/lib/test/unit/color.rb +96 -0
- data/test-unit/lib/test/unit/diff.rb +724 -0
- data/test-unit/lib/test/unit/error.rb +130 -0
- data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
- data/test-unit/lib/test/unit/failure.rb +136 -0
- data/test-unit/lib/test/unit/fixture.rb +176 -0
- data/test-unit/lib/test/unit/notification.rb +129 -0
- data/test-unit/lib/test/unit/omission.rb +191 -0
- data/test-unit/lib/test/unit/pending.rb +150 -0
- data/test-unit/lib/test/unit/priority.rb +180 -0
- data/test-unit/lib/test/unit/runner/console.rb +52 -0
- data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
- data/test-unit/lib/test/unit/runner/tap.rb +8 -0
- data/test-unit/lib/test/unit/testcase.rb +476 -0
- data/test-unit/lib/test/unit/testresult.rb +89 -0
- data/test-unit/lib/test/unit/testsuite.rb +110 -0
- data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +466 -0
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +63 -0
- data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +28 -0
- data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
- data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
- data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
- data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
- data/test-unit/lib/test/unit/util/observable.rb +90 -0
- data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
- data/test-unit/lib/test/unit/version.rb +7 -0
- data/test-unit/lib/test/unit.rb +323 -0
- data/test-unit/sample/adder.rb +13 -0
- data/test-unit/sample/subtracter.rb +12 -0
- data/test-unit/sample/test_adder.rb +20 -0
- data/test-unit/sample/test_subtracter.rb +20 -0
- data/test-unit/sample/test_user.rb +23 -0
- data/test-unit/test/collector/test-descendant.rb +133 -0
- data/test-unit/test/collector/test-load.rb +442 -0
- data/test-unit/test/collector/test_dir.rb +406 -0
- data/test-unit/test/collector/test_objectspace.rb +100 -0
- data/test-unit/test/run-test.rb +15 -0
- data/test-unit/test/test-attribute.rb +86 -0
- data/test-unit/test/test-color-scheme.rb +67 -0
- data/test-unit/test/test-color.rb +47 -0
- data/test-unit/test/test-diff.rb +518 -0
- data/test-unit/test/test-emacs-runner.rb +60 -0
- data/test-unit/test/test-fixture.rb +287 -0
- data/test-unit/test/test-notification.rb +33 -0
- data/test-unit/test/test-omission.rb +81 -0
- data/test-unit/test/test-pending.rb +70 -0
- data/test-unit/test/test-priority.rb +119 -0
- data/test-unit/test/test-testcase.rb +544 -0
- data/test-unit/test/test_assertions.rb +1151 -0
- data/test-unit/test/test_error.rb +26 -0
- data/test-unit/test/test_failure.rb +33 -0
- data/test-unit/test/test_testresult.rb +113 -0
- data/test-unit/test/test_testsuite.rb +129 -0
- data/test-unit/test/testunit-test-util.rb +14 -0
- data/test-unit/test/ui/test_testrunmediator.rb +20 -0
- data/test-unit/test/util/test-method-owner-finder.rb +38 -0
- data/test-unit/test/util/test_backtracefilter.rb +41 -0
- data/test-unit/test/util/test_observable.rb +102 -0
- data/test-unit/test/util/test_procwrapper.rb +36 -0
- data/text/{TUTORIAL.ja.rdoc → tutorial.ja.rdoc} +165 -126
- metadata +106 -16
- data/html/favicon.xcf +0 -0
- data/html/logo.xcf +0 -0
- data/license/GPL +0 -340
- data/license/RUBY +0 -59
- data/pkg-config.rb +0 -333
@@ -0,0 +1,287 @@
|
|
1
|
+
class TestUnitFixture < Test::Unit::TestCase
|
2
|
+
module EmptyModule
|
3
|
+
end
|
4
|
+
|
5
|
+
def test_setup_without_option
|
6
|
+
expected_setup_calls = [:setup,
|
7
|
+
:custom_setup_method0,
|
8
|
+
:custom_setup_method1,
|
9
|
+
:custom_setup_method3]
|
10
|
+
test_case = assert_setup(expected_setup_calls, [])
|
11
|
+
assert_inherited_setup(expected_setup_calls, test_case)
|
12
|
+
|
13
|
+
assert_inherited_setup([:setup], nil)
|
14
|
+
assert_called_fixtures(expected_setup_calls, test_case)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_setup_with_before_option
|
18
|
+
expected_setup_calls = [:custom_setup_method3,
|
19
|
+
:custom_setup_method0,
|
20
|
+
:custom_setup_method1,
|
21
|
+
:setup]
|
22
|
+
test_case = assert_setup(expected_setup_calls,
|
23
|
+
[[{:before => :append}],
|
24
|
+
[{:before => :append}],
|
25
|
+
[{:before => :prepend}],
|
26
|
+
[{:before => :prepend}]])
|
27
|
+
assert_inherited_setup(expected_setup_calls, test_case)
|
28
|
+
|
29
|
+
assert_inherited_setup([:setup], nil)
|
30
|
+
assert_called_fixtures(expected_setup_calls, test_case)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_setup_with_after_option
|
34
|
+
expected_setup_calls = [:setup,
|
35
|
+
:custom_setup_method3,
|
36
|
+
:custom_setup_method0,
|
37
|
+
:custom_setup_method1]
|
38
|
+
test_case = assert_setup(expected_setup_calls,
|
39
|
+
[[{:after => :append}],
|
40
|
+
[{:after => :append}],
|
41
|
+
[{:after => :prepend}],
|
42
|
+
[{:after => :prepend}]])
|
43
|
+
assert_inherited_setup(expected_setup_calls, test_case)
|
44
|
+
|
45
|
+
assert_inherited_setup([:setup], nil)
|
46
|
+
assert_called_fixtures(expected_setup_calls, test_case)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_setup_with_invalid_option
|
50
|
+
assert_invalid_setup_option(:unknown => true)
|
51
|
+
assert_invalid_setup_option(:before => :unknown)
|
52
|
+
assert_invalid_setup_option(:after => :unknown)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_setup_with_option_to_inherited
|
56
|
+
expected_setup_calls = [:setup]
|
57
|
+
test_case = assert_setup(expected_setup_calls, nil)
|
58
|
+
assert_inherited_setup([:setup,
|
59
|
+
:custom_setup_method0,
|
60
|
+
:custom_setup_method1,
|
61
|
+
:custom_setup_method3],
|
62
|
+
test_case,
|
63
|
+
[])
|
64
|
+
|
65
|
+
assert_inherited_setup([:setup], nil)
|
66
|
+
assert_called_fixtures(expected_setup_calls, test_case)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_teardown_without_option
|
70
|
+
expected_teardown_calls = [:custom_teardown_method3,
|
71
|
+
:custom_teardown_method1,
|
72
|
+
:custom_teardown_method0,
|
73
|
+
:teardown]
|
74
|
+
test_case = assert_teardown(expected_teardown_calls, [])
|
75
|
+
assert_inherited_teardown(expected_teardown_calls, test_case)
|
76
|
+
|
77
|
+
assert_inherited_teardown([:teardown], nil)
|
78
|
+
assert_called_fixtures(expected_teardown_calls, test_case)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_teardown_with_before_option
|
82
|
+
expected_teardown_calls = [:custom_teardown_method3,
|
83
|
+
:custom_teardown_method0,
|
84
|
+
:custom_teardown_method1,
|
85
|
+
:teardown]
|
86
|
+
test_case = assert_teardown(expected_teardown_calls,
|
87
|
+
[[{:before => :append}],
|
88
|
+
[{:before => :append}],
|
89
|
+
[{:before => :prepend}],
|
90
|
+
[{:before => :prepend}]])
|
91
|
+
assert_inherited_teardown(expected_teardown_calls, test_case)
|
92
|
+
|
93
|
+
assert_inherited_teardown([:teardown], nil)
|
94
|
+
assert_called_fixtures(expected_teardown_calls, test_case)
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_teardown_with_after_option
|
98
|
+
expected_teardown_calls = [:teardown,
|
99
|
+
:custom_teardown_method3,
|
100
|
+
:custom_teardown_method0,
|
101
|
+
:custom_teardown_method1]
|
102
|
+
test_case = assert_teardown(expected_teardown_calls,
|
103
|
+
[[{:after => :append}],
|
104
|
+
[{:after => :append}],
|
105
|
+
[{:after => :prepend}],
|
106
|
+
[{:after => :prepend}]])
|
107
|
+
assert_inherited_teardown(expected_teardown_calls, test_case)
|
108
|
+
|
109
|
+
assert_inherited_teardown([:teardown], nil)
|
110
|
+
assert_called_fixtures(expected_teardown_calls, test_case)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_teardown_with_invalid_option
|
114
|
+
assert_invalid_teardown_option(:unknown => true)
|
115
|
+
assert_invalid_teardown_option(:before => :unknown)
|
116
|
+
assert_invalid_teardown_option(:after => :unknown)
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_teardown_with_option_to_inherited
|
120
|
+
expected_teardown_calls = [:teardown]
|
121
|
+
test_case = assert_teardown(expected_teardown_calls, nil)
|
122
|
+
assert_inherited_teardown([:custom_teardown_method3,
|
123
|
+
:custom_teardown_method1,
|
124
|
+
:custom_teardown_method0,
|
125
|
+
:teardown],
|
126
|
+
test_case, [])
|
127
|
+
|
128
|
+
assert_inherited_teardown([:teardown], nil)
|
129
|
+
assert_called_fixtures(expected_teardown_calls, test_case)
|
130
|
+
end
|
131
|
+
|
132
|
+
private
|
133
|
+
def assert_called_fixtures(expected, test_case)
|
134
|
+
test = test_case.new("test_nothing")
|
135
|
+
test.run(Test::Unit::TestResult.new) {}
|
136
|
+
assert_equal(expected, test.called_ids)
|
137
|
+
end
|
138
|
+
|
139
|
+
def assert_setup_customizable(expected, parent, options)
|
140
|
+
test_case = Class.new(parent || Test::Unit::TestCase) do
|
141
|
+
yield(self, :before) if block_given?
|
142
|
+
|
143
|
+
def called_ids
|
144
|
+
@called_ids ||= []
|
145
|
+
end
|
146
|
+
|
147
|
+
def called(id)
|
148
|
+
called_ids << id
|
149
|
+
end
|
150
|
+
|
151
|
+
def setup
|
152
|
+
called(:setup)
|
153
|
+
end
|
154
|
+
|
155
|
+
setup(*(options[0] || [])) if options
|
156
|
+
def custom_setup_method0
|
157
|
+
called(:custom_setup_method0)
|
158
|
+
end
|
159
|
+
|
160
|
+
def custom_setup_method1
|
161
|
+
called(:custom_setup_method1)
|
162
|
+
end
|
163
|
+
setup(*[:custom_setup_method1, *(options[1] || [])]) if options
|
164
|
+
|
165
|
+
setup(*(options[2] || [])) if options
|
166
|
+
def custom_setup_method2
|
167
|
+
called(:custom_setup_method2)
|
168
|
+
end
|
169
|
+
unregister_setup(:custom_setup_method2) if options
|
170
|
+
|
171
|
+
setup(*(options[3] || [])) if options
|
172
|
+
def custom_setup_method3
|
173
|
+
called(:custom_setup_method3)
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_nothing
|
177
|
+
end
|
178
|
+
|
179
|
+
yield(self, :after) if block_given?
|
180
|
+
end
|
181
|
+
|
182
|
+
assert_called_fixtures(expected, test_case)
|
183
|
+
test_case
|
184
|
+
end
|
185
|
+
|
186
|
+
def assert_setup(expected, options)
|
187
|
+
_test_case = assert_setup_customizable(expected, nil, options)
|
188
|
+
assert_setup_customizable(expected, nil, options) do |test_case, tag|
|
189
|
+
test_case.send(:include, EmptyModule) if tag == :before
|
190
|
+
end
|
191
|
+
_test_case
|
192
|
+
end
|
193
|
+
|
194
|
+
def assert_inherited_setup(expected, parent, options=nil)
|
195
|
+
_test_case = assert_setup_customizable(expected, parent, options)
|
196
|
+
assert_setup_customizable(expected, parent, options) do |test_case, tag|
|
197
|
+
test_case.send(:include, EmptyModule) if tag == :before
|
198
|
+
end
|
199
|
+
_test_case
|
200
|
+
end
|
201
|
+
|
202
|
+
def assert_teardown_customizable(expected, parent, options)
|
203
|
+
test_case = Class.new(parent || Test::Unit::TestCase) do
|
204
|
+
yield(self, :before) if block_given?
|
205
|
+
|
206
|
+
def called_ids
|
207
|
+
@called_ids ||= []
|
208
|
+
end
|
209
|
+
|
210
|
+
def called(id)
|
211
|
+
called_ids << id
|
212
|
+
end
|
213
|
+
|
214
|
+
def teardown
|
215
|
+
called(:teardown)
|
216
|
+
end
|
217
|
+
|
218
|
+
teardown(*(options[0] || [])) if options
|
219
|
+
def custom_teardown_method0
|
220
|
+
called(:custom_teardown_method0)
|
221
|
+
end
|
222
|
+
|
223
|
+
def custom_teardown_method1
|
224
|
+
called(:custom_teardown_method1)
|
225
|
+
end
|
226
|
+
teardown(*[:custom_teardown_method1, *(options[1] || [])]) if options
|
227
|
+
|
228
|
+
teardown(*(options[2] || [])) if options
|
229
|
+
def custom_teardown_method2
|
230
|
+
called(:custom_teardown_method2)
|
231
|
+
end
|
232
|
+
unregister_teardown(:custom_teardown_method2) if options
|
233
|
+
|
234
|
+
teardown(*(options[3] || [])) if options
|
235
|
+
def custom_teardown_method3
|
236
|
+
called(:custom_teardown_method3)
|
237
|
+
end
|
238
|
+
|
239
|
+
def test_nothing
|
240
|
+
end
|
241
|
+
|
242
|
+
yield(self, :after) if block_given?
|
243
|
+
end
|
244
|
+
|
245
|
+
assert_called_fixtures(expected, test_case)
|
246
|
+
test_case
|
247
|
+
end
|
248
|
+
|
249
|
+
def assert_teardown(expected, options)
|
250
|
+
assert_teardown_customizable(expected, nil, options)
|
251
|
+
assert_teardown_customizable(expected, nil, options) do |test_case, tag|
|
252
|
+
test_case.send(:include, EmptyModule) if tag == :before
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def assert_inherited_teardown(expected, parent, options=nil)
|
257
|
+
assert_teardown_customizable(expected, parent, options)
|
258
|
+
assert_teardown_customizable(expected, parent, options) do |test_case, tag|
|
259
|
+
test_case.send(:include, EmptyModule) if tag == :before
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def assert_invalid_option(fixture_type, option)
|
264
|
+
exception = assert_raise(ArgumentError) do
|
265
|
+
Class.new(Test::Unit::TestCase) do
|
266
|
+
def test_nothing
|
267
|
+
end
|
268
|
+
|
269
|
+
send(fixture_type, option)
|
270
|
+
def fixture
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
assert_equal("must be {:before => :prepend}, {:before => :append}, " +
|
275
|
+
"{:after => :prepend} or {:after => :append}" +
|
276
|
+
": #{option.inspect}",
|
277
|
+
exception.message)
|
278
|
+
end
|
279
|
+
|
280
|
+
def assert_invalid_setup_option(option)
|
281
|
+
assert_invalid_option(:setup, option)
|
282
|
+
end
|
283
|
+
|
284
|
+
def assert_invalid_teardown_option(option)
|
285
|
+
assert_invalid_option(:teardown, option)
|
286
|
+
end
|
287
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'testunit-test-util'
|
3
|
+
|
4
|
+
class TestUnitNotification < Test::Unit::TestCase
|
5
|
+
include TestUnitTestUtil
|
6
|
+
|
7
|
+
class TestCase < Test::Unit::TestCase
|
8
|
+
class << self
|
9
|
+
def suite
|
10
|
+
Test::Unit::TestSuite.new(name)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_notify
|
15
|
+
notify("1st notify")
|
16
|
+
notify("2nd notify. Reach here.")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_notify
|
21
|
+
result = _run_test("test_notify")
|
22
|
+
assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
|
23
|
+
"0 omissions, 2 notifications",
|
24
|
+
result.to_s)
|
25
|
+
assert_fault_messages(["1st notify", "2nd notify. Reach here."],
|
26
|
+
result.notifications)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def _run_test(name)
|
31
|
+
super(TestCase, name)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'testunit-test-util'
|
3
|
+
|
4
|
+
class TestUnitOmission < Test::Unit::TestCase
|
5
|
+
include TestUnitTestUtil
|
6
|
+
|
7
|
+
class TestCase < Test::Unit::TestCase
|
8
|
+
class << self
|
9
|
+
def suite
|
10
|
+
Test::Unit::TestSuite.new(name)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_omit
|
15
|
+
omit("1st omit")
|
16
|
+
omit("2nd omit. Should not be reached here.")
|
17
|
+
assert(true, "Should not be reached here too.")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_omit_with_condition
|
21
|
+
omit_if(false, "Never omit.")
|
22
|
+
omit_unless(true, "Never omit too.")
|
23
|
+
omit_if(true, "Should omit.")
|
24
|
+
omit("The last omit. Should not be reached here.")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_omit_with_block
|
28
|
+
omit("Omit block") do
|
29
|
+
flunk("Should not be reached here.")
|
30
|
+
end
|
31
|
+
assert(true, "Should be reached here.")
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_omit_with_block_and_condition
|
35
|
+
omit_if(false, "Never omit.") do
|
36
|
+
assert(true, "Should be reached here.")
|
37
|
+
end
|
38
|
+
omit_if(true, "Should omit.") do
|
39
|
+
flunk("Never reached here.")
|
40
|
+
end
|
41
|
+
assert(true, "Should be reached here too.")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_omit
|
46
|
+
result = _run_test("test_omit")
|
47
|
+
assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
|
48
|
+
"1 omissions, 0 notifications",
|
49
|
+
result.to_s)
|
50
|
+
assert_fault_messages(["1st omit"], result.omissions)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_omit_with_condition
|
54
|
+
result = _run_test("test_omit_with_condition")
|
55
|
+
assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, " \
|
56
|
+
"1 omissions, 0 notifications",
|
57
|
+
result.to_s)
|
58
|
+
assert_fault_messages(["Should omit."], result.omissions)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_omit_with_block
|
62
|
+
result = _run_test("test_omit_with_block")
|
63
|
+
assert_equal("1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, " \
|
64
|
+
"1 omissions, 0 notifications",
|
65
|
+
result.to_s)
|
66
|
+
assert_fault_messages(["Omit block"], result.omissions)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_omit_with_condition_and_block
|
70
|
+
result = _run_test("test_omit_with_block_and_condition")
|
71
|
+
assert_equal("1 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, " \
|
72
|
+
"1 omissions, 0 notifications",
|
73
|
+
result.to_s)
|
74
|
+
assert_fault_messages(["Should omit."], result.omissions)
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
def _run_test(name)
|
79
|
+
super(TestCase, name)
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'testunit-test-util'
|
3
|
+
|
4
|
+
class TestUnitPending < Test::Unit::TestCase
|
5
|
+
include TestUnitTestUtil
|
6
|
+
|
7
|
+
class TestCase < Test::Unit::TestCase
|
8
|
+
class << self
|
9
|
+
def suite
|
10
|
+
Test::Unit::TestSuite.new(name)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_pend
|
15
|
+
pend("1st pend")
|
16
|
+
pend("2nd pend. Should not be reached here.")
|
17
|
+
assert(true, "Should not be reached here too.")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_pend_with_failure_in_block
|
21
|
+
pend("Wait a minute") do
|
22
|
+
raise "Not implemented yet"
|
23
|
+
end
|
24
|
+
assert(true, "Reached here.")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_pend_with_no_failure_in_block
|
28
|
+
pend("Wait a minute") do
|
29
|
+
"Nothing raised"
|
30
|
+
end
|
31
|
+
assert(true, "Not reached here.")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_pend
|
36
|
+
test = nil
|
37
|
+
result = _run_test("test_pend") {|t| test = t}
|
38
|
+
assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 1 pendings, " \
|
39
|
+
"0 omissions, 0 notifications",
|
40
|
+
result.to_s)
|
41
|
+
assert_fault_messages(["1st pend"], result.pendings)
|
42
|
+
assert_true(test.interrupted?)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_pend_with_failure_in_block
|
46
|
+
test = nil
|
47
|
+
result = _run_test("test_pend_with_failure_in_block") {|t| test = t}
|
48
|
+
assert_equal("1 tests, 1 assertions, 0 failures, 0 errors, 1 pendings, " \
|
49
|
+
"0 omissions, 0 notifications",
|
50
|
+
result.to_s)
|
51
|
+
assert_fault_messages(["Wait a minute"], result.pendings)
|
52
|
+
assert_false(test.interrupted?)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_pend_with_no_failure_in_block
|
56
|
+
test = nil
|
57
|
+
result = _run_test("test_pend_with_no_failure_in_block") {|t| test = t}
|
58
|
+
assert_equal("1 tests, 1 assertions, 1 failures, 0 errors, 0 pendings, " \
|
59
|
+
"0 omissions, 0 notifications",
|
60
|
+
result.to_s)
|
61
|
+
assert_fault_messages(["Pending block should not be passed: Wait a minute."],
|
62
|
+
result.failures)
|
63
|
+
assert_true(test.interrupted?)
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
def _run_test(name, &block)
|
68
|
+
super(TestCase, name, &block)
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class TestUnitPriority < Test::Unit::TestCase
|
4
|
+
class TestCase < Test::Unit::TestCase
|
5
|
+
class << self
|
6
|
+
def suite
|
7
|
+
Test::Unit::TestSuite.new(name)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
priority :must
|
12
|
+
def test_must
|
13
|
+
assert(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_must_inherited
|
17
|
+
assert(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
priority :important
|
21
|
+
def test_important
|
22
|
+
assert(true)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_important_inherited
|
26
|
+
assert(true)
|
27
|
+
end
|
28
|
+
|
29
|
+
priority :high
|
30
|
+
def test_high
|
31
|
+
assert(true)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_high_inherited
|
35
|
+
assert(true)
|
36
|
+
end
|
37
|
+
|
38
|
+
priority :normal
|
39
|
+
def test_normal
|
40
|
+
assert(true)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_normal_inherited
|
44
|
+
assert(true)
|
45
|
+
end
|
46
|
+
|
47
|
+
priority :low
|
48
|
+
def test_low
|
49
|
+
assert(true)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_low_inherited
|
53
|
+
assert(true)
|
54
|
+
end
|
55
|
+
|
56
|
+
priority :never
|
57
|
+
def test_never
|
58
|
+
assert(true)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_never_inherited
|
62
|
+
assert(true)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_priority
|
67
|
+
assert_priority("must", 1.0, 0.0001)
|
68
|
+
assert_priority("important", 0.9, 0.09)
|
69
|
+
assert_priority("high", 0.70, 0.1)
|
70
|
+
assert_priority("normal", 0.5, 0.1)
|
71
|
+
assert_priority("low", 0.25, 0.1)
|
72
|
+
assert_priority("never", 0.0, 0.0001)
|
73
|
+
end
|
74
|
+
|
75
|
+
def assert_priority(priority, expected, delta)
|
76
|
+
assert_need_to_run("test_#{priority}", expected, delta)
|
77
|
+
assert_need_to_run("test_#{priority}_inherited", expected, delta)
|
78
|
+
end
|
79
|
+
|
80
|
+
def assert_need_to_run(test_name, expected, delta)
|
81
|
+
test = TestCase.new(test_name)
|
82
|
+
n = 1000
|
83
|
+
n_need_to_run = 0
|
84
|
+
n.times do |i|
|
85
|
+
n_need_to_run +=1 if Test::Unit::Priority::Checker.need_to_run?(test)
|
86
|
+
end
|
87
|
+
assert_in_delta(expected, n_need_to_run.to_f / n, delta)
|
88
|
+
end
|
89
|
+
|
90
|
+
class SpecialNameTestCase < Test::Unit::TestCase
|
91
|
+
class << self
|
92
|
+
def suite
|
93
|
+
Test::Unit::TestSuite.new(name)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_question?
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_exclamation!
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_equal=
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_escaped?
|
108
|
+
assert_escaped_name("test_question.predicate", "test_question?")
|
109
|
+
assert_escaped_name("test_exclamation.destructive", "test_exclamation!")
|
110
|
+
assert_escaped_name("test_equal.equal", "test_equal=")
|
111
|
+
end
|
112
|
+
|
113
|
+
def assert_escaped_name(expected, test_method_name)
|
114
|
+
checker = Checker.new(SpecialNameTestCase.new(test_method_name))
|
115
|
+
passed_file = checker.send(:passed_file)
|
116
|
+
method_name_component = File.basename(File.dirname(passed_file))
|
117
|
+
assert_equal(expected, method_name_component)
|
118
|
+
end
|
119
|
+
end
|