1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
|
require 'pp'
require File.expand_path '../xref_test_case', __FILE__
class TestRDocClassModule < XrefTestCase
def setup
super
@RM = RDoc::Markup
end
def mu_pp obj
s = ''
s = PP.pp obj, s
s.force_encoding Encoding.default_external if defined? Encoding
s.chomp
end
def test_add_comment
tl1 = RDoc::TopLevel.new 'one.rb'
tl2 = RDoc::TopLevel.new 'two.rb'
tl3 = RDoc::TopLevel.new 'three.rb'
cm = RDoc::ClassModule.new 'Klass'
cm.add_comment '# comment 1', tl1
assert_equal [['comment 1', tl1]], cm.comment_location
assert_equal 'comment 1', cm.comment
cm.add_comment '# comment 2', tl2
assert_equal [['comment 1', tl1], ['comment 2', tl2]], cm.comment_location
assert_equal "comment 1\n---\ncomment 2", cm.comment
cm.add_comment "# * comment 3", tl3
assert_equal [['comment 1', tl1],
['comment 2', tl2],
['* comment 3', tl3]], cm.comment_location
assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment
end
def test_add_comment_stopdoc
tl = RDoc::TopLevel.new 'file.rb'
cm = RDoc::ClassModule.new 'Klass'
cm.stop_doc
cm.add_comment '# comment 1', tl
assert_empty cm.comment
end
def test_ancestors
assert_equal [@parent], @child.ancestors
end
def test_comment_equals
cm = RDoc::ClassModule.new 'Klass'
cm.comment = '# comment 1'
assert_equal 'comment 1', cm.comment
cm.comment = '# comment 2'
assert_equal "comment 1\n---\ncomment 2", cm.comment
cm.comment = "# * comment 3"
assert_equal "comment 1\n---\ncomment 2\n---\n* comment 3", cm.comment
end
def test_each_ancestor
ancestors = []
@child.each_ancestor do |mod|
ancestors << mod
end
assert_equal [@parent], ancestors
end
# handle making a short module alias of yourself
def test_find_class_named
@c2.classes_hash['C2'] = @c2
assert_nil @c2.find_class_named('C1')
end
def test_from_module_comment
tl = RDoc::TopLevel.new 'file.rb'
klass = tl.add_class RDoc::NormalModule, 'Klass'
klass.add_comment 'really a class', tl
klass = RDoc::ClassModule.from_module RDoc::NormalClass, klass
assert_equal [['really a class', tl]], klass.comment_location
end
def test_marshal_dump
tl = RDoc::TopLevel.new 'file.rb'
ns = tl.add_module RDoc::NormalModule, 'Namespace'
cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
cm.record_location tl
a1 = RDoc::Attr.new nil, 'a1', 'RW', ''
a1.record_location tl
a2 = RDoc::Attr.new nil, 'a2', 'RW', '', true
a2.record_location tl
m1 = RDoc::AnyMethod.new nil, 'm1'
m1.record_location tl
c1 = RDoc::Constant.new 'C1', nil, ''
c1.record_location tl
i1 = RDoc::Include.new 'I1', ''
i1.record_location tl
cm.add_attribute a1
cm.add_attribute a2
cm.add_method m1
cm.add_constant c1
cm.add_include i1
cm.add_comment 'this is a comment', tl
loaded = Marshal.load Marshal.dump cm
assert_equal cm, loaded
inner = RDoc::Markup::Document.new(
RDoc::Markup::Paragraph.new('this is a comment'))
inner.file = tl.absolute_name
comment = RDoc::Markup::Document.new inner
assert_equal [a2, a1], loaded.attributes.sort
assert_equal comment, loaded.comment
assert_equal [c1], loaded.constants
assert_equal 'Namespace::Klass', loaded.full_name
assert_equal [i1], loaded.includes
assert_equal [m1], loaded.method_list
assert_equal 'Klass', loaded.name
assert_equal 'Super', loaded.superclass
assert_equal tl, loaded.attributes.first.file
assert_equal tl, loaded.constants.first.file
assert_equal tl, loaded.includes.first.file
assert_equal tl, loaded.method_list.first.file
end
def test_marshal_load_version_0
tl = RDoc::TopLevel.new 'file.rb'
ns = tl.add_module RDoc::NormalModule, 'Namespace'
cm = ns.add_class RDoc::NormalClass, 'Klass', 'Super'
a = RDoc::Attr.new(nil, 'a1', 'RW', '')
m = RDoc::AnyMethod.new(nil, 'm1')
c = RDoc::Constant.new('C1', nil, '')
i = RDoc::Include.new('I1', '')
cm.add_attribute a
cm.add_method m
cm.add_constant c
cm.add_include i
cm.add_comment 'this is a comment', tl
loaded = Marshal.load "\x04\bU:\x16RDoc::NormalClass[\x0Ei\x00\"\nKlass" \
"\"\x15Namespace::KlassI\"\nSuper\x06:\x06EF" \
"o:\eRDoc::Markup::Document\x06:\v@parts[\x06" \
"o:\x1CRDoc::Markup::Paragraph\x06;\b[\x06I" \
"\"\x16this is a comment\x06;\x06F[\x06[\aI" \
"\"\aa1\x06;\x06FI\"\aRW\x06;\x06F[\x06[\aI" \
"\"\aC1\x06;\x06Fo;\a\x06;\b[\x00[\x06[\aI" \
"\"\aI1\x06;\x06Fo;\a\x06;\b[\x00[\a[\aI" \
"\"\nclass\x06;\x06F[\b[\a:\vpublic[\x00[\a" \
":\x0Eprotected[\x00[\a:\fprivate[\x00[\aI" \
"\"\rinstance\x06;\x06F[\b[\a;\n[\x06I" \
"\"\am1\x06;\x06F[\a;\v[\x00[\a;\f[\x00"
assert_equal cm, loaded
comment = RDoc::Markup::Document.new(
RDoc::Markup::Paragraph.new('this is a comment'))
assert_equal [a], loaded.attributes
assert_equal comment, loaded.comment
assert_equal [c], loaded.constants
assert_equal 'Namespace::Klass', loaded.full_name
assert_equal [i], loaded.includes
assert_equal [m], loaded.method_list
assert_equal 'Klass', loaded.name
assert_equal 'Super', loaded.superclass
assert_equal nil, loaded.file
end
def test_merge_attributes
tl1 = RDoc::TopLevel.new 'one.rb'
tl2 = RDoc::TopLevel.new 'two.rb'
cm1 = RDoc::ClassModule.new 'Klass'
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a1', 'RW', '')
attr.record_location tl1
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a3', 'R', '')
attr.record_location tl1
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a4', 'R', '')
attr.record_location tl1
cm2 = RDoc::ClassModule.new 'Klass'
# TODO allow merging when comment == ''
cm2.instance_variable_set :@comment, @RM::Document.new
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a2', 'RW', '')
attr.record_location tl2
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a3', 'W', '')
attr.record_location tl1
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a4', 'W', '')
attr.record_location tl1
cm1.merge cm2
expected = [
RDoc::Attr.new(nil, 'a2', 'RW', ''),
RDoc::Attr.new(nil, 'a3', 'W', ''),
RDoc::Attr.new(nil, 'a4', 'W', ''),
]
expected.each do |a| a.parent = cm1 end
assert_equal expected, cm1.attributes.sort
end
def test_merge_attributes_version_0
tl1 = RDoc::TopLevel.new 'one.rb'
cm1 = RDoc::ClassModule.new 'Klass'
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a1', 'RW', '')
attr.record_location tl1
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a3', 'R', '')
attr.record_location tl1
attr = cm1.add_attribute RDoc::Attr.new(nil, 'a4', 'R', '')
attr.record_location tl1
cm2 = RDoc::ClassModule.new 'Klass'
# TODO allow merging when comment == ''
cm2.instance_variable_set :@comment, @RM::Document.new
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a2', 'RW', '')
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a3', 'W', '')
attr = cm2.add_attribute RDoc::Attr.new(nil, 'a4', 'W', '')
cm1.merge cm2
expected = [
RDoc::Attr.new(nil, 'a1', 'RW', ''),
RDoc::Attr.new(nil, 'a2', 'RW', ''),
RDoc::Attr.new(nil, 'a3', 'RW', ''),
RDoc::Attr.new(nil, 'a4', 'RW', ''),
]
expected.each do |a| a.parent = cm1 end
assert_equal expected, cm1.attributes.sort
end
def test_merge_collections_drop
tl = RDoc::TopLevel.new 'file'
cm1 = RDoc::ClassModule.new 'C'
cm1.record_location tl
const = cm1.add_constant RDoc::Constant.new('CONST', nil, nil)
const.record_location tl
cm2 = RDoc::ClassModule.new 'C'
cm2.record_location tl
added = []
removed = []
cm1.merge_collections cm1.constants, cm2.constants, cm2.in_files do |add, c|
if add then
added << c
else
removed << c
end
end
assert_empty added
assert_equal [const], removed
end
def test_merge_comment
tl1 = RDoc::TopLevel.new 'one.rb'
tl2 = RDoc::TopLevel.new 'two.rb'
cm1 = RDoc::ClassModule.new 'Klass'
cm1.add_comment 'klass 1', tl1
cm2 = RDoc::ClassModule.new 'Klass'
cm2.add_comment 'klass 2', tl2
cm2.add_comment 'klass 3', tl1
cm2 = Marshal.load Marshal.dump cm2
cm1.merge cm2
inner1 = @RM::Document.new @RM::Paragraph.new 'klass 3'
inner1.file = 'one.rb'
inner2 = @RM::Document.new @RM::Paragraph.new 'klass 2'
inner2.file = 'two.rb'
expected = @RM::Document.new inner2, inner1
assert_equal expected, cm1.comment
end
def test_merge_comment_version_0
tl = RDoc::TopLevel.new 'file.rb'
cm1 = RDoc::ClassModule.new 'Klass'
cm1.add_comment 'klass 1', tl
cm2 = RDoc::ClassModule.new 'Klass'
cm2.instance_variable_set(:@comment,
@RM::Document.new(
@RM::Paragraph.new('klass 2')))
cm2.instance_variable_set :@comment_location, @RM::Document.new(cm2.comment)
cm1.merge cm2
inner = @RM::Document.new @RM::Paragraph.new 'klass 1'
inner.file = 'file.rb'
expected = @RM::Document.new \
inner,
@RM::Document.new(@RM::Paragraph.new('klass 2'))
assert_equal expected, cm1.comment
end
def test_merge_constants
tl1 = RDoc::TopLevel.new 'one.rb'
tl2 = RDoc::TopLevel.new 'two.rb'
cm1 = RDoc::ClassModule.new 'Klass'
const = cm1.add_constant RDoc::Constant.new('C1', nil, 'one')
const.record_location tl1
const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
const.record_location tl1
cm2 = RDoc::ClassModule.new 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
const = cm2.add_constant RDoc::Constant.new('C2', nil, 'two')
const.record_location tl2
const = cm2.add_constant RDoc::Constant.new('C3', nil, 'one')
const.record_location tl1
const = cm2.add_constant RDoc::Constant.new('C4', nil, 'one')
const.record_location tl1
cm1.merge cm2
expected = [
RDoc::Constant.new('C2', nil, 'two'),
RDoc::Constant.new('C3', nil, 'one'),
RDoc::Constant.new('C4', nil, 'one'),
]
expected.each do |a| a.parent = cm1 end
assert_equal expected, cm1.constants.sort
end
def test_merge_constants_version_0
tl1 = RDoc::TopLevel.new 'one.rb'
cm1 = RDoc::ClassModule.new 'Klass'
const = cm1.add_constant RDoc::Constant.new('C1', nil, 'one')
const.record_location tl1
const = cm1.add_constant RDoc::Constant.new('C3', nil, 'one')
const.record_location tl1
cm2 = RDoc::ClassModule.new 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
const = cm2.add_constant RDoc::Constant.new('C2', nil, 'two')
const = cm2.add_constant RDoc::Constant.new('C3', nil, 'two')
const = cm2.add_constant RDoc::Constant.new('C4', nil, 'two')
cm1.merge cm2
expected = [
RDoc::Constant.new('C1', nil, 'one'),
RDoc::Constant.new('C2', nil, 'two'),
RDoc::Constant.new('C3', nil, 'one'),
RDoc::Constant.new('C4', nil, 'two'),
]
expected.each do |a| a.parent = cm1 end
assert_equal expected, cm1.constants.sort
end
def test_merge_includes
tl1 = RDoc::TopLevel.new 'one.rb'
tl2 = RDoc::TopLevel.new 'two.rb'
cm1 = RDoc::ClassModule.new 'Klass'
incl = cm1.add_include RDoc::Include.new('I1', 'one')
incl.record_location tl1
incl = cm1.add_include RDoc::Include.new('I3', 'one')
incl.record_location tl1
cm2 = RDoc::ClassModule.new 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
incl = cm2.add_include RDoc::Include.new('I2', 'two')
incl.record_location tl2
incl = cm2.add_include RDoc::Include.new('I3', 'one')
incl.record_location tl1
incl = cm2.add_include RDoc::Include.new('I4', 'one')
incl.record_location tl1
cm1.merge cm2
expected = [
RDoc::Include.new('I2', 'two'),
RDoc::Include.new('I3', 'one'),
RDoc::Include.new('I4', 'one'),
]
expected.each do |a| a.parent = cm1 end
assert_equal expected, cm1.includes.sort
end
def test_merge_includes_version_0
tl1 = RDoc::TopLevel.new 'one.rb'
cm1 = RDoc::ClassModule.new 'Klass'
incl = cm1.add_include RDoc::Include.new('I1', 'one')
incl.record_location tl1
incl = cm1.add_include RDoc::Include.new('I3', 'one')
incl.record_location tl1
cm2 = RDoc::ClassModule.new 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
incl = cm2.add_include RDoc::Include.new('I2', 'two')
incl = cm2.add_include RDoc::Include.new('I3', 'two')
incl = cm2.add_include RDoc::Include.new('I4', 'two')
cm1.merge cm2
expected = [
RDoc::Include.new('I1', 'one'),
RDoc::Include.new('I2', 'two'),
RDoc::Include.new('I3', 'one'),
RDoc::Include.new('I4', 'two'),
]
expected.each do |a| a.parent = cm1 end
assert_equal expected, cm1.includes.sort
end
def test_merge_methods
tl1 = RDoc::TopLevel.new 'one.rb'
tl2 = RDoc::TopLevel.new 'two.rb'
cm1 = RDoc::ClassModule.new 'Klass'
meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm1')
meth.record_location tl1
meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm3')
meth.record_location tl1
cm2 = RDoc::ClassModule.new 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm2')
meth.record_location tl2
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm3')
meth.record_location tl1
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm4')
meth.record_location tl1
cm1.merge cm2
expected = [
RDoc::AnyMethod.new(nil, 'm2'),
RDoc::AnyMethod.new(nil, 'm3'),
RDoc::AnyMethod.new(nil, 'm4'),
]
expected.each do |a| a.parent = cm1 end
assert_equal expected, cm1.method_list.sort
end
def test_merge_methods_version_0
tl1 = RDoc::TopLevel.new 'one.rb'
cm1 = RDoc::ClassModule.new 'Klass'
meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm1')
meth.record_location tl1
meth = cm1.add_method RDoc::AnyMethod.new(nil, 'm3')
meth.record_location tl1
cm2 = RDoc::ClassModule.new 'Klass'
cm2.instance_variable_set :@comment, @RM::Document.new
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm2')
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm3')
meth = cm2.add_method RDoc::AnyMethod.new(nil, 'm4')
cm1.merge cm2
expected = [
RDoc::AnyMethod.new(nil, 'm1'),
RDoc::AnyMethod.new(nil, 'm2'),
RDoc::AnyMethod.new(nil, 'm3'),
RDoc::AnyMethod.new(nil, 'm4'),
]
expected.each do |a| a.parent = cm1 end
assert_equal expected, cm1.method_list.sort
end
def test_parse
tl1 = RDoc::TopLevel.new 'one.rb'
tl2 = RDoc::TopLevel.new 'two.rb'
cm = RDoc::ClassModule.new 'Klass'
cm.add_comment 'comment 1', tl1
cm.add_comment 'comment 2', tl2
doc1 = @RM::Document.new @RM::Paragraph.new 'comment 1'
doc1.file = tl1.absolute_name
doc2 = @RM::Document.new @RM::Paragraph.new 'comment 2'
doc2.file = tl2.absolute_name
expected = @RM::Document.new doc1, doc2
assert_equal expected, cm.parse(cm.comment_location)
end
def test_parse_comment_location
tl1 = RDoc::TopLevel.new 'one.rb'
tl2 = RDoc::TopLevel.new 'two.rb'
cm = RDoc::ClassModule.new 'Klass'
cm.add_comment 'comment 1', tl1
cm.add_comment 'comment 2', tl2
cm = Marshal.load Marshal.dump cm
doc1 = @RM::Document.new @RM::Paragraph.new 'comment 1'
doc1.file = tl1.absolute_name
doc2 = @RM::Document.new @RM::Paragraph.new 'comment 2'
doc2.file = tl2.absolute_name
assert_same cm.comment_location, cm.parse(cm.comment_location)
end
def test_remove_nodoc_children
parent = RDoc::ClassModule.new 'A'
parent.modules_hash.replace 'B' => true, 'C' => true
RDoc::TopLevel.all_modules_hash.replace 'A::B' => true
parent.classes_hash.replace 'D' => true, 'E' => true
RDoc::TopLevel.all_classes_hash.replace 'A::D' => true
parent.remove_nodoc_children
assert_equal %w[B], parent.modules_hash.keys
assert_equal %w[D], parent.classes_hash.keys
end
def test_superclass
assert_equal @c3_h1, @c3_h2.superclass
end
def test_update_aliases_class
n1 = @xref_data.add_module RDoc::NormalClass, 'N1'
n1_k2 = n1.add_module RDoc::NormalClass, 'N2'
n1.add_module_alias n1_k2, 'A1', @xref_data
n1_a1_c = n1.constants.find { |c| c.name == 'A1' }
refute_nil n1_a1_c
assert_equal n1_k2, n1_a1_c.is_alias_for, 'sanity check'
n1.update_aliases
n1_a1_k = @xref_data.find_class_or_module 'N1::A1'
refute_nil n1_a1_k
assert_equal n1_k2, n1_a1_k.is_alias_for
refute_equal n1_k2, n1_a1_k
assert_equal 1, n1_k2.aliases.length
assert_equal n1_a1_k, n1_k2.aliases.first
assert_equal 'N1::N2', n1_k2.full_name
assert_equal 'N1::A1', n1_a1_k.full_name
end
def test_update_aliases_module
n1 = @xref_data.add_module RDoc::NormalModule, 'N1'
n1_n2 = n1.add_module RDoc::NormalModule, 'N2'
n1.add_module_alias n1_n2, 'A1', @xref_data
n1_a1_c = n1.constants.find { |c| c.name == 'A1' }
refute_nil n1_a1_c
assert_equal n1_n2, n1_a1_c.is_alias_for, 'sanity check'
n1.update_aliases
n1_a1_m = @xref_data.find_class_or_module 'N1::A1'
refute_nil n1_a1_m
assert_equal n1_n2, n1_a1_m.is_alias_for
refute_equal n1_n2, n1_a1_m
assert_equal 1, n1_n2.aliases.length
assert_equal n1_a1_m, n1_n2.aliases.first
assert_equal 'N1::N2', n1_n2.full_name
assert_equal 'N1::A1', n1_a1_m.full_name
end
def test_update_aliases_reparent
l1 = @xref_data.add_module RDoc::NormalModule, 'L1'
l1_l2 = l1.add_module RDoc::NormalModule, 'L2'
o1 = @xref_data.add_module RDoc::NormalModule, 'O1'
o1.add_module_alias l1_l2, 'A1', @xref_data
o1_a1_c = o1.constants.find { |c| c.name == 'A1' }
refute_nil o1_a1_c
assert_equal l1_l2, o1_a1_c.is_alias_for
refute_equal l1_l2, o1_a1_c
o1.update_aliases
o1_a1_m = @xref_data.find_class_or_module 'O1::A1'
refute_nil o1_a1_m
assert_equal l1_l2, o1_a1_m.is_alias_for
assert_equal 1, l1_l2.aliases.length
assert_equal o1_a1_m, l1_l2.aliases[0]
assert_equal 'L1::L2', l1_l2.full_name
assert_equal 'O1::A1', o1_a1_m.full_name
end
def test_update_includes
a = RDoc::Include.new 'M1', nil
b = RDoc::Include.new 'M2', nil
c = RDoc::Include.new 'C', nil
@c1.add_include a
@c1.add_include b
@c1.add_include c
@c1.ancestors # cache included modules
@m1_m2.document_self = nil
assert @m1_m2.remove_from_documentation?
assert RDoc::TopLevel.all_modules_hash.key? @m1_m2.full_name
refute RDoc::TopLevel.all_modules_hash[@m1_m2.full_name].nil?
RDoc::TopLevel.remove_nodoc RDoc::TopLevel.all_modules_hash
refute RDoc::TopLevel.all_modules_hash.key? @m1_m2.full_name
@c1.update_includes
assert_equal [a, c], @c1.includes
end
def test_update_includes_with_colons
a = RDoc::Include.new 'M1', nil
b = RDoc::Include.new 'M1::M2', nil
c = RDoc::Include.new 'C', nil
@c1.add_include a
@c1.add_include b
@c1.add_include c
@c1.ancestors # cache included modules
@m1_m2.document_self = nil
assert @m1_m2.remove_from_documentation?
assert RDoc::TopLevel.all_modules_hash.key? @m1_m2.full_name
refute RDoc::TopLevel.all_modules_hash[@m1_m2.full_name].nil?
RDoc::TopLevel.remove_nodoc RDoc::TopLevel.all_modules_hash
refute RDoc::TopLevel.all_modules_hash.key? @m1_m2.full_name
@c1.update_includes
assert_equal [a, c], @c1.includes
end
end
|