rdoc 3.2 → 3.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

@@ -592,6 +592,71 @@ end
592
592
  assert_equal 2, foo.method_list.length
593
593
  end
594
594
 
595
+ def test_parse_multi_ghost_methods
596
+ util_parser <<-'CLASS'
597
+ class Foo
598
+ ##
599
+ # :method: one
600
+ #
601
+ # my method
602
+
603
+ ##
604
+ # :method: two
605
+ #
606
+ # my method
607
+
608
+ [:one, :two].each do |t|
609
+ eval("def #{t}; \"#{t}\"; end")
610
+ end
611
+ end
612
+ CLASS
613
+
614
+ tk = @parser.get_tk
615
+
616
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, ''
617
+
618
+ foo = @top_level.classes.first
619
+ assert_equal 'Foo', foo.full_name
620
+
621
+ assert_equal 2, foo.method_list.length
622
+ end
623
+
624
+ def test_parse_const_fail_w_meta
625
+ util_parser <<-CLASS
626
+ class ConstFailMeta
627
+ ##
628
+ # :attr: one
629
+ #
630
+ # an attribute
631
+
632
+ OtherModule.define_attr(self, :one)
633
+ end
634
+ CLASS
635
+
636
+ tk = @parser.get_tk
637
+
638
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, ''
639
+
640
+ const_fail_meta = @top_level.classes.first
641
+ assert_equal 'ConstFailMeta', const_fail_meta.full_name
642
+
643
+ assert_equal 1, const_fail_meta.attributes.length
644
+ end
645
+
646
+ def test_parse_class_nested_superclass
647
+ foo = RDoc::NormalModule.new 'Foo'
648
+ foo.parent = @top_level
649
+
650
+ util_parser "class Bar < Super\nend"
651
+
652
+ tk = @parser.get_tk
653
+
654
+ @parser.parse_class foo, RDoc::Parser::Ruby::NORMAL, tk, ''
655
+
656
+ bar = foo.classes.first
657
+ assert_equal 'Super', bar.superclass
658
+ end
659
+
595
660
  def test_parse_class_nested_superclass
596
661
  util_top_level
597
662
  foo = @top_level.add_module RDoc::NormalModule, 'Foo'
@@ -942,6 +1007,27 @@ EOF
942
1007
  assert_equal stream, foo.token_stream
943
1008
  end
944
1009
 
1010
+ def test_parse_meta_method_block
1011
+ klass = RDoc::NormalClass.new 'Foo'
1012
+ klass.parent = @top_level
1013
+
1014
+ comment = "##\n# my method\n"
1015
+
1016
+ content = <<-CONTENT
1017
+ inline(:my_method) do |*args|
1018
+ "this method is causes z to disapear"
1019
+ end
1020
+ CONTENT
1021
+
1022
+ util_parser content
1023
+
1024
+ tk = @parser.get_tk
1025
+
1026
+ @parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
1027
+
1028
+ assert_nil @parser.get_tk
1029
+ end
1030
+
945
1031
  def test_parse_meta_method_name
946
1032
  klass = RDoc::NormalClass.new 'Foo'
947
1033
  klass.parent = @top_level
@@ -1691,8 +1777,77 @@ end
1691
1777
  while @parser.get_tk do end
1692
1778
  end
1693
1779
 
1694
- def test_stopdoc_after_comment
1780
+ def test_scan_cr
1781
+ content = <<-CONTENT
1782
+ class C\r
1783
+ def m\r
1784
+ a=\\\r
1785
+ 123\r
1786
+ end\r
1787
+ end\r
1788
+ CONTENT
1789
+
1790
+ util_parser content
1791
+
1792
+ @parser.scan
1793
+
1794
+ c = @top_level.classes.first
1795
+
1796
+ assert_equal 1, c.method_list.length
1797
+ end
1798
+
1799
+ def test_scan_block_comment
1800
+ content = <<-CONTENT
1801
+ =begin rdoc
1802
+ Foo comment
1803
+ =end
1804
+
1805
+ class Foo
1806
+
1807
+ =begin
1808
+ m comment
1809
+ =end
1810
+
1811
+ def m() end
1812
+ end
1813
+ CONTENT
1814
+
1815
+ util_parser content
1816
+
1817
+ @parser.scan
1818
+
1819
+ foo = @top_level.classes.first
1820
+
1821
+ assert_equal 'Foo comment', foo.comment
1822
+
1823
+ m = foo.method_list.first
1824
+
1825
+ assert_equal 'm comment', m.comment
1826
+ end
1827
+
1828
+ def test_scan_meta_method_block
1829
+ content = <<-CONTENT
1830
+ class C
1695
1831
 
1832
+ ##
1833
+ # my method
1834
+
1835
+ inline(:my_method) do |*args|
1836
+ "this method used to cause z to disapear"
1837
+ end
1838
+
1839
+ def z
1840
+ end
1841
+ CONTENT
1842
+
1843
+ util_parser content
1844
+
1845
+ @parser.scan
1846
+
1847
+ assert_equal 2, @top_level.classes.first.method_list.length
1848
+ end
1849
+
1850
+ def test_stopdoc_after_comment
1696
1851
  util_parser <<-EOS
1697
1852
  module Bar
1698
1853
  # hello
@@ -9,6 +9,8 @@ require 'tmpdir'
9
9
  class TestRDocRDoc < MiniTest::Unit::TestCase
10
10
 
11
11
  def setup
12
+ RDoc::TopLevel.reset
13
+
12
14
  @rdoc = RDoc::RDoc.new
13
15
  @rdoc.options = RDoc::Options.new
14
16
 
@@ -62,13 +64,14 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
62
64
  skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir
63
65
 
64
66
  Dir.mktmpdir {|d|
65
- path = File.join(d, 'testdir')
67
+ path = File.join d, 'testdir'
66
68
 
67
69
  last = @rdoc.setup_output_dir path, false
68
70
 
69
71
  assert_empty last
70
72
 
71
73
  assert File.directory? path
74
+ assert File.exist? @rdoc.output_flag_file path
72
75
  }
73
76
  end
74
77
 
@@ -390,6 +390,16 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
390
390
  assert_match %r%^=== Implementation from Foo%, out
391
391
  end
392
392
 
393
+ def test_display_method_overriden
394
+ util_multi_store
395
+
396
+ out, = capture_io do
397
+ @driver.display_method 'Bar#override'
398
+ end
399
+
400
+ refute_match %r%must not be displayed%, out
401
+ end
402
+
393
403
  def test_display_name_not_found_class
394
404
  util_store
395
405
 
@@ -495,6 +505,32 @@ Foo::Bar#bother
495
505
  assert_equal expected, items
496
506
  end
497
507
 
508
+ def test_filter_methods
509
+ util_multi_store
510
+
511
+ name = 'Bar#override'
512
+
513
+ found = @driver.load_methods_matching name
514
+
515
+ sorted = @driver.filter_methods found, name
516
+
517
+ expected = [[@store2, [@override]]]
518
+
519
+ assert_equal expected, sorted
520
+ end
521
+
522
+ def test_filter_methods_not_found
523
+ util_multi_store
524
+
525
+ name = 'Bar#inherit'
526
+
527
+ found = @driver.load_methods_matching name
528
+
529
+ sorted = @driver.filter_methods found, name
530
+
531
+ assert_equal found, sorted
532
+ end
533
+
498
534
  def test_formatter
499
535
  tty = Object.new
500
536
  def tty.tty?() true; end
@@ -533,6 +569,16 @@ Foo::Bar#bother
533
569
  assert_equal :class, @driver.method_type('::')
534
570
  end
535
571
 
572
+ def test_name_regexp
573
+ assert_equal /^RDoc::AnyMethod#new$/,
574
+ @driver.name_regexp('RDoc::AnyMethod#new')
575
+ assert_equal /^RDoc::AnyMethod::new$/,
576
+ @driver.name_regexp('RDoc::AnyMethod::new')
577
+
578
+ assert_equal /^RDoc::AnyMethod(#|::)new$/,
579
+ @driver.name_regexp('RDoc::AnyMethod.new')
580
+ end
581
+
536
582
  def test_list_known_classes
537
583
  util_store
538
584
 
@@ -766,6 +812,7 @@ Foo::Bar#bother
766
812
  @mAmbiguous = RDoc::NormalModule.new 'Ambiguous'
767
813
 
768
814
  @cFoo = RDoc::NormalClass.new 'Foo'
815
+
769
816
  @cBar = RDoc::NormalClass.new 'Bar'
770
817
  @cBar.superclass = 'Foo'
771
818
  @cFoo_Baz = RDoc::NormalClass.new 'Baz'
@@ -774,10 +821,15 @@ Foo::Bar#bother
774
821
  @baz = RDoc::AnyMethod.new nil, 'baz'
775
822
  @cBar.add_method @baz
776
823
 
824
+ @override = RDoc::AnyMethod.new nil, 'override'
825
+ @override.comment = 'must be displayed'
826
+ @cBar.add_method @override
827
+
777
828
  @store2.save_class @mAmbiguous
778
829
  @store2.save_class @cBar
779
830
  @store2.save_class @cFoo_Baz
780
831
 
832
+ @store2.save_method @cBar, @override
781
833
  @store2.save_method @cBar, @baz
782
834
 
783
835
  @store2.save_cache
@@ -824,6 +876,11 @@ Foo::Bar#bother
824
876
  @inherit = RDoc::AnyMethod.new nil, 'inherit'
825
877
  @cFoo.add_method @inherit
826
878
 
879
+ # overriden by Bar in multi_store
880
+ @overriden = RDoc::AnyMethod.new nil, 'override'
881
+ @overriden.comment = 'must not be displayed'
882
+ @cFoo.add_method @overriden
883
+
827
884
  @store.save_class @cFoo
828
885
  @store.save_class @cFoo_Bar
829
886
  @store.save_class @cFoo_Baz
@@ -836,6 +893,7 @@ Foo::Bar#bother
836
893
  @store.save_method @cFoo_Bar, @attr
837
894
 
838
895
  @store.save_method @cFoo, @inherit
896
+ @store.save_method @cFoo, @overriden
839
897
 
840
898
  @store.save_cache
841
899
 
@@ -0,0 +1,12 @@
1
+ require File.expand_path '../xref_test_case', __FILE__
2
+
3
+ class TestRDocSingleClass < XrefTestCase
4
+
5
+ def test_definition
6
+ c = RDoc::SingleClass.new 'C'
7
+
8
+ assert_equal 'class << C', c.definition
9
+ end
10
+
11
+ end
12
+
@@ -13,8 +13,78 @@ class TestRDocStats < MiniTest::Unit::TestCase
13
13
  @s = RDoc::Stats.new 0
14
14
  end
15
15
 
16
+ def test_report_attr
17
+ tl = RDoc::TopLevel.new 'file.rb'
18
+ c = tl.add_class RDoc::NormalClass, 'C'
19
+ c.record_location tl
20
+ c.comment = 'C'
21
+
22
+ a = RDoc::Attr.new nil, 'a', 'RW', nil
23
+ a.record_location tl
24
+ c.add_attribute a
25
+
26
+ RDoc::TopLevel.complete :public
27
+
28
+ report = @s.report
29
+
30
+ expected = <<-EXPECTED
31
+ The following items are not documented:
32
+
33
+ class C # is documented
34
+
35
+ attr_accessor :a # in file file.rb
36
+ end
37
+ EXPECTED
38
+
39
+ assert_equal expected, report
40
+ end
41
+
42
+ def test_report_attr_documented
43
+ tl = RDoc::TopLevel.new 'file.rb'
44
+ c = tl.add_class RDoc::NormalClass, 'C'
45
+ c.record_location tl
46
+ c.comment = 'C'
47
+
48
+ a = RDoc::Attr.new nil, 'a', 'RW', 'a'
49
+ a.record_location tl
50
+ c.add_attribute a
51
+
52
+ RDoc::TopLevel.complete :public
53
+
54
+ report = @s.report
55
+
56
+ assert_equal @s.great_job, report
57
+ end
58
+
59
+ def test_report_constant
60
+ tl = RDoc::TopLevel.new 'file.rb'
61
+ m = tl.add_module RDoc::NormalModule, 'M'
62
+ m.record_location tl
63
+ m.comment = 'M'
64
+
65
+ c = RDoc::Constant.new 'C', nil, nil
66
+ c.record_location tl
67
+ m.add_constant c
68
+
69
+ RDoc::TopLevel.complete :public
70
+
71
+ report = @s.report
72
+
73
+ expected = <<-EXPECTED
74
+ The following items are not documented:
75
+
76
+ module M # is documented
77
+
78
+ # in file file.rb
79
+ C = nil
80
+ end
81
+ EXPECTED
82
+
83
+ assert_equal expected, report
84
+ end
85
+
16
86
  def test_report_constant_alias
17
- tl = RDoc::TopLevel.new 'fake.rb'
87
+ tl = RDoc::TopLevel.new 'file.rb'
18
88
  mod = tl.add_module RDoc::NormalModule, 'M'
19
89
 
20
90
  c = tl.add_class RDoc::NormalClass, 'C'
@@ -34,5 +104,440 @@ class TestRDocStats < MiniTest::Unit::TestCase
34
104
  assert_match(/class Object/, report)
35
105
  end
36
106
 
107
+ def test_report_constant_documented
108
+ tl = RDoc::TopLevel.new 'file.rb'
109
+ m = tl.add_module RDoc::NormalModule, 'M'
110
+ m.record_location tl
111
+ m.comment = 'M'
112
+
113
+ c = RDoc::Constant.new 'C', nil, 'C'
114
+ c.record_location tl
115
+ m.add_constant c
116
+
117
+ RDoc::TopLevel.complete :public
118
+
119
+ report = @s.report
120
+
121
+ assert_equal @s.great_job, report
122
+ end
123
+
124
+ def test_report_class
125
+ tl = RDoc::TopLevel.new 'file.rb'
126
+ c = tl.add_class RDoc::NormalClass, 'C'
127
+ c.record_location tl
128
+
129
+ m = RDoc::AnyMethod.new nil, 'm'
130
+ m.record_location tl
131
+ c.add_method m
132
+ m.comment = 'm'
133
+
134
+ RDoc::TopLevel.complete :public
135
+
136
+ report = @s.report
137
+
138
+ expected = <<-EXPECTED
139
+ The following items are not documented:
140
+
141
+ # in files:
142
+ # file.rb
143
+
144
+ class C
145
+ end
146
+ EXPECTED
147
+
148
+ assert_equal expected, report
149
+ end
150
+
151
+ def test_report_class_documented
152
+ tl = RDoc::TopLevel.new 'file.rb'
153
+ c = tl.add_class RDoc::NormalClass, 'C'
154
+ c.record_location tl
155
+ c.comment = 'C'
156
+
157
+ m = RDoc::AnyMethod.new nil, 'm'
158
+ m.record_location tl
159
+ c.add_method m
160
+ m.comment = 'm'
161
+
162
+ RDoc::TopLevel.complete :public
163
+
164
+ report = @s.report
165
+
166
+ assert_equal @s.great_job, report
167
+ end
168
+
169
+ def test_report_class_documented_level_1
170
+ tl = RDoc::TopLevel.new 'file.rb'
171
+ c1 = tl.add_class RDoc::NormalClass, 'C1'
172
+ c1.record_location tl
173
+ c1.comment = 'C1'
174
+
175
+ m1 = RDoc::AnyMethod.new nil, 'm1'
176
+ m1.record_location tl
177
+ c1.add_method m1
178
+ m1.comment = 'm1'
179
+
180
+ c2 = tl.add_class RDoc::NormalClass, 'C2'
181
+ c2.record_location tl
182
+
183
+ m2 = RDoc::AnyMethod.new nil, 'm2'
184
+ m2.record_location tl
185
+ c2.add_method m2
186
+ m2.comment = 'm2'
187
+
188
+ RDoc::TopLevel.complete :public
189
+
190
+ @s.coverage_level = 1
191
+
192
+ report = @s.report
193
+
194
+ expected = <<-EXPECTED
195
+ The following items are not documented:
196
+
197
+
198
+ # in files:
199
+ # file.rb
200
+
201
+ class C2
202
+ end
203
+ EXPECTED
204
+
205
+ assert_equal expected, report
206
+ end
207
+
208
+ def test_report_class_empty
209
+ tl = RDoc::TopLevel.new 'file.rb'
210
+ tl.add_class RDoc::NormalClass, 'C'
211
+
212
+ RDoc::TopLevel.complete :public
213
+
214
+ report = @s.report
215
+
216
+ expected = <<-EXPECTED
217
+ The following items are not documented:
218
+
219
+ # class C is referenced but empty.
220
+ #
221
+ # It probably came from another project. I'm sorry I'm holding it against you.
222
+ EXPECTED
223
+
224
+ assert_equal expected, report
225
+ end
226
+
227
+ def test_report_class_empty_2
228
+ tl = RDoc::TopLevel.new 'file.rb'
229
+ c1 = tl.add_class RDoc::NormalClass, 'C1'
230
+ c1.record_location tl
231
+
232
+ c2 = tl.add_class RDoc::NormalClass, 'C2'
233
+ c2.record_location tl
234
+ c2.comment = 'C2'
235
+
236
+ RDoc::TopLevel.complete :public
237
+
238
+ @s.coverage_level = 1
239
+ report = @s.report
240
+
241
+ expected = <<-EXPECTED
242
+ The following items are not documented:
243
+
244
+ # in files:
245
+ # file.rb
246
+
247
+ class C1
248
+ end
249
+
250
+ EXPECTED
251
+
252
+ assert_equal expected, report
253
+ end
254
+
255
+ def test_report_class_method_documented
256
+ tl = RDoc::TopLevel.new 'file.rb'
257
+ c = tl.add_class RDoc::NormalClass, 'C'
258
+ c.record_location tl
259
+
260
+ m = RDoc::AnyMethod.new nil, 'm'
261
+ m.record_location tl
262
+ c.add_method m
263
+ m.comment = 'm'
264
+
265
+ RDoc::TopLevel.complete :public
266
+
267
+ report = @s.report
268
+
269
+ expected = <<-EXPECTED
270
+ The following items are not documented:
271
+
272
+ # in files:
273
+ # file.rb
274
+
275
+ class C
276
+ end
277
+ EXPECTED
278
+
279
+ assert_equal expected, report
280
+ end
281
+
282
+ def test_report_empty
283
+ RDoc::TopLevel.complete :public
284
+
285
+ report = @s.report
286
+
287
+ assert_equal @s.great_job, report
288
+ end
289
+
290
+ def test_report_method
291
+ tl = RDoc::TopLevel.new 'file.rb'
292
+ c = tl.add_class RDoc::NormalClass, 'C'
293
+ c.record_location tl
294
+ c.comment = 'C'
295
+
296
+ m1 = RDoc::AnyMethod.new nil, 'm1'
297
+ m1.record_location tl
298
+ c.add_method m1
299
+
300
+ m2 = RDoc::AnyMethod.new nil, 'm2'
301
+ m2.record_location tl
302
+ c.add_method m2
303
+ m2.comment = 'm2'
304
+
305
+ RDoc::TopLevel.complete :public
306
+
307
+ report = @s.report
308
+
309
+ expected = <<-EXPECTED
310
+ The following items are not documented:
311
+
312
+ class C # is documented
313
+
314
+ # in file file.rb
315
+ def m1; end
316
+
317
+ end
318
+ EXPECTED
319
+
320
+ assert_equal expected, report
321
+ end
322
+
323
+ def test_report_method_documented
324
+ tl = RDoc::TopLevel.new 'file.rb'
325
+ c = tl.add_class RDoc::NormalClass, 'C'
326
+ c.record_location tl
327
+ c.comment = 'C'
328
+
329
+ m = RDoc::AnyMethod.new nil, 'm'
330
+ m.record_location tl
331
+ c.add_method m
332
+ m.comment = 'm'
333
+
334
+ RDoc::TopLevel.complete :public
335
+
336
+ report = @s.report
337
+
338
+ assert_equal @s.great_job, report
339
+ end
340
+
341
+ def test_report_method_parameters
342
+ tl = RDoc::TopLevel.new 'file.rb'
343
+ c = tl.add_class RDoc::NormalClass, 'C'
344
+ c.record_location tl
345
+ c.comment = 'C'
346
+
347
+ m1 = RDoc::AnyMethod.new nil, 'm1'
348
+ m1.record_location tl
349
+ m1.params = '(p1, p2)'
350
+ m1.comment = 'Stuff with +p1+'
351
+ c.add_method m1
352
+
353
+ m2 = RDoc::AnyMethod.new nil, 'm2'
354
+ m2.record_location tl
355
+ c.add_method m2
356
+ m2.comment = 'm2'
357
+
358
+ RDoc::TopLevel.complete :public
359
+
360
+ @s.coverage_level = 1
361
+ report = @s.report
362
+
363
+ expected = <<-EXPECTED
364
+ The following items are not documented:
365
+
366
+ class C # is documented
367
+
368
+ # in file file.rb
369
+ # +p2+ is not documented
370
+ def m1(p1, p2); end
371
+
372
+ end
373
+ EXPECTED
374
+
375
+ assert_equal expected, report
376
+ end
377
+
378
+ def test_report_method_parameters_documented
379
+ tl = RDoc::TopLevel.new 'file.rb'
380
+ c = tl.add_class RDoc::NormalClass, 'C'
381
+ c.record_location tl
382
+ c.comment = 'C'
383
+
384
+ m = RDoc::AnyMethod.new nil, 'm'
385
+ m.record_location tl
386
+ m.params = '(p1)'
387
+ m.comment = 'Stuff with +p1+'
388
+ c.add_method m
389
+
390
+ RDoc::TopLevel.complete :public
391
+
392
+ @s.coverage_level = 1
393
+ report = @s.report
394
+
395
+ assert_equal @s.great_job, report
396
+ end
397
+
398
+ def test_report_method_parameters_yield
399
+ tl = RDoc::TopLevel.new 'file.rb'
400
+ c = tl.add_class RDoc::NormalClass, 'C'
401
+ c.record_location tl
402
+ c.comment = 'C'
403
+
404
+ m = RDoc::AnyMethod.new nil, 'm'
405
+ m.record_location tl
406
+ m.call_seq = <<-SEQ
407
+ m(a) { |c| ... }
408
+ m(a, b) { |c, d| ... }
409
+ SEQ
410
+ m.comment = 'Stuff with +a+, yields +c+ for you to do stuff with'
411
+ c.add_method m
412
+
413
+ RDoc::TopLevel.complete :public
414
+
415
+ @s.coverage_level = 1
416
+ report = @s.report
417
+
418
+ expected = <<-EXPECTED
419
+ The following items are not documented:
420
+
421
+ class C # is documented
422
+
423
+ # in file file.rb
424
+ # +b+, +d+ is not documented
425
+ def m; end
426
+
427
+ end
428
+ EXPECTED
429
+
430
+ assert_equal expected, report
431
+ end
432
+
433
+ def test_summary
434
+ tl = RDoc::TopLevel.new 'file.rb'
435
+ c = tl.add_class RDoc::NormalClass, 'C'
436
+ c.record_location tl
437
+
438
+ m = tl.add_module RDoc::NormalModule, 'M'
439
+ m.record_location tl
440
+
441
+ a = RDoc::Attr.new nil, 'a', 'RW', nil
442
+ a.record_location tl
443
+ c.add_attribute a
444
+
445
+ c_c = RDoc::Constant.new 'C', nil, nil
446
+ c_c.record_location tl
447
+ c.add_constant c_c
448
+
449
+ m = RDoc::AnyMethod.new nil, 'm'
450
+ m.record_location tl
451
+ c.add_method m
452
+
453
+ RDoc::TopLevel.complete :public
454
+
455
+ summary = @s.summary
456
+ summary.sub!(/Elapsed:.*/, '')
457
+
458
+ expected = <<-EXPECTED
459
+ Files: 0
460
+
461
+ Classes: 1 (1 undocumented)
462
+ Modules: 1 (1 undocumented)
463
+ Constants: 1 (1 undocumented)
464
+ Attributes: 1 (1 undocumented)
465
+ Methods: 1 (1 undocumented)
466
+
467
+ Total: 5 (5 undocumented)
468
+ 0.00% documented
469
+
470
+ EXPECTED
471
+
472
+ assert_equal summary, expected
473
+ end
474
+
475
+ def test_summary_level_false
476
+ tl = RDoc::TopLevel.new 'file.rb'
477
+ c = tl.add_class RDoc::NormalClass, 'C'
478
+ c.record_location tl
479
+
480
+ RDoc::TopLevel.complete :public
481
+
482
+ @s.coverage_level = false
483
+
484
+ summary = @s.summary
485
+ summary.sub!(/Elapsed:.*/, '')
486
+
487
+ expected = <<-EXPECTED
488
+ Files: 0
489
+
490
+ Classes: 1 (1 undocumented)
491
+ Modules: 0 (0 undocumented)
492
+ Constants: 0 (0 undocumented)
493
+ Attributes: 0 (0 undocumented)
494
+ Methods: 0 (0 undocumented)
495
+
496
+ Total: 1 (1 undocumented)
497
+ 0.00% documented
498
+
499
+ EXPECTED
500
+
501
+ assert_equal summary, expected
502
+ end
503
+
504
+ def test_summary_level_1
505
+ tl = RDoc::TopLevel.new 'file.rb'
506
+ c = tl.add_class RDoc::NormalClass, 'C'
507
+ c.record_location tl
508
+ c.comment = 'C'
509
+
510
+ m = RDoc::AnyMethod.new nil, 'm'
511
+ m.record_location tl
512
+ m.params = '(p1, p2)'
513
+ m.comment = 'Stuff with +p1+'
514
+ c.add_method m
515
+
516
+ RDoc::TopLevel.complete :public
517
+
518
+ @s.coverage_level = 1
519
+ @s.report
520
+
521
+ summary = @s.summary
522
+ summary.sub!(/Elapsed:.*/, '')
523
+
524
+ expected = <<-EXPECTED
525
+ Files: 0
526
+
527
+ Classes: 1 (0 undocumented)
528
+ Modules: 0 (0 undocumented)
529
+ Constants: 0 (0 undocumented)
530
+ Attributes: 0 (0 undocumented)
531
+ Methods: 1 (0 undocumented)
532
+ Parameters: 2 (1 undocumented)
533
+
534
+ Total: 4 (1 undocumented)
535
+ 75.00% documented
536
+
537
+ EXPECTED
538
+
539
+ assert_equal summary, expected
540
+ end
541
+
37
542
  end
38
543