Skip to content
Newer
Older
100644 696 lines (494 sloc) 16.9 KB
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
1 require 'rubygems'
04a96ea @drbrain Updates for 1.9
drbrain authored Apr 1, 2010
2 require 'minitest/autorun'
3 require File.expand_path '../xref_test_case', __FILE__
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
4
5 class TestRDocContext < XrefTestCase
6
7 def setup
8 super
9
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
10 @context = RDoc::Context.new
11 end
12
13 def test_initialize
14 assert_empty @context.in_files
15 assert_equal 'unknown', @context.name
16 assert_equal '', @context.comment
17 assert_equal nil, @context.parent
18 assert_equal :public, @context.visibility
19 assert_equal 1, @context.sections.length
0b45495 @drbrain Add the :category: directive which works like :section: but only for …
drbrain authored May 24, 2011
20 assert_equal nil, @context.temporary_section
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
21
22 assert_empty @context.classes_hash
23 assert_empty @context.modules_hash
24
25 assert_empty @context.method_list
26 assert_empty @context.attributes
27 assert_empty @context.aliases
28 assert_empty @context.requires
29 assert_empty @context.includes
30 assert_empty @context.constants
31 end
32
33 def test_add_alias
34 as = RDoc::Alias.new nil, 'old_name', 'new_name', 'comment'
35
36 @context.add_alias as
37
54dbcf7 @drbrain Import various improvements from Thierry Lambert. See History.txt.
drbrain authored Sep 10, 2010
38 assert_equal [as], @context.external_aliases
39 assert_equal [as], @context.unmatched_alias_lists['#old_name']
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
40 end
41
592e014 @drbrain Propogate file across aliases
drbrain authored Sep 29, 2010
42 def test_add_alias_method_attr
43 top_level = RDoc::TopLevel.new 'file.rb'
44
45 attr = RDoc::Attr.new nil, 'old_name', 'R', ''
46
47 as = RDoc::Alias.new nil, 'old_name', 'new_name', 'comment'
48 as.record_location top_level
49 as.parent = @context
50
51 @context.add_attribute attr
52 @context.add_alias as
53
54 assert_empty @context.aliases
55 assert_empty @context.unmatched_alias_lists
56 assert_equal %w[old_name new_name], @context.attributes.map { |m| m.name }
57
58 new = @context.attributes.last
59 assert_equal top_level, new.file
60 end
61
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
62 def test_add_alias_method
592e014 @drbrain Propogate file across aliases
drbrain authored Sep 29, 2010
63 top_level = RDoc::TopLevel.new 'file.rb'
64
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
65 meth = RDoc::AnyMethod.new nil, 'old_name'
54dbcf7 @drbrain Import various improvements from Thierry Lambert. See History.txt.
drbrain authored Sep 10, 2010
66 meth.singleton = false
67
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
68 as = RDoc::Alias.new nil, 'old_name', 'new_name', 'comment'
592e014 @drbrain Propogate file across aliases
drbrain authored Sep 29, 2010
69 as.record_location top_level
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
70 as.parent = @context
71
72 @context.add_method meth
73 @context.add_alias as
74
75 assert_empty @context.aliases
76 assert_empty @context.unmatched_alias_lists
77 assert_equal %w[old_name new_name], @context.method_list.map { |m| m.name }
592e014 @drbrain Propogate file across aliases
drbrain authored Sep 29, 2010
78
79 new = @context.method_list.last
80 assert_equal top_level, new.file
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
81 end
82
2b3df00 @drbrain Teach RDoc about aliases of signletons
drbrain authored Aug 18, 2010
83 def test_add_alias_method_singleton
84 meth = RDoc::AnyMethod.new nil, 'old_name'
85 meth.singleton = true
86
87 as = RDoc::Alias.new nil, 'old_name', 'new_name', 'comment'
88 as.singleton = true
89
90 as.parent = @context
91
92 @context.add_method meth
93 @context.add_alias as
94
95 assert_empty @context.aliases
96 assert_empty @context.unmatched_alias_lists
97 assert_equal %w[old_name new_name], @context.method_list.map { |m| m.name }
98
99 assert @context.method_list.last.singleton
100 end
101
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
102 def test_add_class
103 @c1.add_class RDoc::NormalClass, 'Klass', 'Object'
104
105 assert_includes @c1.classes.map { |k| k.full_name }, 'C1::Klass'
106 assert_includes RDoc::TopLevel.classes.map { |k| k.full_name }, 'C1::Klass'
107 end
108
1d3f389 @drbrain Fix infinite loop caused by re-encountering superclass
drbrain authored May 13, 2011
109 def test_add_class_basic_object
110 skip 'BasicObject is 1.9 only' unless defined?(BasicObject)
111
112 @xref_data.add_class RDoc::NormalClass, 'BasicObject'
113
114 basic = @xref_data.find_module_named 'BasicObject'
115
116 assert_nil basic.superclass
117
118 @c1.add_class RDoc::NormalClass, 'BasicObject'
119
120 basic = @c1.find_module_named 'BasicObject'
121
122 assert_equal 'Object', basic.superclass
123 end
124
125 def test_add_class_object
126 root_class = defined?(BasicObject) ? 'BasicObject' : nil
127
128 @xref_data.add_class RDoc::NormalClass, 'Object'
129
130 object = @xref_data.find_module_named 'Object'
131
132 assert_equal root_class, object.superclass
133
134 @c1.add_class RDoc::NormalClass, 'Object'
135
136 object = @c1.find_module_named 'Object'
137
138 assert_equal 'Object', object.superclass.full_name
139 end
140
8d2f2ee @drbrain RDoc::Parser::C no longer creates classes when processing aliases.
drbrain authored May 16, 2011
141 def test_add_class_singleton
142 @c1.add_class RDoc::NormalClass, 'Klass', 'Object'
143
144 assert_includes @c1.classes.map { |k| k.full_name }, 'C1::Klass'
145 assert_includes RDoc::TopLevel.classes.map { |k| k.full_name }, 'C1::Klass'
146 end
147
dc304d5 @drbrain RDoc now supports module aliasing via constant assignment.
drbrain authored Mar 8, 2010
148 def test_add_class_superclass
149 @c1.add_class RDoc::NormalClass, 'Klass', 'Object'
150 @c1.add_class RDoc::NormalClass, 'Klass', 'Other'
151 @c1.add_class RDoc::NormalClass, 'Klass', 'Object'
152
153 klass = @c1.find_module_named 'Klass'
154 assert_equal 'Other', klass.superclass
155 end
156
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
157 def test_add_class_upgrade
158 @c1.add_module RDoc::NormalModule, 'Klass'
159 @c1.add_class RDoc::NormalClass, 'Klass', nil
160
161 assert_includes @c1.classes.map { |k| k.full_name }, 'C1::Klass',
162 'c1 classes'
163 refute_includes @c1.modules.map { |k| k.full_name }, 'C1::Klass',
164 'c1 modules'
165
166 assert_includes RDoc::TopLevel.classes.map { |k| k.full_name }, 'C1::Klass',
167 'TopLevel classes'
168 refute_includes RDoc::TopLevel.modules.map { |k| k.full_name }, 'C1::Klass',
169 'TopLevel modules'
170 end
171
172 def test_add_constant
173 const = RDoc::Constant.new 'NAME', 'value', 'comment'
174 @context.add_constant const
175
176 assert_equal [const], @context.constants
177 end
178
179 def test_add_include
180 incl = RDoc::Include.new 'Name', 'comment'
181 @context.add_include incl
182
183 assert_equal [incl], @context.includes
184 end
185
72c6b2c @drbrain Test for adding the same include twice
drbrain authored Apr 12, 2011
186 def test_add_include_twice
187 incl1 = RDoc::Include.new 'Name', 'comment'
188 @context.add_include incl1
189
190 incl2 = RDoc::Include.new 'Name', 'comment'
191 @context.add_include incl2
192
193 assert_equal [incl1], @context.includes
194 end
195
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
196 def test_add_method
197 meth = RDoc::AnyMethod.new nil, 'old_name'
198 meth.visibility = nil
199
200 @context.add_method meth
201
202 assert_equal [meth], @context.method_list
203 assert_equal :public, meth.visibility
204 end
205
206 def test_add_method_alias
207 as = RDoc::Alias.new nil, 'old_name', 'new_name', 'comment'
208 meth = RDoc::AnyMethod.new nil, 'old_name'
209
210 @context.add_alias as
54dbcf7 @drbrain Import various improvements from Thierry Lambert. See History.txt.
drbrain authored Sep 10, 2010
211 refute_empty @context.external_aliases
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
212
213 @context.add_method meth
214
54dbcf7 @drbrain Import various improvements from Thierry Lambert. See History.txt.
drbrain authored Sep 10, 2010
215 assert_empty @context.external_aliases
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
216 assert_empty @context.unmatched_alias_lists
217 assert_equal %w[old_name new_name], @context.method_list.map { |m| m.name }
218 end
219
220 def test_add_module
221 @c1.add_module RDoc::NormalModule, 'Mod'
222
223 assert_includes @c1.modules.map { |m| m.full_name }, 'C1::Mod'
224 end
225
dc304d5 @drbrain RDoc now supports module aliasing via constant assignment.
drbrain authored Mar 8, 2010
226 def test_add_module_alias
14c80df @drbrain Record location of module alias
drbrain authored Jan 9, 2011
227 tl = RDoc::TopLevel.new 'file.rb'
dc304d5 @drbrain RDoc now supports module aliasing via constant assignment.
drbrain authored Mar 8, 2010
228
14c80df @drbrain Record location of module alias
drbrain authored Jan 10, 2011
229 c3_c4 = @c2.add_module_alias @c2_c3, 'C4', tl
230
231 c4 = @c2.find_module_named('C4')
232
233 alias_constant = @c2.constants.first
234
235 assert_equal c4, c3_c4
236 assert_equal tl, alias_constant.file
dc304d5 @drbrain RDoc now supports module aliasing via constant assignment.
drbrain authored Mar 8, 2010
237 end
238
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
239 def test_add_module_class
240 k = @c1.add_class RDoc::NormalClass, 'Klass', nil
241 m = @c1.add_module RDoc::NormalModule, 'Klass'
242
243 assert_equal k, m, 'returns class'
244 assert_empty @c1.modules
245 end
246
247 def test_add_require
248 req = RDoc::Require.new 'require', 'comment'
249 @c1.add_require req
250
251 assert_empty @c1.requires
252 assert_includes @c1.top_level.requires, req
253 end
254
0b45495 @drbrain Add the :category: directive which works like :section: but only for …
drbrain authored May 25, 2011
255 def test_add_section
256 default_section = @context.sections.first
257
258 @context.add_section nil, '# comment'
259
260 assert_equal 1, @context.sections.length
261 assert_equal '# comment', @context.sections.first.comment
262
263 @context.add_section nil, '# new comment'
264
265 assert_equal 1, @context.sections.length
266 assert_equal "# comment\n# ---\n# new comment",
267 @context.sections.first.comment
268
269 @context.add_section 'other', ''
270
271 assert_equal 2, @context.sections.length
272
273 new_section = @context.sections.find { |section| section.title == 'other' }
274 assert new_section
275 assert_equal default_section, @context.current_section
276 end
277
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
278 def test_add_to
279 incl = RDoc::Include.new 'Name', 'comment'
280 arr = []
281 @context.add_to arr, incl
282
283 assert_includes arr, incl
284 assert_equal @context, incl.parent
285 assert_equal @context.current_section, incl.section
286 end
287
0b45495 @drbrain Add the :category: directive which works like :section: but only for …
drbrain authored May 25, 2011
288 def test_add_to_temporary_section
289 incl = RDoc::Include.new 'Name', 'comment'
290 arr = []
291 section = @context.add_section 'temporary', ''
292 @context.temporary_section = section
293
294 @context.add_to arr, incl
295
296 assert_includes arr, incl
297 assert_equal @context, incl.parent
298 assert_equal section, incl.section
299 end
300
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
301 def test_add_to_no_document_self
302 incl = RDoc::Include.new 'Name', 'comment'
303 arr = []
304 @context.document_self = false
305 @context.add_to arr, incl
306
307 refute_includes arr, incl
308 end
309
310 def test_add_to_done_documenting
311 incl = RDoc::Include.new 'Name', 'comment'
312 arr = []
313 @context.done_documenting = true
314 @context.add_to arr, incl
315
316 refute_includes arr, incl
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
317 end
318
dc304d5 @drbrain RDoc now supports module aliasing via constant assignment.
drbrain authored Mar 8, 2010
319 def test_child_name
320 assert_equal 'C1::C1', @c1.child_name('C1')
321 end
322
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
323 def test_classes
324 assert_equal %w[C2::C3], @c2.classes.map { |k| k.full_name }
325 assert_equal %w[C3::H1 C3::H2], @c3.classes.map { |k| k.full_name }
326 end
327
0b45495 @drbrain Add the :category: directive which works like :section: but only for …
drbrain authored May 25, 2011
328 def test_current_section
329 default_section = @context.current_section
330
331 new_section = @context.add_section 'other', ''
332 @context.temporary_section = new_section
333
334 assert_equal new_section, @context.current_section
335 assert_equal default_section, @context.current_section
336 end
337
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
338 def test_defined_in_eh
339 assert @c1.defined_in?(@c1.top_level)
340
341 refute @c1.defined_in?(RDoc::TopLevel.new('name.rb'))
342 end
343
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
344 def test_equals2
345 assert_equal @c3, @c3
346 refute_equal @c2, @c3
347 refute_equal @c2_c3, @c3
348 end
349
ab2df2c @drbrain Add RDoc::Context#each_section
drbrain authored Feb 4, 2011
350 def test_each_section
351 sects = []
352 consts = []
353 attrs = []
354
74da994 @drbrain Add section filtering to #methods_by_type, remove methods from #each_…
drbrain authored Feb 4, 2011
355 @c1.each_section do |section, constants, attributes|
ab2df2c @drbrain Add RDoc::Context#each_section
drbrain authored Feb 5, 2011
356 sects << section
357 consts << constants
358 attrs << attributes
359 end
360
361 assert_equal [nil, 'separate'], sects.map { |section| section.title }
362
363 expected_consts = [
364 [@c1.constants.first],
365 [],
366 ]
367
368 assert_equal expected_consts, consts
369
370 expected_attrs = [
371 [@c1.attributes[0], @c1.attributes[3]],
372 [@c1.attributes[1], @c1.attributes[2]],
373 ]
374
375 assert_equal expected_attrs, attrs
376 end
377
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
378 def test_find_attribute_named
379 assert_equal nil, @c1.find_attribute_named('none')
380 assert_equal 'R', @c1.find_attribute_named('attr').rw
381 assert_equal 'R', @c1.find_attribute_named('attr_reader').rw
382 assert_equal 'W', @c1.find_attribute_named('attr_writer').rw
383 assert_equal 'RW', @c1.find_attribute_named('attr_accessor').rw
384 end
385
1297127 @drbrain Ruby bug #3169
drbrain authored Apr 19, 2010
386 def test_find_class_method_named
387 assert_equal nil, @c1.find_class_method_named('none')
388
389 m = @c1.find_class_method_named('m')
390 assert_instance_of RDoc::AnyMethod, m
391 assert m.singleton
392 end
393
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
394 def test_find_constant_named
395 assert_equal nil, @c1.find_constant_named('NONE')
396 assert_equal ':const', @c1.find_constant_named('CONST').value
397 end
398
399 def test_find_enclosing_module_named
400 assert_equal nil, @c2_c3.find_enclosing_module_named('NONE')
401 assert_equal @c1, @c2_c3.find_enclosing_module_named('C1')
402 assert_equal @c2, @c2_c3.find_enclosing_module_named('C2')
403 end
404
405 def test_find_file_named
406 assert_equal nil, @c1.find_file_named('nonexistent.rb')
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
407 assert_equal @xref_data, @c1.find_file_named(@file_name)
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
408 end
409
410 def test_find_instance_method_named
411 assert_equal nil, @c1.find_instance_method_named('none')
412
413 m = @c1.find_instance_method_named('m')
414 assert_instance_of RDoc::AnyMethod, m
1297127 @drbrain Ruby bug #3169
drbrain authored Apr 19, 2010
415 refute m.singleton
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
416 end
417
418 def test_find_local_symbol
419 assert_equal true, @c1.find_local_symbol('m').singleton
420 assert_equal ':const', @c1.find_local_symbol('CONST').value
421 assert_equal 'R', @c1.find_local_symbol('attr').rw
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
422 assert_equal @xref_data, @c1.find_local_symbol(@file_name)
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
423 assert_equal @c2_c3, @c2.find_local_symbol('C3')
424 end
425
426 def test_find_method_named
427 assert_equal true, @c1.find_method_named('m').singleton
428 end
429
430 def test_find_module_named
431 assert_equal @c2_c3, @c2.find_module_named('C3')
432 assert_equal @c2, @c2.find_module_named('C2')
433 assert_equal @c1, @c2.find_module_named('C1')
434
435 assert_equal 'C2::C3', @c2.find_module_named('C3').full_name
436 end
437
438 def test_find_symbol
ddcb75e @drbrain Remove file_ from TopLevel, universally use top_level in code objects
drbrain authored Feb 19, 2009
439 c3 = @xref_data.find_module_named('C3')
440 assert_equal c3, @xref_data.find_symbol('C3')
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
441 assert_equal c3, @c2.find_symbol('::C3')
442 assert_equal @c2_c3, @c2.find_symbol('C3')
443 end
444
1297127 @drbrain Ruby bug #3169
drbrain authored Apr 19, 2010
445 def test_find_symbol_method
446 assert_equal @c1__m, @c1.find_symbol('m')
447 assert_equal @c1_m, @c1.find_symbol('#m')
448 assert_equal @c1__m, @c1.find_symbol('::m')
449 end
450
208af01 @drbrain Test #fully_documented?
drbrain authored Dec 13, 2010
451 def test_fully_documented_eh
452 context = RDoc::Context.new
453
454 refute context.fully_documented?
455
456 context.comment = 'hi'
457
458 assert context.fully_documented?
459
460 m = @c1_m
461
462 context.add_method m
463
464 refute context.fully_documented?
465
466 m.comment = 'hi'
467
468 assert context.fully_documented?
469
470 c = RDoc::Constant.new 'C', '0', nil
471
472 context.add_constant c
473
474 refute context.fully_documented?
475
476 c.comment = 'hi'
477
478 assert context.fully_documented?
b6df2ff @drbrain Expand RDoc::Context#fully_documented? to include attributes
drbrain authored Dec 18, 2010
479
480 a = RDoc::Attr.new '', 'a', 'RW', nil
481
482 context.add_attribute a
483
484 refute context.fully_documented?
485
486 a.comment = 'hi'
487
488 assert context.fully_documented?
208af01 @drbrain Test #fully_documented?
drbrain authored Dec 13, 2010
489 end
490
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
491 def test_spaceship
492 assert_equal(-1, @c2.<=>(@c3))
493 assert_equal 0, @c2.<=>(@c2)
494 assert_equal 1, @c3.<=>(@c2)
495
496 assert_equal 1, @c2_c3.<=>(@c2)
497 assert_equal(-1, @c2_c3.<=>(@c3))
498 end
499
74da994 @drbrain Add section filtering to #methods_by_type, remove methods from #each_…
drbrain authored Feb 5, 2011
500 def test_methods_by_type
501 expected = {
502 'instance' => {
503 :private => [],
504 :protected => [],
505 :public => [@c1_m],
506 },
507 'class' => {
508 :private => [],
509 :protected => [],
510 :public => [@c1__m],
511 },
512 }
513
514 assert_equal expected, @c1.methods_by_type
515 end
516
517 def test_methods_by_type_section
518 separate = @c1.sections_hash['separate']
519 @c1_m.section = separate
520
521 expected = {
522 'instance' => {
523 :private => [],
524 :protected => [],
525 :public => [@c1_m],
526 },
527 'class' => {
528 :private => [],
529 :protected => [],
530 :public => [],
531 },
532 }
533
534 assert_equal expected, @c1.methods_by_type(separate)
535 end
536
5fb832a @drbrain Handle private_class_method and public_class_method correctly by copy…
drbrain authored May 13, 2011
537 def test_methods_matching
538 methods = []
539
540 @parent.methods_matching 'm' do |m|
541 methods << m
542 end
543
544 assert_equal [@parent_m], methods
545 end
546
547 def test_methods_matching_singleton
548 methods = []
549
550 @parent.methods_matching 'm', true do |m|
551 methods << m
552 end
553
554 assert_equal [@parent__m], methods
555 end
556
557 def test_methods_matching_inherit
558 methods = []
559
560 @child.methods_matching 'm' do |m|
561 methods << m
562 end
563
564 assert_equal [@parent_m], methods
565 end
566
38354a7 @drbrain Obey force_documentation when removing methods and attributes due to …
drbrain authored May 13, 2011
567 def test_remove_invisible_private
568 util_visibilities
569
570 @vis.remove_invisible :private
571
572 assert_equal [@pub, @prot, @priv], @vis.method_list
573 assert_equal [@apub, @aprot, @apriv], @vis.attributes
574 end
575
576 def test_remove_invisible_protected
577 util_visibilities
578
579 @vis.remove_invisible :protected
580
581 assert_equal [@pub, @prot], @vis.method_list
582 assert_equal [@apub, @aprot], @vis.attributes
583 end
584
585 def test_remove_invisible_public
586 util_visibilities
587
588 @vis.remove_invisible :public
589
590 assert_equal [@pub], @vis.method_list
591 assert_equal [@apub], @vis.attributes
592 end
593
594 def test_remove_invisible_public_force
595 util_visibilities
596
597 @priv.force_documentation = true
598 @prot.force_documentation = true
599 @apriv.force_documentation = true
600 @aprot.force_documentation = true
601
602 @vis.remove_invisible :public
603
604 assert_equal [@pub, @prot, @priv], @vis.method_list
605 assert_equal [@apub, @aprot, @apriv], @vis.attributes
606 end
607
608 def test_remove_invisible_in_protected
609 util_visibilities
610
611 methods = [@pub, @prot, @priv]
612
613 @c1.remove_invisible_in methods, :protected
614
615 assert_equal [@pub, @prot], methods
616 end
617
618 def test_remove_invisible_in_protected_force
619 util_visibilities
620
621 @priv.force_documentation = true
622
623 methods = [@pub, @prot, @priv]
624
625 @c1.remove_invisible_in methods, :protected
626
627 assert_equal [@pub, @prot, @priv], methods
628 end
629
630 def test_remove_invisible_in_public
631 util_visibilities
632
633 methods = [@pub, @prot, @priv]
634
635 @c1.remove_invisible_in methods, :public
636
637 assert_equal [@pub], methods
638 end
639
640 def test_remove_invisible_in_public_force
641 util_visibilities
642
643 @prot.force_documentation = true
644 @priv.force_documentation = true
645
646 methods = [@pub, @prot, @priv]
647
648 @c1.remove_invisible_in methods, :public
649
650 assert_equal [@pub, @prot, @priv], methods
651 end
652
0b45495 @drbrain Add the :category: directive which works like :section: but only for …
drbrain authored May 25, 2011
653 def test_set_current_section
654 default_section = @context.sections.first
655
656 @context.set_current_section nil, ''
657
658 assert_equal default_section, @context.current_section
659
660 @context.set_current_section 'other', ''
661
662 new_section = @context.sections.find { |section|
663 section != default_section
664 }
665
666 assert_equal new_section, @context.current_section
667 end
668
38354a7 @drbrain Obey force_documentation when removing methods and attributes due to …
drbrain authored May 13, 2011
669 def util_visibilities
670 @pub = RDoc::AnyMethod.new nil, 'pub'
671 @prot = RDoc::AnyMethod.new nil, 'prot'
672 @priv = RDoc::AnyMethod.new nil, 'priv'
673
674 @apub = RDoc::Attr.new nil, 'pub', 'RW', nil
675 @aprot = RDoc::Attr.new nil, 'prot', 'RW', nil
676 @apriv = RDoc::Attr.new nil, 'priv', 'RW', nil
677
678 @vis = RDoc::NormalClass.new 'Vis'
679 @vis.add_method @pub
680 @vis.add_method @prot
681 @vis.add_method @priv
682
683 @vis.add_attribute @apub
684 @vis.add_attribute @aprot
685 @vis.add_attribute @apriv
686
687 @prot.visibility = :protected
688 @priv.visibility = :private
689
690 @aprot.visibility = :protected
691 @apriv.visibility = :private
692 end
693
ea01122 @drbrain Reorganize code_objects.rb, fix references issues.
drbrain authored Feb 12, 2009
694 end
695
Something went wrong with that request. Please try again.