test-unit 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a84889d7e64ada72e39b5d39465d56fca7041b25
4
- data.tar.gz: 723b397f2691190b10b17e0ba71dafa3d5d3247e
3
+ metadata.gz: cf2bacf30a66a56af147ea9e94da6e0494a2651d
4
+ data.tar.gz: dc496f0ff48c039ce45d31d9b0aeda8c8fe3207c
5
5
  SHA512:
6
- metadata.gz: 7cccaddea4b0ddc35b4984a82b0b6fbc637f76f427671efa6c4aeba33e6f7246ac191cc62db8ced399db8128f478557e84e1e27ad0c8fbe35c4a27b966807083
7
- data.tar.gz: 64f04e97bd245dbcb02fece0633cd3cfc5cdf14877a5d75cadb817d7743d97db9f2fcab4ea1a918c4aa88a27ed7531116bd68b1085ef00ffd9826272e2dab3b0
6
+ metadata.gz: ea2f7f667dbc1ebb99e234c2634f2b8ed4651d1d56704a5ab800d4f0fd285d97309a4ed4920020ef37cdc4eb8316c114d75045e33ba20652ee04e4d565ae519b
7
+ data.tar.gz: c8301808c3e979ee04682074550643a7b0ae214bba5eb60f4c9808be7d86ff2faa7eaded9829e47e9f841fd76257d37bdb1b294163faad401bc9150fe4c1a671
@@ -1,5 +1,19 @@
1
1
  # News
2
2
 
3
+ ## 3.0.4 - 2014-11-01 {#version-3-0-4}
4
+
5
+ It's a minor update release.
6
+
7
+ ### Improvements
8
+
9
+ * Stopped to remove JRuby and Rubinius internal backtrace entries from
10
+ backtrace on failure/error.
11
+ [GitHub#82][Patch by Charles Oliver Nutter]
12
+
13
+ ### Thanks
14
+
15
+ * Charles Oliver Nutter
16
+
3
17
  ## 3.0.3 - 2014-10-29 {#version-3-0-3}
4
18
 
5
19
  It's a minor update release.
@@ -525,7 +525,7 @@ EOT
525
525
  alias_method :refute_respond_to, :assert_not_respond_to
526
526
 
527
527
  ##
528
- # Passes if +string+ =~ +pattern+.
528
+ # Passes if +pattern+ =~ +string+.
529
529
  #
530
530
  # @example
531
531
  # assert_match(/\d+/, 'five, 6, seven')
@@ -537,8 +537,9 @@ EOT
537
537
  else
538
538
  pattern
539
539
  end
540
- full_message = build_message(message, "<?> expected to be =~\n<?>.", string, pattern)
541
- assert_block(full_message) { string =~ pattern }
540
+ full_message = build_message(message, "<?> expected to be =~\n<?>.",
541
+ pattern, string)
542
+ assert_block(full_message) { pattern =~ string }
542
543
  end
543
544
  end
544
545
 
@@ -23,31 +23,19 @@ module Test
23
23
  split_entry[-1].sub(TESTUNIT_RB_FILE, '') == split_prefix[-1]
24
24
  end
25
25
 
26
- jruby_internal_p = lambda do |entry|
27
- entry.start_with?("org/jruby/")
28
- end
29
-
30
- rubinius_internal_p = lambda do |entry|
31
- entry.start_with?("kernel/")
32
- end
33
-
34
- found_prefix = false
26
+ in_user_code = false
35
27
  new_backtrace = backtrace.reverse.reject do |entry|
36
28
  if test_unit_internal_p.call(entry)
37
- found_prefix = true
29
+ in_user_code = true
38
30
  true
39
- elsif found_prefix
40
- jruby_internal_p.call(entry) or rubinius_internal_p.call(entry)
41
31
  else
42
- true
32
+ not in_user_code
43
33
  end
44
34
  end.reverse
45
35
 
46
36
  if new_backtrace.empty?
47
37
  new_backtrace = backtrace.reject do |entry|
48
- test_unit_internal_p.call(entry) or
49
- jruby_internal_p.call(entry) or
50
- rubinius_internal_p.call(entry)
38
+ test_unit_internal_p.call(entry)
51
39
  end
52
40
  new_backtrace = backtrace if new_backtrace.empty?
53
41
  end
@@ -1,5 +1,5 @@
1
1
  module Test
2
2
  module Unit
3
- VERSION = '3.0.3'
3
+ VERSION = '3.0.4'
4
4
  end
5
5
  end
@@ -772,13 +772,13 @@ EOM
772
772
  check_nothing_fails {
773
773
  assert_match(/strin./, "string", "successful assert_match")
774
774
  }
775
- check_fail(%Q{<"string"> expected to be =~\n</slin./>.}) {
775
+ check_fail(%Q{</slin./> expected to be =~\n<"string">.}) {
776
776
  assert_match(/slin./, "string")
777
777
  }
778
- check_fail(%Q{<"string"> expected to be =~\n</strin\\./>.}) {
778
+ check_fail(%Q{</strin\\./> expected to be =~\n<"string">.}) {
779
779
  assert_match("strin.", "string")
780
780
  }
781
- check_fail(%Q{failed assert_match.\n<"string"> expected to be =~\n</slin./>.}) {
781
+ check_fail(%Q{failed assert_match.\n</slin./> expected to be =~\n<"string">.}) {
782
782
  assert_match(/slin./, "string", "failed assert_match")
783
783
  }
784
784
  end
@@ -1,5 +1,5 @@
1
1
  # Author:: Nathaniel Talbott.
2
- # Copyright:: Copyright (c) 2008-2013 Kouhei Sutou <kou@clear-code.com>
2
+ # Copyright:: Copyright (c) 2008-2014 Kouhei Sutou <kou@clear-code.com>
3
3
  # Copyright:: Copyright (c) 2011 Haruka Yoshihara <yoshihara@clear-code.com>
4
4
  # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott
5
5
  # License:: Ruby license.
@@ -28,7 +28,9 @@ module Test
28
28
  def setup
29
29
  @tc_failure_error = Class.new(TestCase) do
30
30
  def test_failure
31
- assert_block("failure") { false }
31
+ assert_block("failure") do
32
+ false
33
+ end
32
34
  end
33
35
  def test_error
34
36
  1 / 0
@@ -37,7 +39,9 @@ module Test
37
39
  nested
38
40
  end
39
41
  def nested
40
- assert_block("nested"){false}
42
+ assert_block("nested") do
43
+ false
44
+ end
41
45
  end
42
46
  def return_passed?
43
47
  return passed?
@@ -49,82 +53,157 @@ module Test
49
53
  end
50
54
  end
51
55
 
56
+ def jruby_backtrace_entry?(entry)
57
+ entry.start_with?("org/jruby/")
58
+ end
59
+
60
+ def rubinius_backtrace_entry?(entry)
61
+ entry.start_with?("kernel/")
62
+ end
63
+
64
+ def normalize_location(location)
65
+ filtered_location = location.reject do |entry|
66
+ jruby_backtrace_entry?(entry) or
67
+ rubinius_backtrace_entry?(entry)
68
+ end
69
+ filtered_location.collect do |entry|
70
+ entry.sub(/:\d+:/, ":0:")
71
+ end
72
+ end
73
+
52
74
  def test_add_failed_assertion
53
75
  test_case = @tc_failure_error.new(:test_failure)
54
- check("passed? should start out true", test_case.return_passed?)
76
+ assert do
77
+ test_case.passed?
78
+ end
79
+
55
80
  result = TestResult.new
56
- called = false
57
- result.add_listener(TestResult::FAULT) {
58
- | fault |
59
- check("Should have a Failure", fault.instance_of?(Failure))
60
- check("The Failure should have the correct message", "failure" == fault.message)
61
- check("The Failure should have the correct test_name (was <#{fault.test_name}>)", fault.test_name == "test_failure(TC_FailureError)")
62
- r = /\A.*#{Regexp.escape(File.basename(__FILE__))}:\d+:in `test_failure'\Z/
63
-
64
- location = fault.location
65
- check("The location should be an array", location.kind_of?(Array))
66
- check("The location should have two lines (was: <#{location.inspect}>)", location.size == 2)
67
- check("The Failure should have the correct location (was <#{location[0].inspect}>, expected <#{r.inspect}>)", r =~ location[0])
68
- called = true
69
- }
81
+ faults = []
82
+ result.add_listener(TestResult::FAULT) do |fault|
83
+ faults << fault
84
+ end
70
85
  progress = []
71
- test_case.run(result) { |*arguments| progress << arguments }
72
- check("The failure should have triggered the listener", called)
73
- check("The failure should have set passed?", !test_case.return_passed?)
74
- check("The progress block should have been updated correctly",
75
- [[TestCase::STARTED, test_case.name],
76
- [TestCase::STARTED_OBJECT, test_case],
77
- [TestCase::FINISHED, test_case.name],
78
- [TestCase::FINISHED_OBJECT, test_case]] == progress)
86
+ test_case.run(result) do |*arguments|
87
+ progress << arguments
88
+ end
89
+ fault_details = faults.collect do |fault|
90
+ {
91
+ :class => fault.class,
92
+ :message => fault.message,
93
+ :test_name => fault.test_name,
94
+ :location => normalize_location(fault.location),
95
+ }
96
+ end
97
+ assert_equal([
98
+ {
99
+ :class => Failure,
100
+ :message => "failure",
101
+ :test_name => "test_failure(TC_FailureError)",
102
+ :location => [
103
+ "#{__FILE__}:0:in `test_failure'",
104
+ "#{__FILE__}:0:in `#{__method__}'",
105
+ ],
106
+ },
107
+ ],
108
+ fault_details)
109
+
110
+ assert do
111
+ not test_case.passed?
112
+ end
113
+ assert_equal([
114
+ [TestCase::STARTED, test_case.name],
115
+ [TestCase::STARTED_OBJECT, test_case],
116
+ [TestCase::FINISHED, test_case.name],
117
+ [TestCase::FINISHED_OBJECT, test_case],
118
+ ],
119
+ progress)
79
120
  end
80
121
 
81
122
  def test_add_failure_nested
82
123
  test_case = @tc_failure_error.new(:test_nested_failure)
83
- check("passed? should start out true", test_case.return_passed?)
124
+ assert do
125
+ test_case.passed?
126
+ end
84
127
 
85
128
  result = TestResult.new
86
- called = false
87
- result.add_listener(TestResult::FAULT) {
88
- | fault |
89
- check("Should have a Failure", fault.instance_of?(Failure))
90
- check("The Failure should have the correct message", "nested" == fault.message)
91
- check("The Failure should have the correct test_name (was <#{fault.test_name}>)", fault.test_name == "test_nested_failure(TC_FailureError)")
92
-
93
- location = fault.location
94
- check("The location should be an array", location.kind_of?(Array))
95
- check("The location should have the correct number of lines (was: <#{location.inspect}>)", location.size == 3)
96
- check("The Failure should have the correct location (was <#{location[0].inspect}>)", /\A.*#{Regexp.escape(File.basename(__FILE__))}:\d+:in `nested'\Z/ =~ location[0])
97
- 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])
98
- called = true
99
- }
100
- test_case.run(result){}
101
- check("The failure should have triggered the listener", called)
129
+ faults = []
130
+ result.add_listener(TestResult::FAULT) do |fault|
131
+ faults << fault
132
+ end
133
+ test_case.run(result) do
134
+ end
135
+ fault_details = faults.collect do |fault|
136
+ {
137
+ :class => fault.class,
138
+ :message => fault.message,
139
+ :test_name => fault.test_name,
140
+ :location => normalize_location(fault.location),
141
+ }
142
+ end
143
+ assert_equal([
144
+ {
145
+ :class => Failure,
146
+ :message => "nested",
147
+ :test_name => "test_nested_failure(TC_FailureError)",
148
+ :location => [
149
+ "#{__FILE__}:0:in `nested'",
150
+ "#{__FILE__}:0:in `test_nested_failure'",
151
+ "#{__FILE__}:0:in `#{__method__}'",
152
+ ],
153
+ },
154
+ ],
155
+ fault_details)
156
+
157
+ assert do
158
+ not test_case.passed?
159
+ end
102
160
  end
103
-
161
+
104
162
  def test_add_error
105
163
  test_case = @tc_failure_error.new(:test_error)
106
- check("passed? should start out true", test_case.return_passed?)
164
+ assert do
165
+ test_case.passed?
166
+ end
167
+
107
168
  result = TestResult.new
108
- called = false
109
- result.add_listener(TestResult::FAULT) {
110
- | fault |
111
- check("Should have a TestError", fault.instance_of?(Error))
112
- check("The Error should have the correct message", "ZeroDivisionError: divided by 0" == fault.message)
113
- check("The Error should have the correct test_name", "test_error(TC_FailureError)" == fault.test_name)
114
- check("The Error should have the correct exception", fault.exception.instance_of?(ZeroDivisionError))
115
- called = true
116
- }
117
- test_case.run(result) {}
118
- check("The error should have triggered the listener", called)
119
- check("The error should have set passed?", !test_case.return_passed?)
169
+ faults = []
170
+ result.add_listener(TestResult::FAULT) do |fault|
171
+ faults << fault
172
+ end
173
+ test_case.run(result) do
174
+ end
175
+ fault_details = faults.collect do |fault|
176
+ {
177
+ :class => fault.class,
178
+ :message => fault.message,
179
+ :test_name => fault.test_name,
180
+ :location => normalize_location(fault.location),
181
+ }
182
+ end
183
+ assert_equal([
184
+ {
185
+ :class => Error,
186
+ :message => "ZeroDivisionError: divided by 0",
187
+ :test_name => "test_error(TC_FailureError)",
188
+ :location => [
189
+ "#{__FILE__}:0:in `test_error'",
190
+ "#{__FILE__}:0:in `#{__method__}'",
191
+ ],
192
+ },
193
+ ],
194
+ fault_details)
195
+
196
+ assert do
197
+ not test_case.passed?
198
+ end
120
199
  end
121
200
 
122
- def test_no_tests
201
+ def test_no_tests
123
202
  suite = TestCase.suite
124
203
  check("Should have a test suite", suite.instance_of?(TestSuite))
125
204
  check("Should have one test", suite.size == 1)
126
205
  check("Should have the default test", suite.tests.first.name == "default_test(Test::Unit::TestCase)")
127
-
206
+
128
207
  result = TestResult.new
129
208
  suite.run(result) {}
130
209
  check("Should have had one test run", result.run_count == 1)
@@ -153,19 +232,18 @@ module Test
153
232
  assert_block {true}
154
233
  end
155
234
  end
156
-
235
+
157
236
  suite = tc.suite
158
237
  check("Should have a test suite", suite.instance_of?(TestSuite))
159
238
  check("Should have three tests", suite.size == 3)
160
-
239
+
161
240
  result = TestResult.new
162
241
  suite.run(result) {}
163
242
  check("Should have had three test runs", result.run_count == 3)
164
243
  check("Should have had one test failure", result.failure_count == 1)
165
244
  check("Should have had one test error", result.error_count == 1)
166
245
  end
167
-
168
-
246
+
169
247
  def test_setup_teardown
170
248
  tc = Class.new(TestCase) do
171
249
  attr_reader(:setup_called, :teardown_called)
@@ -191,34 +269,34 @@ module Test
191
269
  end
192
270
  end
193
271
  result = TestResult.new
194
-
272
+
195
273
  test = tc.new(:test_succeed)
196
274
  test.run(result) {}
197
275
  check("Should have called setup the correct number of times", test.setup_called)
198
276
  check("Should have called teardown the correct number of times", test.teardown_called)
199
-
277
+
200
278
  test = tc.new(:test_fail)
201
279
  test.run(result) {}
202
280
  check("Should have called setup the correct number of times", test.setup_called)
203
281
  check("Should have called teardown the correct number of times", test.teardown_called)
204
-
282
+
205
283
  test = tc.new(:test_error)
206
284
  test.run(result) {}
207
285
  check("Should have called setup the correct number of times", test.setup_called)
208
286
  check("Should have called teardown the correct number of times", test.teardown_called)
209
-
287
+
210
288
  check("Should have had two test runs", result.run_count == 3)
211
289
  check("Should have had a test failure", result.failure_count == 1)
212
290
  check("Should have had a test error", result.error_count == 1)
213
291
  end
214
-
292
+
215
293
  def test_assertion_failed_not_called
216
294
  tc = Class.new(TestCase) do
217
295
  def test_thing
218
296
  raise AssertionFailedError.new
219
297
  end
220
298
  end
221
-
299
+
222
300
  suite = tc.suite
223
301
  check("Should have one test", suite.size == 1)
224
302
  result = TestResult.new
@@ -227,7 +305,7 @@ module Test
227
305
  check("Should have had one assertion failure", result.failure_count == 1)
228
306
  check("Should not have any assertion errors but had #{result.error_count}", result.error_count == 0)
229
307
  end
230
-
308
+
231
309
  def test_equality
232
310
  tc1 = Class.new(TestCase) do
233
311
  def test_1
@@ -235,31 +313,30 @@ module Test
235
313
  def test_2
236
314
  end
237
315
  end
238
-
316
+
239
317
  tc2 = Class.new(TestCase) do
240
318
  def test_1
241
319
  end
242
320
  end
243
-
321
+
244
322
  test1 = tc1.new('test_1')
245
323
  test2 = tc1.new('test_1')
246
324
  check("Should be equal", test1 == test2)
247
325
  check("Should be equal", test2 == test1)
248
-
326
+
249
327
  test1 = tc1.new('test_2')
250
328
  check("Should not be equal", test1 != test2)
251
329
  check("Should not be equal", test2 != test1)
252
-
330
+
253
331
  test2 = tc1.new('test_2')
254
332
  check("Should be equal", test1 == test2)
255
333
  check("Should be equal", test2 == test1)
256
-
334
+
257
335
  test1 = tc1.new('test_1')
258
336
  test2 = tc2.new('test_1')
259
337
  check("Should not be equal", test1 != test2)
260
338
  check("Should not be equal", test2 != test1)
261
339
 
262
-
263
340
  check("Should not be equal", test1 != Object.new)
264
341
  check("Should not be equal", Object.new != test1)
265
342
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-28 00:00:00.000000000 Z
12
+ date: 2014-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: power_assert