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.

@@ -146,7 +146,7 @@ http://rubyforge.org/tracker/?atid=2472&group_id=627&func=browse
146
146
  # Strips leading and trailing \n characters from +text+
147
147
 
148
148
  def strip_newlines text
149
- text.gsub(/\A\n*(.*?)\n*\z/m, '\1')
149
+ text.gsub(/\A\n*(.*?)\n*\z/m) do $1 end # block preserves String encoding
150
150
  end
151
151
 
152
152
  ##
@@ -97,6 +97,48 @@ method(a, b) { |c, d| ... }
97
97
  assert_nil m.name
98
98
  end
99
99
 
100
+ def test_param_list_block_params
101
+ m = RDoc::AnyMethod.new nil, 'method'
102
+ m.parent = @c1
103
+
104
+ m.block_params = 'c, d'
105
+
106
+ assert_equal %w[c d], m.param_list
107
+ end
108
+
109
+ def test_param_list_call_seq
110
+ m = RDoc::AnyMethod.new nil, 'method'
111
+ m.parent = @c1
112
+
113
+ call_seq = <<-SEQ
114
+ method(a) { |c| ... }
115
+ method(a, b) { |c, d| ... }
116
+ SEQ
117
+
118
+ m.call_seq = call_seq
119
+
120
+ assert_equal %w[a b c d], m.param_list
121
+ end
122
+
123
+ def test_param_list_params
124
+ m = RDoc::AnyMethod.new nil, 'method'
125
+ m.parent = @c1
126
+
127
+ m.params = '(a, b)'
128
+
129
+ assert_equal %w[a b], m.param_list
130
+ end
131
+
132
+ def test_param_list_params_block_params
133
+ m = RDoc::AnyMethod.new nil, 'method'
134
+ m.parent = @c1
135
+
136
+ m.params = '(a, b)'
137
+ m.block_params = 'c, d'
138
+
139
+ assert_equal %w[a b c d], m.param_list
140
+ end
141
+
100
142
  def test_param_seq
101
143
  m = RDoc::AnyMethod.new nil, 'method'
102
144
  m.parent = @c1
@@ -117,6 +159,21 @@ method(a, b) { |c, d| ... }
117
159
  assert_equal '(a, b) { |c, d| ... }', m.param_seq
118
160
  end
119
161
 
162
+ def test_param_seq_call_seq
163
+ m = RDoc::AnyMethod.new nil, 'method'
164
+ m.parent = @c1
165
+
166
+ call_seq = <<-SEQ
167
+ method(a) { |c| ... }
168
+ method(a, b) { |c, d| ... }
169
+ SEQ
170
+
171
+ m.call_seq = call_seq
172
+
173
+ assert_equal '(a, b) { |c, d| }', m.param_seq
174
+
175
+ end
176
+
120
177
  def test_parent_name
121
178
  assert_equal 'C1', @c1.method_list.first.parent_name
122
179
  assert_equal 'C1', @c1.method_list.last.parent_name
@@ -30,6 +30,30 @@ class TestRDocCodeObject < XrefTestCase
30
30
  assert_equal 'I am a comment', @co.comment
31
31
  end
32
32
 
33
+ def test_comment_equals_encoding
34
+ refute_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check'
35
+
36
+ input = 'text'
37
+ input.force_encoding Encoding::UTF_8
38
+
39
+ @co.comment = input
40
+
41
+ assert_equal 'text', @co.comment
42
+ assert_equal Encoding::UTF_8, @co.comment.encoding
43
+ end
44
+
45
+ def test_comment_equals_encoding_blank
46
+ refute_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check'
47
+
48
+ input = ''
49
+ input.force_encoding Encoding::UTF_8
50
+
51
+ @co.comment = input
52
+
53
+ assert_equal '', @co.comment
54
+ assert_equal Encoding::UTF_8, @co.comment.encoding
55
+ end
56
+
33
57
  def test_document_children_equals
34
58
  @co.document_children = false
35
59
  refute @co.document_children
@@ -0,0 +1,225 @@
1
+ require 'rubygems'
2
+ require 'rdoc/markup/formatter_test_case'
3
+ require 'rdoc/markup/to_tt_only'
4
+ require 'minitest/autorun'
5
+
6
+ class TestRDocMarkupToTtOnly < RDoc::Markup::FormatterTestCase
7
+
8
+ add_visitor_tests
9
+
10
+ def setup
11
+ super
12
+
13
+ @to = RDoc::Markup::ToTtOnly.new
14
+ end
15
+
16
+ def accept_blank_line
17
+ assert_empty @to.end_accepting
18
+ end
19
+
20
+ def accept_heading
21
+ assert_empty @to.end_accepting
22
+ end
23
+
24
+ def accept_list_end_bullet
25
+ assert_empty @to.res
26
+ end
27
+
28
+ def accept_list_end_label
29
+ assert_empty @to.res
30
+ end
31
+
32
+ def accept_list_end_lalpha
33
+ assert_empty @to.res
34
+ end
35
+
36
+ def accept_list_end_note
37
+ assert_empty @to.res
38
+ end
39
+
40
+ def accept_list_end_number
41
+ assert_empty @to.res
42
+ end
43
+
44
+ def accept_list_end_ualpha
45
+ assert_empty @to.res
46
+ end
47
+
48
+ def accept_list_item_end_bullet
49
+ assert_empty @to.res
50
+ end
51
+
52
+ def accept_list_item_end_label
53
+ assert_empty @to.res
54
+ end
55
+
56
+ def accept_list_item_end_lalpha
57
+ assert_empty @to.res
58
+ end
59
+
60
+ def accept_list_item_end_note
61
+ assert_empty @to.res
62
+ end
63
+
64
+ def accept_list_item_end_number
65
+ assert_empty @to.res
66
+ end
67
+
68
+ def accept_list_item_end_ualpha
69
+ assert_empty @to.res
70
+ end
71
+
72
+ def accept_list_item_start_bullet
73
+ assert_empty @to.res
74
+ end
75
+
76
+ def accept_list_item_start_label
77
+ assert_empty @to.res
78
+ end
79
+
80
+ def accept_list_item_start_lalpha
81
+ assert_empty @to.res
82
+ end
83
+
84
+ def accept_list_item_start_note
85
+ assert_empty @to.res
86
+ end
87
+
88
+ def accept_list_item_start_number
89
+ assert_empty @to.res
90
+ end
91
+
92
+ def accept_list_item_start_ualpha
93
+ assert_empty @to.res
94
+ end
95
+
96
+ def accept_list_start_bullet
97
+ assert_empty @to.res
98
+ end
99
+
100
+ def accept_list_start_label
101
+ assert_empty @to.res
102
+ end
103
+
104
+ def accept_list_start_lalpha
105
+ assert_empty @to.res
106
+ end
107
+
108
+ def accept_list_start_note
109
+ assert_empty @to.res
110
+ end
111
+
112
+ def accept_list_start_number
113
+ assert_empty @to.res
114
+ end
115
+
116
+ def accept_list_start_ualpha
117
+ assert_empty @to.res
118
+ end
119
+
120
+ def accept_paragraph
121
+ assert_empty @to.end_accepting
122
+ end
123
+
124
+ def accept_raw
125
+ assert_empty @to.end_accepting
126
+ end
127
+
128
+ def accept_rule
129
+ assert_empty @to.end_accepting
130
+ end
131
+
132
+ def accept_verbatim
133
+ assert_empty @to.end_accepting
134
+ end
135
+
136
+ def end_accepting
137
+ assert_equal %w[hi], @to.end_accepting
138
+ end
139
+
140
+ def start_accepting
141
+ assert_empty @to.end_accepting
142
+ end
143
+
144
+ def accept_heading_1
145
+ assert_empty @to.end_accepting
146
+ end
147
+
148
+ def accept_heading_2
149
+ assert_empty @to.end_accepting
150
+ end
151
+
152
+ def accept_heading_3
153
+ assert_empty @to.end_accepting
154
+ end
155
+
156
+ def accept_heading_4
157
+ assert_empty @to.end_accepting
158
+ end
159
+
160
+ def accept_heading_indent
161
+ assert_empty @to.end_accepting
162
+ end
163
+
164
+ def accept_heading_b
165
+ assert_empty @to.end_accepting
166
+ end
167
+
168
+ def accept_heading_suppressed_crossref
169
+ assert_empty @to.end_accepting
170
+ end
171
+
172
+ def accept_list_item_start_note_2
173
+ assert_equal [nil, 'teletype', nil], @to.res
174
+ end
175
+
176
+ def accept_paragraph_b
177
+ assert_empty @to.end_accepting
178
+ end
179
+
180
+ def accept_paragraph_i
181
+ assert_empty @to.end_accepting
182
+ end
183
+
184
+ def accept_paragraph_indent
185
+ assert_empty @to.end_accepting
186
+ end
187
+
188
+ def accept_paragraph_plus
189
+ assert_equal %w[teletype], @to.end_accepting
190
+ end
191
+
192
+ def accept_paragraph_star
193
+ assert_empty @to.end_accepting
194
+ end
195
+
196
+ def accept_paragraph_underscore
197
+ assert_empty @to.end_accepting
198
+ end
199
+
200
+ def accept_paragraph_wrap
201
+ assert_empty @to.end_accepting
202
+ end
203
+
204
+ def accept_rule_indent
205
+ assert_empty @to.end_accepting
206
+ end
207
+
208
+ def accept_verbatim_indent
209
+ assert_empty @to.end_accepting
210
+ end
211
+
212
+ def accept_verbatim_big_indent
213
+ assert_empty @to.end_accepting
214
+ end
215
+
216
+ def list_nested
217
+ assert_empty @to.end_accepting
218
+ end
219
+
220
+ def list_verbatim
221
+ assert_empty @to.end_accepting
222
+ end
223
+
224
+ end
225
+
@@ -13,5 +13,11 @@ class TestRDocNormalClass < XrefTestCase
13
13
  assert_equal [incl.name, klass], sub_klass.ancestors
14
14
  end
15
15
 
16
+ def test_definition
17
+ c = RDoc::NormalClass.new 'C'
18
+
19
+ assert_equal 'class C', c.definition
20
+ end
21
+
16
22
  end
17
23
 
@@ -23,6 +23,12 @@ class TestRDocNormalModule < XrefTestCase
23
23
  assert_equal [mod2, incl.name], mod.ancestors
24
24
  end
25
25
 
26
+ def test_definition
27
+ m = RDoc::NormalModule.new 'M'
28
+
29
+ assert_equal 'module M', m.definition
30
+ end
31
+
26
32
  def test_module_eh
27
33
  assert @mod.module?
28
34
  end
@@ -66,6 +66,25 @@ file 'unreadable' not readable
66
66
  assert_equal expected, @options.generator_descriptions
67
67
  end
68
68
 
69
+ def test_parse_coverage
70
+ @options.parse %w[--dcov]
71
+
72
+ assert @options.coverage_report
73
+ assert @options.force_update
74
+ end
75
+
76
+ def test_parse_coverage_no
77
+ @options.parse %w[--no-dcov]
78
+
79
+ refute @options.coverage_report
80
+ end
81
+
82
+ def test_parse_coverage_level_1
83
+ @options.parse %w[--dcov=1]
84
+
85
+ assert_equal 1, @options.coverage_report
86
+ end
87
+
69
88
  def test_parse_dash_p
70
89
  out, err = capture_io do
71
90
  @options.parse %w[-p]
@@ -101,6 +101,7 @@ void Init_Blah(void) {
101
101
  assert_equal 'accessor', accessor.name
102
102
  assert_equal 'RW', accessor.rw
103
103
  assert_equal 'This is an accessor', accessor.comment
104
+ assert_equal @top_level, accessor.file
104
105
 
105
106
  reader = attrs.shift
106
107
  assert_equal 'reader', reader.name
@@ -134,6 +135,7 @@ void Init_Blah(void) {
134
135
  assert_equal 'accessor', accessor.name
135
136
  assert_equal 'RW', accessor.rw
136
137
  assert_equal 'This is an accessor', accessor.comment
138
+ assert_equal @top_level, accessor.file
137
139
  end
138
140
 
139
141
  def test_do_aliases
@@ -159,6 +161,9 @@ void Init_Blah(void) {
159
161
  assert_equal 2, methods.length
160
162
  assert_equal 'bleh', methods.last.name
161
163
  assert_equal 'blah', methods.last.is_alias_for.name
164
+
165
+ assert_equal @top_level, methods.last.is_alias_for.file
166
+ assert_equal @top_level, methods.last.file
162
167
  end
163
168
 
164
169
  def test_do_aliases_singleton
@@ -339,6 +344,8 @@ void Init_foo(){
339
344
  constants = klass.constants
340
345
  assert !klass.constants.empty?
341
346
 
347
+ assert_equal @top_level, constants.first.file
348
+
342
349
  constants = constants.map { |c| [c.name, c.value, c.comment] }
343
350
 
344
351
  assert_equal ['PERFECT', '300', 'The highest possible score in bowling '],
@@ -743,9 +750,21 @@ commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
743
750
  end
744
751
 
745
752
  def test_handle_method
753
+ parser = util_parser "Document-method: Object#m\n blah */"
754
+
755
+ parser.handle_method 'method', 'rb_cObject', 'm', 'rb_m', 2
756
+
757
+ m = @top_level.find_module_named('Object').method_list.first
758
+
759
+ assert_equal 'm', m.name
760
+ assert_equal '(p1, p2)', m.params
761
+ assert_equal @top_level, m.file
762
+ end
763
+
764
+ def test_handle_method_args
746
765
  parser = util_parser "Document-method: BasicObject#==\n blah */"
747
766
 
748
- parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', 1
767
+ parser.handle_method 'method', 'rb_cBasicObject', '==', 'rb_obj_equal', 2
749
768
 
750
769
  bo = @top_level.find_module_named 'BasicObject'
751
770
 
@@ -753,7 +772,7 @@ commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
753
772
 
754
773
  equals2 = bo.method_list.first
755
774
 
756
- assert_equal '==', equals2.name
775
+ assert_equal '(p1, p2)', equals2.params
757
776
  end
758
777
 
759
778
  def test_handle_method_initialize
@@ -772,6 +791,16 @@ commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
772
791
  assert_equal :public, new.visibility
773
792
  end
774
793
 
794
+ def test_handle_method_star_args
795
+ parser = util_parser "Document-method: Object#m\n blah */"
796
+
797
+ parser.handle_method 'method', 'rb_cObject', 'm', 'rb_m', -1
798
+
799
+ m = @top_level.find_module_named('Object').method_list.first
800
+
801
+ assert_equal '(*args)', m.params
802
+ end
803
+
775
804
  def test_look_for_directives_in
776
805
  parser = util_parser ''
777
806