rdoc 4.1.2 → 4.2.0

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.

Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.autotest +3 -1
  3. data/History.rdoc +70 -3
  4. data/LEGAL.rdoc +11 -0
  5. data/Manifest.txt +6 -2
  6. data/Rakefile +8 -1
  7. data/lib/rdoc.rb +3 -1
  8. data/lib/rdoc/context.rb +2 -0
  9. data/lib/rdoc/encoding.rb +3 -1
  10. data/lib/rdoc/generator.rb +1 -0
  11. data/lib/rdoc/generator/darkfish.rb +3 -2
  12. data/lib/rdoc/generator/json_index.rb +44 -0
  13. data/lib/rdoc/generator/pot.rb +97 -0
  14. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
  15. data/lib/rdoc/generator/template/darkfish/_head.rhtml +9 -12
  16. data/lib/rdoc/generator/template/darkfish/{fonts.css → css/fonts.css} +0 -0
  17. data/lib/rdoc/generator/template/darkfish/{rdoc.css → css/rdoc.css} +11 -1
  18. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +32 -11
  19. data/lib/rdoc/markdown.kpeg +6 -1
  20. data/lib/rdoc/markdown.rb +174 -2
  21. data/lib/rdoc/markup.rb +2 -2
  22. data/lib/rdoc/markup/attribute_manager.rb +1 -1
  23. data/lib/rdoc/markup/to_html.rb +5 -4
  24. data/lib/rdoc/markup/to_label.rb +1 -1
  25. data/lib/rdoc/method_attr.rb +11 -3
  26. data/lib/rdoc/options.rb +55 -3
  27. data/lib/rdoc/parser.rb +1 -1
  28. data/lib/rdoc/parser/c.rb +5 -6
  29. data/lib/rdoc/parser/changelog.rb +7 -3
  30. data/lib/rdoc/parser/ruby.rb +8 -12
  31. data/lib/rdoc/rd/block_parser.rb +1 -1
  32. data/lib/rdoc/rd/inline_parser.rb +1 -1
  33. data/lib/rdoc/rdoc.rb +5 -3
  34. data/lib/rdoc/ruby_lex.rb +3 -3
  35. data/lib/rdoc/ruby_token.rb +7 -7
  36. data/lib/rdoc/single_class.rb +4 -0
  37. data/lib/rdoc/stats.rb +4 -0
  38. data/lib/rdoc/stats/normal.rb +22 -11
  39. data/lib/rdoc/task.rb +1 -1
  40. data/lib/rdoc/test_case.rb +1 -1
  41. data/lib/rdoc/text.rb +9 -0
  42. data/lib/rdoc/token_stream.rb +1 -1
  43. data/test/test_rdoc_context.rb +2 -0
  44. data/test/test_rdoc_encoding.rb +23 -0
  45. data/test/test_rdoc_generator_darkfish.rb +2 -2
  46. data/test/test_rdoc_generator_json_index.rb +55 -0
  47. data/test/test_rdoc_generator_markup.rb +1 -1
  48. data/test/test_rdoc_generator_pot.rb +91 -0
  49. data/test/test_rdoc_generator_pot_po.rb +51 -0
  50. data/test/test_rdoc_generator_pot_po_entry.rb +139 -0
  51. data/test/test_rdoc_i18n_locale.rb +73 -0
  52. data/test/test_rdoc_i18n_text.rb +123 -0
  53. data/test/test_rdoc_markup_attribute_manager.rb +6 -0
  54. data/test/test_rdoc_markup_heading.rb +4 -4
  55. data/test/test_rdoc_markup_pre_process.rb +1 -1
  56. data/test/test_rdoc_markup_to_html.rb +46 -26
  57. data/test/test_rdoc_markup_to_html_snippet.rb +8 -7
  58. data/test/test_rdoc_markup_to_label.rb +4 -4
  59. data/test/test_rdoc_method_attr.rb +31 -1
  60. data/test/test_rdoc_normal_class.rb +4 -4
  61. data/test/test_rdoc_options.rb +19 -0
  62. data/test/test_rdoc_parser.rb +16 -1
  63. data/test/test_rdoc_parser_c.rb +31 -1
  64. data/test/test_rdoc_parser_changelog.rb +1 -1
  65. data/test/test_rdoc_parser_markdown.rb +1 -1
  66. data/test/test_rdoc_parser_rd.rb +1 -1
  67. data/test/test_rdoc_parser_ruby.rb +22 -25
  68. data/test/test_rdoc_parser_simple.rb +1 -1
  69. data/test/test_rdoc_rd_block_parser.rb +3 -1
  70. data/test/test_rdoc_rdoc.rb +24 -3
  71. data/test/test_rdoc_ruby_lex.rb +11 -0
  72. data/test/test_rdoc_rubygems_hook.rb +0 -3
  73. data/test/test_rdoc_single_class.rb +13 -5
  74. data/test/test_rdoc_stats.rb +55 -0
  75. data/test/test_rdoc_task.rb +1 -0
  76. metadata +18 -7
@@ -130,6 +130,9 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
130
130
  assert_equal(["cat ", @tt_on, "and", @tt_off, " dog"],
131
131
  @am.flow("cat +and+ dog"))
132
132
 
133
+ assert_equal(["cat ", @tt_on, "X::Y", @tt_off, " dog"],
134
+ @am.flow("cat +X::Y+ dog"))
135
+
133
136
  assert_equal(["cat ", @bold_on, "a_b_c", @bold_off, " dog"],
134
137
  @am.flow("cat *a_b_c* dog"))
135
138
 
@@ -138,6 +141,9 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
138
141
 
139
142
  assert_equal(["cat ", @em_on, "_", @em_off, " dog"],
140
143
  @am.flow("cat ___ dog"))
144
+
145
+ assert_equal(["cat and ", @em_on, "5", @em_off, " dogs"],
146
+ @am.flow("cat and _5_ dogs"))
141
147
  end
142
148
 
143
149
  def test_bold
@@ -9,16 +9,16 @@ class TestRDocMarkupHeading < RDoc::TestCase
9
9
  end
10
10
 
11
11
  def test_aref
12
- assert_equal 'label-Hello+Friend%21', @h.aref
12
+ assert_equal 'label-Hello+Friend-21', @h.aref
13
13
  end
14
14
 
15
15
  def test_label
16
- assert_equal 'label-Hello+Friend%21', @h.label
17
- assert_equal 'label-Hello+Friend%21', @h.label(nil)
16
+ assert_equal 'label-Hello+Friend-21', @h.label
17
+ assert_equal 'label-Hello+Friend-21', @h.label(nil)
18
18
 
19
19
  context = RDoc::NormalClass.new 'Foo'
20
20
 
21
- assert_equal 'class-Foo-label-Hello+Friend%21', @h.label(context)
21
+ assert_equal 'class-Foo-label-Hello+Friend-21', @h.label(context)
22
22
  end
23
23
 
24
24
  def test_plain_html
@@ -17,7 +17,7 @@ class TestRDocMarkupPreProcess < RDoc::TestCase
17
17
  def teardown
18
18
  super
19
19
 
20
- @tempfile.close
20
+ @tempfile.close!
21
21
  end
22
22
 
23
23
  def test_class_register
@@ -24,7 +24,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
24
24
 
25
25
  def accept_heading
26
26
  links = '<span><a href="#label-Hello">&para;</a> ' +
27
- '<a href="#documentation">&uarr;</a></span>'
27
+ '<a href="#top">&uarr;</a></span>'
28
28
  expected = "\n<h5 id=\"label-Hello\">Hello#{links}</h5>\n"
29
29
 
30
30
  assert_equal expected, @to.res.join
@@ -32,35 +32,35 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
32
32
 
33
33
  def accept_heading_1
34
34
  links = '<span><a href="#label-Hello">&para;</a> ' +
35
- '<a href="#documentation">&uarr;</a></span>'
35
+ '<a href="#top">&uarr;</a></span>'
36
36
 
37
37
  assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", @to.res.join
38
38
  end
39
39
 
40
40
  def accept_heading_2
41
41
  links = '<span><a href="#label-Hello">&para;</a> ' +
42
- '<a href="#documentation">&uarr;</a></span>'
42
+ '<a href="#top">&uarr;</a></span>'
43
43
 
44
44
  assert_equal "\n<h2 id=\"label-Hello\">Hello#{links}</h2>\n", @to.res.join
45
45
  end
46
46
 
47
47
  def accept_heading_3
48
48
  links = '<span><a href="#label-Hello">&para;</a> ' +
49
- '<a href="#documentation">&uarr;</a></span>'
49
+ '<a href="#top">&uarr;</a></span>'
50
50
 
51
51
  assert_equal "\n<h3 id=\"label-Hello\">Hello#{links}</h3>\n", @to.res.join
52
52
  end
53
53
 
54
54
  def accept_heading_4
55
55
  links = '<span><a href="#label-Hello">&para;</a> ' +
56
- '<a href="#documentation">&uarr;</a></span>'
56
+ '<a href="#top">&uarr;</a></span>'
57
57
 
58
58
  assert_equal "\n<h4 id=\"label-Hello\">Hello#{links}</h4>\n", @to.res.join
59
59
  end
60
60
 
61
61
  def accept_heading_b
62
62
  links = '<span><a href="#label-Hello">&para;</a> ' +
63
- '<a href="#documentation">&uarr;</a></span>'
63
+ '<a href="#top">&uarr;</a></span>'
64
64
  inner = "<strong>Hello</strong>"
65
65
 
66
66
  assert_equal "\n<h1 id=\"label-Hello\">#{inner}#{links}</h1>\n",
@@ -69,7 +69,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
69
69
 
70
70
  def accept_heading_suppressed_crossref
71
71
  links = '<span><a href="#label-Hello">&para;</a> ' +
72
- '<a href="#documentation">&uarr;</a></span>'
72
+ '<a href="#top">&uarr;</a></span>'
73
73
 
74
74
  assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", @to.res.join
75
75
  end
@@ -292,7 +292,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
292
292
  end
293
293
 
294
294
  def accept_verbatim
295
- assert_equal "\n<pre>hi\n world</pre>\n", @to.res.join
295
+ assert_equal "\n<pre class=\"ruby\"><span class=\"ruby-identifier\">hi</span>\n <span class=\"ruby-identifier\">world</span>\n</pre>\n", @to.res.join
296
296
  end
297
297
 
298
298
  def end_accepting
@@ -348,7 +348,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
348
348
  @to.accept_heading @RM::Heading.new(7, 'Hello')
349
349
 
350
350
  links = '<span><a href="#label-Hello">&para;</a> ' +
351
- '<a href="#documentation">&uarr;</a></span>'
351
+ '<a href="#top">&uarr;</a></span>'
352
352
 
353
353
  assert_equal "\n<h6 id=\"label-Hello\">Hello#{links}</h6>\n", @to.res.join
354
354
  end
@@ -360,7 +360,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
360
360
  @to.accept_heading head(1, 'Hello')
361
361
 
362
362
  links = '<span><a href="#class-Foo-label-Hello">&para;</a> ' +
363
- '<a href="#documentation">&uarr;</a></span>'
363
+ '<a href="#top">&uarr;</a></span>'
364
364
 
365
365
  assert_equal "\n<h1 id=\"class-Foo-label-Hello\">Hello#{links}</h1>\n",
366
366
  @to.res.join
@@ -373,7 +373,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
373
373
  @to.accept_heading @RM::Heading.new(1, 'Hello')
374
374
 
375
375
  links = '<span><a href="#method-i-foo-label-Hello">&para;</a> ' +
376
- '<a href="#documentation">&uarr;</a></span>'
376
+ '<a href="#top">&uarr;</a></span>'
377
377
 
378
378
  assert_equal "\n<h1 id=\"method-i-foo-label-Hello\">Hello#{links}</h1>\n",
379
379
  @to.res.join
@@ -404,7 +404,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
404
404
 
405
405
  @to.accept_heading @RM::Heading.new(1, 'Hello')
406
406
 
407
- assert_equal "\n<h1>Hello<span><a href=\"#label-Hello\">&para;</a> <a href=\"#documentation\">&uarr;</a></span></h1>\n", @to.res.join
407
+ assert_equal "\n<h1>Hello<span><a href=\"#label-Hello\">&para;</a> <a href=\"#top\">&uarr;</a></span></h1>\n", @to.res.join
408
408
  end
409
409
 
410
410
  def test_accept_heading_output_decoration_with_pipe
@@ -444,8 +444,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
444
444
 
445
445
  expected = <<-EXPECTED
446
446
 
447
- <pre>#{inner}
448
- </pre>
447
+ <pre>#{inner}</pre>
449
448
  EXPECTED
450
449
 
451
450
  assert_equal expected, @to.res.join
@@ -604,8 +603,9 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
604
603
  <ul><li>
605
604
  <p>one</p>
606
605
 
607
- <pre>verb1
608
- verb2</pre>
606
+ <pre class=\"ruby\"><span class=\"ruby-identifier\">verb1</span>
607
+ <span class=\"ruby-identifier\">verb2</span>
608
+ </pre>
609
609
  </li><li>
610
610
  <p>two</p>
611
611
  </li></ul>
@@ -615,16 +615,36 @@ verb2</pre>
615
615
  end
616
616
 
617
617
  def test_parseable_eh
618
- assert @to.parseable?('def x() end'), 'def'
619
- assert @to.parseable?('class C end'), 'class'
620
- assert @to.parseable?('module M end'), 'module'
621
- assert @to.parseable?('a # => blah'), '=>'
622
- assert @to.parseable?('x { |y| ... }'), '{ |x|'
623
- assert @to.parseable?('x do |y| ... end'), 'do |x|'
624
- refute @to.parseable?('* 1'), '* 1'
625
- refute @to.parseable?('# only a comment'), '# only a comment'
626
- refute @to.parseable?('<% require "foo" %>'), 'ERB'
627
- refute @to.parseable?('class="foo"'), 'HTML class'
618
+ valid_syntax = [
619
+ 'def x() end',
620
+ 'def x; end',
621
+ 'class C; end',
622
+ "module M end",
623
+ 'a # => blah',
624
+ 'x { |y| nil }',
625
+ 'x do |y| nil end',
626
+ '# only a comment',
627
+ 'require "foo"',
628
+ 'cls="foo"'
629
+ ]
630
+ invalid_syntax = [
631
+ 'def x end',
632
+ 'class C end',
633
+ 'class C < end',
634
+ 'module M < C end',
635
+ 'a=># blah',
636
+ 'x { |y| ... }',
637
+ 'x do |y| ... end',
638
+ '// only a comment',
639
+ '<% require "foo" %>',
640
+ 'class="foo"'
641
+ ]
642
+ valid_syntax.each do |t|
643
+ assert @to.parseable?(t), "valid syntax considered invalid: #{t}"
644
+ end
645
+ invalid_syntax.each do |t|
646
+ refute @to.parseable?(t), "invalid syntax considered valid: #{t}"
647
+ end
628
648
  end
629
649
 
630
650
  def test_to_html
@@ -309,7 +309,7 @@ class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase
309
309
  end
310
310
 
311
311
  def accept_verbatim
312
- assert_equal "\n<pre>hi\n world</pre>\n", @to.res.join
312
+ assert_equal "\n<pre class=\"ruby\"><span class=\"ruby-identifier\">hi</span>\n <span class=\"ruby-identifier\">world</span>\n</pre>\n", @to.res.join
313
313
  assert_equal 10, @to.characters
314
314
  end
315
315
 
@@ -427,8 +427,7 @@ class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase
427
427
 
428
428
  expected = <<-EXPECTED
429
429
 
430
- <pre>#{inner}
431
- </pre>
430
+ <pre>#{inner}</pre>
432
431
  EXPECTED
433
432
 
434
433
  assert_equal expected, @to.res.join
@@ -588,8 +587,9 @@ This routine modifies its +comment+ parameter.
588
587
  expected = <<-EXPECTED
589
588
  <p>Look for directives in a normal comment block:
590
589
 
591
- <pre># :stopdoc:
592
- #{inner}</pre>
590
+ <pre class=\"ruby\"><span class=\"ruby-comment\"># :stopdoc:</span>
591
+ <span class=\"ruby-comment\">#{inner}</span>
592
+ </pre>
593
593
  EXPECTED
594
594
 
595
595
  actual = @to.convert rdoc
@@ -665,8 +665,9 @@ This routine modifies its +comment+ parameter.
665
665
  expected = <<-EXPECTED
666
666
  <p>one
667
667
 
668
- <pre>verb1
669
- verb2</pre>
668
+ <pre class=\"ruby\"><span class=\"ruby-identifier\">verb1</span>
669
+ <span class=\"ruby-identifier\">verb2</span>
670
+ </pre>
670
671
  <p>two
671
672
 
672
673
  EXPECTED
@@ -82,8 +82,8 @@ class TestRDocMarkupToLabel < RDoc::Markup::FormatterTestCase
82
82
  assert_equal 'some_method', @to.convert('some_method')
83
83
  assert_equal 'some_method', @to.convert('\\some_method')
84
84
 
85
- assert_equal '%23some_method', @to.convert('#some_method')
86
- assert_equal '%23some_method', @to.convert('\\#some_method')
85
+ assert_equal '23some_method', @to.convert('#some_method')
86
+ assert_equal '23some_method', @to.convert('\\#some_method')
87
87
  end
88
88
 
89
89
  def test_convert_em
@@ -92,11 +92,11 @@ class TestRDocMarkupToLabel < RDoc::Markup::FormatterTestCase
92
92
  end
93
93
 
94
94
  def test_convert_em_dash # for HTML conversion
95
- assert_equal '--', @to.convert('--')
95
+ assert_equal '-', @to.convert('--')
96
96
  end
97
97
 
98
98
  def test_convert_escape
99
- assert_equal 'a+%3E+b', @to.convert('a > b')
99
+ assert_equal 'a+-3E+b', @to.convert('a > b')
100
100
  end
101
101
 
102
102
  def test_convert_tidylink
@@ -7,7 +7,6 @@ class TestRDocMethodAttr < XrefTestCase
7
7
  end
8
8
 
9
9
  def test_block_params_equal
10
-
11
10
  m = RDoc::MethodAttr.new(nil, 'foo')
12
11
 
13
12
  m.block_params = ''
@@ -148,11 +147,42 @@ class TestRDocMethodAttr < XrefTestCase
148
147
  assert_equal expected, @c1_m.search_record
149
148
  end
150
149
 
150
+ def test_spaceship
151
+ assert_nil @c1_m.<=>(RDoc::CodeObject.new)
152
+ end
153
+
151
154
  def test_equals2
152
155
  assert_equal @c1_m, @c1_m
153
156
  refute_equal @c1_m, @parent_m
154
157
  end
155
158
 
159
+ def test_pretty_print
160
+ temp_dir do |tmpdir|
161
+ s = RDoc::RI::Store.new tmpdir
162
+ s.rdoc = @rdoc
163
+
164
+ top_level = s.add_file 'file.rb'
165
+ meth_bang = RDoc::AnyMethod.new nil, 'method!'
166
+ meth_bang.record_location top_level
167
+
168
+ meth_bang_alias = RDoc::Alias.new nil, 'method!', 'method_bang', ''
169
+ meth_bang_alias.record_location top_level
170
+
171
+ klass = top_level.add_class RDoc::NormalClass, 'Object'
172
+ klass.add_method meth_bang
173
+
174
+ meth_bang.add_alias meth_bang_alias, klass
175
+
176
+ s.save
177
+
178
+ meth_alias_from_store = s.load_method 'Object', '#method_bang'
179
+
180
+ expected = "[RDoc::AnyMethod Object#method_bang public alias for method!]"
181
+ actual = mu_pp meth_alias_from_store
182
+ assert_equal expected, actual
183
+ end
184
+ end
185
+
156
186
  def test_to_s
157
187
  assert_equal 'RDoc::AnyMethod: C1#m', @c1_m.to_s
158
188
  assert_equal 'RDoc::AnyMethod: C2#b', @c2_b.to_s
@@ -15,8 +15,8 @@ class TestRDocNormalClass < XrefTestCase
15
15
 
16
16
  def test_ancestors_multilevel
17
17
  c1 = @top_level.add_class RDoc::NormalClass, 'Outer'
18
- c2 = @top_level.add_class RDoc::NormalClass, 'Middle', c1
19
- c3 = @top_level.add_class RDoc::NormalClass, 'Inner', c2
18
+ c2 = @top_level.add_class RDoc::NormalClass, 'Middle', c1.full_name
19
+ c3 = @top_level.add_class RDoc::NormalClass, 'Inner', c2.full_name
20
20
 
21
21
  assert_equal [c2, c1, 'Object'], c3.ancestors
22
22
  end
@@ -30,8 +30,8 @@ class TestRDocNormalClass < XrefTestCase
30
30
  incl = RDoc::Include.new 'Incl', ''
31
31
 
32
32
  c1 = @top_level.add_class RDoc::NormalClass, 'Outer'
33
- c2 = @top_level.add_class RDoc::NormalClass, 'Middle', c1
34
- c3 = @top_level.add_class RDoc::NormalClass, 'Inner', c2
33
+ c2 = @top_level.add_class RDoc::NormalClass, 'Middle', c1.full_name
34
+ c3 = @top_level.add_class RDoc::NormalClass, 'Inner', c2.full_name
35
35
  c3.add_include incl
36
36
 
37
37
  assert_equal [incl.name, c2], c3.direct_ancestors
@@ -67,6 +67,9 @@ class TestRDocOptions < RDoc::TestCase
67
67
  'exclude' => [],
68
68
  'hyperlink_all' => false,
69
69
  'line_numbers' => false,
70
+ 'locale' => nil,
71
+ 'locale_dir' => 'locale',
72
+ 'locale_name' => nil,
70
73
  'main_page' => nil,
71
74
  'markup' => 'rdoc',
72
75
  'output_decoration' => true,
@@ -334,6 +337,18 @@ rdoc_include:
334
337
  e.message
335
338
  end
336
339
 
340
+ def test_parse_h
341
+ out, = capture_io do
342
+ begin
343
+ @options.parse %w[-h]
344
+ rescue SystemExit
345
+ end
346
+ end
347
+
348
+ assert_equal 1, out.scan(/HTML generator options:/).length
349
+ assert_equal 1, out.scan(/ri generator options:/). length
350
+ end
351
+
337
352
  def test_parse_help
338
353
  out, = capture_io do
339
354
  begin
@@ -743,5 +758,9 @@ rdoc_include:
743
758
  assert out.include?(RDoc::VERSION)
744
759
  end
745
760
 
761
+ def test_visibility
762
+ @options.visibility = :all
763
+ assert_equal :private, @options.visibility
764
+ end
746
765
  end
747
766
 
@@ -15,6 +15,19 @@ class TestRDocParser < RDoc::TestCase
15
15
  @options = RDoc::Options.new
16
16
  end
17
17
 
18
+ def test_class_binary_eh_ISO_2022_JP
19
+ iso_2022_jp = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.rd"
20
+
21
+ open iso_2022_jp, 'wb' do |io|
22
+ io.write "# coding: ISO-2022-JP\n"
23
+ io.write ":\e$B%3%^%s%I\e(B:\n"
24
+ end
25
+
26
+ refute @RP.binary? iso_2022_jp
27
+ ensure
28
+ File.unlink iso_2022_jp
29
+ end
30
+
18
31
  def test_class_binary_eh_marshal
19
32
  marshal = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.marshal"
20
33
  open marshal, 'wb' do |io|
@@ -96,7 +109,7 @@ class TestRDocParser < RDoc::TestCase
96
109
  def test_class_for_forbidden
97
110
  skip 'chmod not supported' if Gem.win_platform?
98
111
 
99
- Tempfile.open 'forbidden' do |io|
112
+ tf = Tempfile.open 'forbidden' do |io|
100
113
  begin
101
114
  File.chmod 0000, io.path
102
115
  forbidden = @store.add_file io.path
@@ -107,7 +120,9 @@ class TestRDocParser < RDoc::TestCase
107
120
  ensure
108
121
  File.chmod 0400, io.path
109
122
  end
123
+ io
110
124
  end
125
+ tf.close! if tf.respond_to? :close!
111
126
  end
112
127
 
113
128
  def test_class_for_modeline
@@ -58,7 +58,7 @@ class TestRDocParserC < RDoc::TestCase
58
58
  def teardown
59
59
  super
60
60
 
61
- @tempfile.close
61
+ @tempfile.close!
62
62
  end
63
63
 
64
64
  def test_class_can_parse
@@ -1246,6 +1246,36 @@ Init_Foo(void) {
1246
1246
  assert_equal "a comment for Foo#bar", bar.comment.text
1247
1247
  end
1248
1248
 
1249
+ def test_find_body_macro
1250
+ content = <<-EOF
1251
+ /*
1252
+ * a comment for other_function
1253
+ */
1254
+ DLL_LOCAL VALUE
1255
+ other_function() {
1256
+ }
1257
+
1258
+ void
1259
+ Init_Foo(void) {
1260
+ VALUE foo = rb_define_class("Foo", rb_cObject);
1261
+
1262
+ rb_define_method(foo, "my_method", other_function, 0);
1263
+ }
1264
+ EOF
1265
+
1266
+ klass = util_get_class content, 'foo'
1267
+ other_function = klass.method_list.first
1268
+
1269
+ assert_equal 'my_method', other_function.name
1270
+ assert_equal "a comment for other_function",
1271
+ other_function.comment.text
1272
+ assert_equal '()', other_function.params
1273
+
1274
+ code = other_function.token_stream.first.text
1275
+
1276
+ assert_equal "DLL_LOCAL VALUE\nother_function() {\n}", code
1277
+ end
1278
+
1249
1279
  def test_find_modifiers_call_seq
1250
1280
  comment = RDoc::Comment.new <<-COMMENT
1251
1281
  call-seq: