glib2 0.90.8 → 0.90.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/ChangeLog +44 -0
  2. data/Rakefile +1 -0
  3. data/ext/glib2/rbglib.h +1 -1
  4. data/ext/glib2/rbglib_iochannel.c +15 -6
  5. data/ext/glib2/rbgobj_signal.c +1 -1
  6. data/ext/glib2/rbgobject.h +1 -1
  7. data/lib/gnome2-raketask.rb +4 -2
  8. data/lib/mkmf-gnome2.rb +47 -23
  9. data/test/glib-test-init.rb +1 -3
  10. metadata +20 -121
  11. data/test-unit/COPYING +0 -56
  12. data/test-unit/GPL +0 -340
  13. data/test-unit/History.txt +0 -279
  14. data/test-unit/Manifest.txt +0 -110
  15. data/test-unit/PSFL +0 -271
  16. data/test-unit/README.txt +0 -75
  17. data/test-unit/Rakefile +0 -53
  18. data/test-unit/TODO +0 -5
  19. data/test-unit/bin/testrb +0 -5
  20. data/test-unit/html/bar.png +0 -0
  21. data/test-unit/html/bar.svg +0 -153
  22. data/test-unit/html/developer.png +0 -0
  23. data/test-unit/html/developer.svg +0 -469
  24. data/test-unit/html/famfamfam-logo.png +0 -0
  25. data/test-unit/html/favicon.ico +0 -0
  26. data/test-unit/html/favicon.png +0 -0
  27. data/test-unit/html/favicon.svg +0 -82
  28. data/test-unit/html/heading-mark.png +0 -0
  29. data/test-unit/html/heading-mark.svg +0 -393
  30. data/test-unit/html/index.html +0 -285
  31. data/test-unit/html/index.html.ja +0 -299
  32. data/test-unit/html/install.png +0 -0
  33. data/test-unit/html/install.svg +0 -636
  34. data/test-unit/html/jp.png +0 -0
  35. data/test-unit/html/kinotan-failure.png +0 -0
  36. data/test-unit/html/kinotan-pass.png +0 -0
  37. data/test-unit/html/logo.png +0 -0
  38. data/test-unit/html/logo.svg +0 -483
  39. data/test-unit/html/reference.png +0 -0
  40. data/test-unit/html/rubyforge.png +0 -0
  41. data/test-unit/html/tango-logo.png +0 -0
  42. data/test-unit/html/test-unit.css +0 -339
  43. data/test-unit/html/tutorial.png +0 -0
  44. data/test-unit/html/tutorial.svg +0 -559
  45. data/test-unit/html/us.png +0 -0
  46. data/test-unit/images/color-diff.png +0 -0
  47. data/test-unit/lib/test/unit.rb +0 -328
  48. data/test-unit/lib/test/unit/assertionfailederror.rb +0 -25
  49. data/test-unit/lib/test/unit/assertions.rb +0 -1792
  50. data/test-unit/lib/test/unit/attribute.rb +0 -125
  51. data/test-unit/lib/test/unit/autorunner.rb +0 -415
  52. data/test-unit/lib/test/unit/collector.rb +0 -38
  53. data/test-unit/lib/test/unit/collector/descendant.rb +0 -23
  54. data/test-unit/lib/test/unit/collector/dir.rb +0 -108
  55. data/test-unit/lib/test/unit/collector/load.rb +0 -187
  56. data/test-unit/lib/test/unit/collector/objectspace.rb +0 -34
  57. data/test-unit/lib/test/unit/collector/xml.rb +0 -250
  58. data/test-unit/lib/test/unit/color-scheme.rb +0 -106
  59. data/test-unit/lib/test/unit/color.rb +0 -96
  60. data/test-unit/lib/test/unit/diff.rb +0 -740
  61. data/test-unit/lib/test/unit/error.rb +0 -131
  62. data/test-unit/lib/test/unit/exceptionhandler.rb +0 -39
  63. data/test-unit/lib/test/unit/failure.rb +0 -136
  64. data/test-unit/lib/test/unit/fixture.rb +0 -185
  65. data/test-unit/lib/test/unit/notification.rb +0 -129
  66. data/test-unit/lib/test/unit/omission.rb +0 -191
  67. data/test-unit/lib/test/unit/pending.rb +0 -150
  68. data/test-unit/lib/test/unit/priority.rb +0 -180
  69. data/test-unit/lib/test/unit/runner/console.rb +0 -52
  70. data/test-unit/lib/test/unit/runner/emacs.rb +0 -8
  71. data/test-unit/lib/test/unit/runner/tap.rb +0 -8
  72. data/test-unit/lib/test/unit/runner/xml.rb +0 -15
  73. data/test-unit/lib/test/unit/testcase.rb +0 -515
  74. data/test-unit/lib/test/unit/testresult.rb +0 -125
  75. data/test-unit/lib/test/unit/testsuite.rb +0 -134
  76. data/test-unit/lib/test/unit/ui/console/outputlevel.rb +0 -14
  77. data/test-unit/lib/test/unit/ui/console/testrunner.rb +0 -467
  78. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +0 -63
  79. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +0 -82
  80. data/test-unit/lib/test/unit/ui/testrunner.rb +0 -53
  81. data/test-unit/lib/test/unit/ui/testrunnermediator.rb +0 -86
  82. data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +0 -41
  83. data/test-unit/lib/test/unit/ui/xml/testrunner.rb +0 -224
  84. data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -42
  85. data/test-unit/lib/test/unit/util/method-owner-finder.rb +0 -28
  86. data/test-unit/lib/test/unit/util/observable.rb +0 -90
  87. data/test-unit/lib/test/unit/util/output.rb +0 -31
  88. data/test-unit/lib/test/unit/util/procwrapper.rb +0 -48
  89. data/test-unit/lib/test/unit/version.rb +0 -7
  90. data/test-unit/sample/adder.rb +0 -13
  91. data/test-unit/sample/subtracter.rb +0 -12
  92. data/test-unit/sample/test_adder.rb +0 -20
  93. data/test-unit/sample/test_subtracter.rb +0 -20
  94. data/test-unit/sample/test_user.rb +0 -23
  95. data/test-unit/test/collector/test-descendant.rb +0 -133
  96. data/test-unit/test/collector/test-load.rb +0 -442
  97. data/test-unit/test/collector/test_dir.rb +0 -406
  98. data/test-unit/test/collector/test_objectspace.rb +0 -100
  99. data/test-unit/test/run-test.rb +0 -22
  100. data/test-unit/test/test-assertions.rb +0 -1849
  101. data/test-unit/test/test-attribute.rb +0 -86
  102. data/test-unit/test/test-color-scheme.rb +0 -69
  103. data/test-unit/test/test-color.rb +0 -47
  104. data/test-unit/test/test-diff.rb +0 -518
  105. data/test-unit/test/test-emacs-runner.rb +0 -60
  106. data/test-unit/test/test-fixture.rb +0 -324
  107. data/test-unit/test/test-notification.rb +0 -33
  108. data/test-unit/test/test-omission.rb +0 -81
  109. data/test-unit/test/test-pending.rb +0 -70
  110. data/test-unit/test/test-priority.rb +0 -119
  111. data/test-unit/test/test-testcase.rb +0 -569
  112. data/test-unit/test/test_error.rb +0 -26
  113. data/test-unit/test/test_failure.rb +0 -33
  114. data/test-unit/test/test_testresult.rb +0 -113
  115. data/test-unit/test/test_testsuite.rb +0 -137
  116. data/test-unit/test/testunit-test-util.rb +0 -14
  117. data/test-unit/test/ui/test_tap.rb +0 -33
  118. data/test-unit/test/ui/test_testrunmediator.rb +0 -20
  119. data/test-unit/test/util/test-method-owner-finder.rb +0 -38
  120. data/test-unit/test/util/test-output.rb +0 -11
  121. data/test-unit/test/util/test_backtracefilter.rb +0 -41
  122. data/test-unit/test/util/test_observable.rb +0 -102
  123. data/test-unit/test/util/test_procwrapper.rb +0 -36
@@ -1,70 +0,0 @@
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
@@ -1,119 +0,0 @@
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
@@ -1,569 +0,0 @@
1
- # Author:: Nathaniel Talbott.
2
- # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
3
- # License:: Ruby license.
4
-
5
- require 'test/unit'
6
-
7
- module Test
8
- module Unit
9
- class TestTestCase < TestCase
10
- self.test_order = :random
11
- def test_creation
12
- tc = Class.new(TestCase) do
13
- def test_with_arguments(arg1, arg2)
14
- end
15
- end
16
-
17
- caught = true
18
- catch(:invalid_test) do
19
- tc.new(:test_with_arguments)
20
- caught = false
21
- end
22
- check("Should have caught an invalid test when there are arguments", caught)
23
-
24
- caught = true
25
- catch(:invalid_test) do
26
- tc.new(:non_existent_test)
27
- caught = false
28
- end
29
- check("Should have caught an invalid test when the method does not exist", caught)
30
- end
31
-
32
- def setup
33
- @tc_failure_error = Class.new(TestCase) do
34
- def test_failure
35
- assert_block("failure") { false }
36
- end
37
- def test_error
38
- 1 / 0
39
- end
40
- def test_nested_failure
41
- nested
42
- end
43
- def nested
44
- assert_block("nested"){false}
45
- end
46
- def return_passed?
47
- return passed?
48
- end
49
- end
50
-
51
- def @tc_failure_error.name
52
- "TC_FailureError"
53
- end
54
- end
55
-
56
- def test_add_failed_assertion
57
- test_case = @tc_failure_error.new(:test_failure)
58
- check("passed? should start out true", test_case.return_passed?)
59
- result = TestResult.new
60
- called = false
61
- result.add_listener(TestResult::FAULT) {
62
- | fault |
63
- check("Should have a Failure", fault.instance_of?(Failure))
64
- check("The Failure should have the correct message", "failure" == fault.message)
65
- check("The Failure should have the correct test_name (was <#{fault.test_name}>)", fault.test_name == "test_failure(TC_FailureError)")
66
- r = /\A.*#{Regexp.escape(File.basename(__FILE__))}:\d+:in `test_failure'\Z/
67
-
68
- location = fault.location
69
- check("The location should be an array", location.kind_of?(Array))
70
- check("The location should have two lines (was: <#{location.inspect}>)", location.size == 2)
71
- check("The Failure should have the correct location (was <#{location[0].inspect}>, expected <#{r.inspect}>)", r =~ location[0])
72
- called = true
73
- }
74
- progress = []
75
- test_case.run(result) { |*arguments| progress << arguments }
76
- check("The failure should have triggered the listener", called)
77
- check("The failure should have set passed?", !test_case.return_passed?)
78
- check("The progress block should have been updated correctly",
79
- [[TestCase::STARTED, test_case.name],
80
- [TestCase::STARTED_OBJECT, test_case],
81
- [TestCase::FINISHED, test_case.name],
82
- [TestCase::FINISHED_OBJECT, test_case]] == progress)
83
- end
84
-
85
- def test_add_failure_nested
86
- test_case = @tc_failure_error.new(:test_nested_failure)
87
- check("passed? should start out true", test_case.return_passed?)
88
-
89
- result = TestResult.new
90
- called = false
91
- result.add_listener(TestResult::FAULT) {
92
- | fault |
93
- check("Should have a Failure", fault.instance_of?(Failure))
94
- check("The Failure should have the correct message", "nested" == fault.message)
95
- check("The Failure should have the correct test_name (was <#{fault.test_name}>)", fault.test_name == "test_nested_failure(TC_FailureError)")
96
- r =
97
-
98
- location = fault.location
99
- check("The location should be an array", location.kind_of?(Array))
100
- check("The location should have the correct number of lines (was: <#{location.inspect}>)", location.size == 3)
101
- check("The Failure should have the correct location (was <#{location[0].inspect}>)", /\A.*#{Regexp.escape(File.basename(__FILE__))}:\d+:in `nested'\Z/ =~ location[0])
102
- check("The Failure should have the correct location (was <#{location[1].inspect}>)", /\A.*#{Regexp.escape(File.basename(__FILE__))}:\d+:in `test_nested_failure'\Z/ =~ location[1])
103
- called = true
104
- }
105
- test_case.run(result){}
106
- check("The failure should have triggered the listener", called)
107
- end
108
-
109
- def test_add_error
110
- test_case = @tc_failure_error.new(:test_error)
111
- check("passed? should start out true", test_case.return_passed?)
112
- result = TestResult.new
113
- called = false
114
- result.add_listener(TestResult::FAULT) {
115
- | fault |
116
- check("Should have a TestError", fault.instance_of?(Error))
117
- check("The Error should have the correct message", "ZeroDivisionError: divided by 0" == fault.message)
118
- check("The Error should have the correct test_name", "test_error(TC_FailureError)" == fault.test_name)
119
- check("The Error should have the correct exception", fault.exception.instance_of?(ZeroDivisionError))
120
- called = true
121
- }
122
- test_case.run(result) {}
123
- check("The error should have triggered the listener", called)
124
- check("The error should have set passed?", !test_case.return_passed?)
125
- end
126
-
127
- def test_no_tests
128
- suite = TestCase.suite
129
- check("Should have a test suite", suite.instance_of?(TestSuite))
130
- check("Should have one test", suite.size == 1)
131
- check("Should have the default test", suite.tests.first.name == "default_test(Test::Unit::TestCase)")
132
-
133
- result = TestResult.new
134
- suite.run(result) {}
135
- check("Should have had one test run", result.run_count == 1)
136
- check("Should have had one test failure", result.failure_count == 1)
137
- check("Should have had no errors", result.error_count == 0)
138
- end
139
-
140
- def test_suite
141
- tc = Class.new(TestCase) do
142
- def test_succeed
143
- assert_block {true}
144
- end
145
- def test_fail
146
- assert_block {false}
147
- end
148
- def test_error
149
- 1/0
150
- end
151
- def dont_run
152
- assert_block {true}
153
- end
154
- def test_dont_run(argument)
155
- assert_block {true}
156
- end
157
- def test
158
- assert_block {true}
159
- end
160
- end
161
-
162
- suite = tc.suite
163
- check("Should have a test suite", suite.instance_of?(TestSuite))
164
- check("Should have three tests", suite.size == 3)
165
-
166
- result = TestResult.new
167
- suite.run(result) {}
168
- check("Should have had three test runs", result.run_count == 3)
169
- check("Should have had one test failure", result.failure_count == 1)
170
- check("Should have had one test error", result.error_count == 1)
171
- end
172
-
173
-
174
- def test_setup_teardown
175
- tc = Class.new(TestCase) do
176
- attr_reader(:setup_called, :teardown_called)
177
- def initialize(test)
178
- super(test)
179
- @setup_called = false
180
- @teardown_called = false
181
- end
182
- def setup
183
- @setup_called = true
184
- end
185
- def teardown
186
- @teardown_called = true
187
- end
188
- def test_succeed
189
- assert_block {true}
190
- end
191
- def test_fail
192
- assert_block {false}
193
- end
194
- def test_error
195
- raise "Error!"
196
- end
197
- end
198
- result = TestResult.new
199
-
200
- test = tc.new(:test_succeed)
201
- test.run(result) {}
202
- check("Should have called setup the correct number of times", test.setup_called)
203
- check("Should have called teardown the correct number of times", test.teardown_called)
204
-
205
- test = tc.new(:test_fail)
206
- test.run(result) {}
207
- check("Should have called setup the correct number of times", test.setup_called)
208
- check("Should have called teardown the correct number of times", test.teardown_called)
209
-
210
- test = tc.new(:test_error)
211
- test.run(result) {}
212
- check("Should have called setup the correct number of times", test.setup_called)
213
- check("Should have called teardown the correct number of times", test.teardown_called)
214
-
215
- check("Should have had two test runs", result.run_count == 3)
216
- check("Should have had a test failure", result.failure_count == 1)
217
- check("Should have had a test error", result.error_count == 1)
218
- end
219
-
220
- def test_assertion_failed_not_called
221
- tc = Class.new(TestCase) do
222
- def test_thing
223
- raise AssertionFailedError.new
224
- end
225
- end
226
-
227
- suite = tc.suite
228
- check("Should have one test", suite.size == 1)
229
- result = TestResult.new
230
- suite.run(result) {}
231
- check("Should have had one test run", result.run_count == 1)
232
- check("Should have had one assertion failure", result.failure_count == 1)
233
- check("Should not have any assertion errors but had #{result.error_count}", result.error_count == 0)
234
- end
235
-
236
- def test_equality
237
- tc1 = Class.new(TestCase) do
238
- def test_1
239
- end
240
- def test_2
241
- end
242
- end
243
-
244
- tc2 = Class.new(TestCase) do
245
- def test_1
246
- end
247
- end
248
-
249
- test1 = tc1.new('test_1')
250
- test2 = tc1.new('test_1')
251
- check("Should be equal", test1 == test2)
252
- check("Should be equal", test2 == test1)
253
-
254
- test1 = tc1.new('test_2')
255
- check("Should not be equal", test1 != test2)
256
- check("Should not be equal", test2 != test1)
257
-
258
- test2 = tc1.new('test_2')
259
- check("Should be equal", test1 == test2)
260
- check("Should be equal", test2 == test1)
261
-
262
- test1 = tc1.new('test_1')
263
- test2 = tc2.new('test_1')
264
- check("Should not be equal", test1 != test2)
265
- check("Should not be equal", test2 != test1)
266
-
267
-
268
- check("Should not be equal", test1 != Object.new)
269
- check("Should not be equal", Object.new != test1)
270
- end
271
-
272
- def test_re_raise_exception
273
- test_case = Class.new(TestCase) do
274
- def test_raise_interrupt
275
- raise Interrupt, "from test"
276
- end
277
- end
278
-
279
- test = test_case.new("test_raise_interrupt")
280
- begin
281
- test.run(TestResult.new) {}
282
- check("Should not be reached", false)
283
- rescue Exception
284
- check("Interrupt exception should be re-raised", $!.class == Interrupt)
285
- end
286
- end
287
-
288
- def test_startup_shutdown
289
- called = []
290
- test_case = Class.new(TestCase) do
291
- class << self
292
- def called
293
- @@called
294
- end
295
-
296
- def called=(called)
297
- @@called = called
298
- end
299
-
300
- def startup
301
- @@called << :startup
302
- end
303
-
304
- def shutdown
305
- @@called << :shutdown
306
- end
307
- end
308
- self.called = called
309
-
310
- def setup
311
- self.class.called << :setup
312
- end
313
-
314
- def teardown
315
- self.class.called << :teardown
316
- end
317
-
318
- def test1
319
- end
320
-
321
- def test2
322
- end
323
- end
324
-
325
- test_suite = test_case.suite
326
- test_suite.run(TestResult.new) {}
327
- check("startup/shutdown should be called once per test case" +
328
- ": #{called.inspect}",
329
- called == [:startup,
330
- :setup, :teardown,
331
- :setup, :teardown,
332
- :shutdown])
333
- end
334
-
335
- def test_error_on_startup
336
- test_case = Class.new(TestCase) do
337
- class << self
338
- def startup
339
- raise "from startup"
340
- end
341
- end
342
-
343
- def test_nothing
344
- end
345
- end
346
-
347
- test_suite = test_case.suite
348
- result = TestResult.new
349
- test_suite.run(result) {}
350
- check("Should record an error on startup: #{result}",
351
- result.error_count == 1)
352
- end
353
-
354
- def test_pass_through_error_on_startup
355
- test_case = Class.new(TestCase) do
356
- class << self
357
- def startup
358
- raise Interrupt, "from startup"
359
- end
360
- end
361
-
362
- def test_nothing
363
- end
364
- end
365
-
366
- test_suite = test_case.suite
367
- begin
368
- test_suite.run(TestResult.new) {}
369
- check("Should not be reached", false)
370
- rescue Exception
371
- check("Interrupt should be passed through: #{$!}",
372
- Interrupt === $!)
373
- end
374
- end
375
-
376
- def test_error_on_shutdown
377
- test_case = Class.new(TestCase) do
378
- class << self
379
- def shutdown
380
- raise "from shutdown"
381
- end
382
- end
383
-
384
- def test_nothing
385
- end
386
- end
387
-
388
- test_suite = test_case.suite
389
- result = TestResult.new
390
- test_suite.run(result) {}
391
- check("Should record an error on shutdown: #{result}",
392
- result.error_count == 1)
393
- end
394
-
395
- def test_pass_through_error_on_shutdown
396
- test_case = Class.new(TestCase) do
397
- class << self
398
- def shutdown
399
- raise Interrupt, "from shutdown"
400
- end
401
- end
402
-
403
- def test_nothing
404
- end
405
- end
406
-
407
- test_suite = test_case.suite
408
- begin
409
- test_suite.run(TestResult.new) {}
410
- check("Should not be reached", false)
411
- rescue Exception
412
- check("Interrupt should be passed through: #{$!}",
413
- Interrupt === $!)
414
- end
415
- end
416
-
417
- def test_interrupted
418
- test_case = Class.new(TestCase) do
419
- def test_fail
420
- flunk
421
- end
422
-
423
- def test_nothing
424
- end
425
- end
426
-
427
- failed_test = test_case.new(:test_fail)
428
- failed_test.run(TestResult.new) {}
429
- check("Should be interrupted", failed_test.interrupted?)
430
-
431
- success_test = test_case.new(:test_nothing)
432
- success_test.run(TestResult.new) {}
433
- check("Should not be interrupted", !success_test.interrupted?)
434
- end
435
-
436
- def test_inherited_test_should_be_ignored
437
- test_case = Class.new(TestCase) do
438
- def test_nothing
439
- end
440
- end
441
-
442
- sub_test_case = Class.new(test_case) do
443
- def test_fail
444
- flunk
445
- end
446
- end
447
-
448
- assert_nothing_thrown do
449
- test_case.new("test_nothing")
450
- end
451
-
452
- assert_nothing_thrown do
453
- sub_test_case.new("test_fail")
454
- end
455
-
456
- assert_throw(:invalid_test) do
457
- sub_test_case.new("test_nothing")
458
- end
459
- end
460
-
461
- def test_mixin_test_should_not_be_ignored
462
- test_module = Module.new do
463
- def test_nothing
464
- end
465
- end
466
-
467
- test_case = Class.new(Test::Unit::TestCase) do
468
- include test_module
469
-
470
- def test_fail
471
- flunk
472
- end
473
- end
474
-
475
- assert_nothing_thrown do
476
- test_case.new("test_nothing")
477
- end
478
-
479
- assert_nothing_thrown do
480
- test_case.new("test_fail")
481
- end
482
- end
483
-
484
- def test_defined_order
485
- test_case = Class.new(Test::Unit::TestCase) do
486
- def test_z
487
- end
488
-
489
- def test_1
490
- end
491
-
492
- def test_a
493
- end
494
- end
495
-
496
- assert_equal(["test_1", "test_a", "test_z"],
497
- test_case.suite.tests.collect {|test| test.method_name})
498
-
499
- test_case.test_order = :defined
500
- assert_equal(["test_z", "test_1", "test_a"],
501
- test_case.suite.tests.collect {|test| test.method_name})
502
- end
503
-
504
- def test_declarative_style
505
- test_case = Class.new(Test::Unit::TestCase) do
506
- test "declarative style test definition" do
507
- end
508
-
509
- test "include parenthesis" do
510
- end
511
-
512
- test "1 + 2 = 3" do
513
- end
514
- end
515
-
516
- test_case.test_order = :defined
517
-
518
- assert_equal(["declarative style test definition",
519
- "include parenthesis",
520
- "1 + 2 = 3"],
521
- test_case.suite.tests.collect {|test| test.method_name})
522
-
523
- assert_equal(["declarative style test definition",
524
- "include parenthesis",
525
- "1 + 2 = 3"],
526
- test_case.suite.tests.collect {|test| test.description})
527
- end
528
-
529
- def test_test_mark
530
- test_case = Class.new(Test::Unit::TestCase) do
531
- test
532
- def my_test_method
533
- end
534
- end
535
-
536
- test_case.test_order = :defined
537
-
538
- assert_equal(["my_test_method"],
539
- test_case.suite.tests.collect {|test| test.method_name})
540
- end
541
-
542
- def test_redefine_method
543
- test_case = Class.new(Test::Unit::TestCase) do
544
- def test_name
545
- end
546
- alias_method :test_name2, :test_name
547
-
548
- def test_name
549
- end
550
- end
551
-
552
- suite = test_case.suite
553
- assert_equal(["test_name", "test_name2"],
554
- suite.tests.collect {|test| test.method_name})
555
- result = TestResult.new
556
- suite.run(result) {}
557
- assert_equal("2 tests, 0 assertions, 0 failures, " +
558
- "0 errors, 0 pendings, 0 omissions, 1 notifications",
559
- result.summary)
560
- end
561
-
562
- private
563
- def check(message, passed)
564
- add_assertion
565
- raise AssertionFailedError.new(message) unless passed
566
- end
567
- end
568
- end
569
- end