From 89b601d176a64f1293a3d3b5195b6735cbf880af Mon Sep 17 00:00:00 2001 From: drbrain Date: Sun, 31 Jul 2011 00:19:00 +0000 Subject: * lib/rdoc: Update to RDoc 3.9. Fixed `ri []`, stopdoc creating an object reference, nodoc for class aliases, verbatim === lines. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rdoc/test_rdoc_markup_to_html_crossref.rb | 161 +++++++------------------ 1 file changed, 44 insertions(+), 117 deletions(-) (limited to 'test/rdoc/test_rdoc_markup_to_html_crossref.rb') diff --git a/test/rdoc/test_rdoc_markup_to_html_crossref.rb b/test/rdoc/test_rdoc_markup_to_html_crossref.rb index 8c97941727..4611e45309 100644 --- a/test/rdoc/test_rdoc_markup_to_html_crossref.rb +++ b/test/rdoc/test_rdoc_markup_to_html_crossref.rb @@ -10,159 +10,86 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase def setup super - @xref = RDoc::Markup::ToHtmlCrossref.new 'index.html', @c1, true + @to = RDoc::Markup::ToHtmlCrossref.new 'index.html', @c1, true end - def assert_ref(path, ref) - assert_equal "\n

#{ref}

\n", @xref.convert(ref) - end + def test_convert_CROSSREF + result = @to.convert 'C1' - def refute_ref(body, ref) - assert_equal "\n

#{body}

\n", @xref.convert(ref) + assert_equal "\n

C1

\n", result end - def test_handle_special_CROSSREF_C2 - @xref = RDoc::Markup::ToHtmlCrossref.new 'classes/C2.html', @c2, true - - refute_ref '#m', '#m' + def test_convert_HYPERLINK_rdoc_ref + result = @to.convert 'rdoc-ref:C1' - assert_ref '../C1.html#method-c-m', 'C1::m' - assert_ref '../C2/C3.html', 'C2::C3' - assert_ref '../C2/C3.html#method-i-m', 'C2::C3#m' - assert_ref '../C2/C3/H1.html', 'C3::H1' - assert_ref '../C4.html', 'C4' - - assert_ref '../C3/H2.html', 'C3::H2' - refute_ref 'H1', 'H1' + assert_equal "\n

C1

\n", result end - def test_handle_special_CROSSREF_C2_C3 - @xref = RDoc::Markup::ToHtmlCrossref.new 'classes/C2/C3.html', @c2_c3, true - - assert_ref '../../C2/C3.html#method-i-m', '#m' - - assert_ref '../../C2/C3.html', 'C3' - assert_ref '../../C2/C3.html#method-i-m', 'C3#m' - - assert_ref '../../C2/C3/H1.html', 'H1' - assert_ref '../../C2/C3/H1.html', 'C3::H1' - - assert_ref '../../C4.html', 'C4' - - assert_ref '../../C3/H2.html', 'C3::H2' + def test_handle_special_CROSSREF + assert_equal "C2::C3", SPECIAL('C2::C3') end - def test_handle_special_CROSSREF_C3 - @xref = RDoc::Markup::ToHtmlCrossref.new 'classes/C3.html', @c3, true - - assert_ref '../C3.html', 'C3' - - refute_ref '#m', '#m' - refute_ref 'C3#m', 'C3#m' - - assert_ref '../C3/H1.html', 'H1' - - assert_ref '../C3/H1.html', 'C3::H1' - assert_ref '../C3/H2.html', 'C3::H2' - - assert_ref '../C4.html', 'C4' - end - - def test_handle_special_CROSSREF_C4 - @xref = RDoc::Markup::ToHtmlCrossref.new 'classes/C4.html', @c4, true + def test_handle_special_CROSSREF_show_hash_false + @to.show_hash = false - # C4 ref inside a C4 containing a C4 should resolve to the contained class - assert_ref '../C4/C4.html', 'C4' + assert_equal "m", + SPECIAL('#m') end - def test_handle_special_CROSSREF_C4_C4 - @xref = RDoc::Markup::ToHtmlCrossref.new 'classes/C4/C4.html', @c4_c4, true + def test_handle_special_HYPERLINK_rdoc + RDoc::TopLevel.new 'README.txt' + @to = RDoc::Markup::ToHtmlCrossref.new 'C2.html', @c2, true - # A C4 reference inside a C4 class contained within a C4 class should - # resolve to the inner C4 class. - assert_ref '../../C4/C4.html', 'C4' - end + link = @to.handle_special_HYPERLINK hyper 'C2::C3' - def test_handle_special_CROSSREF_class - assert_ref 'C1.html', 'C1' - refute_ref 'H1', 'H1' + assert_equal 'C2::C3', link - assert_ref 'C2.html', 'C2' - assert_ref 'C2/C3.html', 'C2::C3' - assert_ref 'C2/C3/H1.html', 'C2::C3::H1' + link = @to.handle_special_HYPERLINK hyper 'C4' - assert_ref 'C3.html', '::C3' - assert_ref 'C3/H1.html', '::C3::H1' + assert_equal 'C4', link - assert_ref 'C4/C4.html', 'C4::C4' - end + link = @to.handle_special_HYPERLINK hyper 'README.txt' - def test_handle_special_CROSSREF_file - assert_ref 'xref_data_rb.html', 'xref_data.rb' + assert_equal 'README.txt', link end - def test_handle_special_CROSSREF_method - refute_ref 'm', 'm' - assert_ref 'C1.html#method-i-m', '#m' - assert_ref 'C1.html#method-c-m', '::m' - - assert_ref 'C1.html#method-i-m', 'C1#m' - assert_ref 'C1.html#method-c-m', 'C1.m' - assert_ref 'C1.html#method-c-m', 'C1::m' + def test_handle_special_TIDYLINK_rdoc + RDoc::TopLevel.new 'README.txt' + @to = RDoc::Markup::ToHtmlCrossref.new 'C2.html', @c2, true - assert_ref 'C1.html#method-i-m', 'C1#m' - assert_ref 'C1.html#method-i-m', 'C1#m()' - assert_ref 'C1.html#method-i-m', 'C1#m(*)' + link = @to.handle_special_TIDYLINK tidy 'C2::C3' - assert_ref 'C1.html#method-c-m', 'C1.m' - assert_ref 'C1.html#method-c-m', 'C1.m()' - assert_ref 'C1.html#method-c-m', 'C1.m(*)' + assert_equal 'tidy', link - assert_ref 'C1.html#method-c-m', 'C1::m' - assert_ref 'C1.html#method-c-m', 'C1::m()' - assert_ref 'C1.html#method-c-m', 'C1::m(*)' + link = @to.handle_special_TIDYLINK tidy 'C4' - assert_ref 'C2/C3.html#method-i-m', 'C2::C3#m' + assert_equal 'tidy', link - assert_ref 'C2/C3.html#method-i-m', 'C2::C3.m' + link = @to.handle_special_TIDYLINK tidy 'README.txt' - # TODO stop escaping - HTML5 allows anything but space - assert_ref 'C2/C3/H1.html#method-i-m-3F', 'C2::C3::H1#m?' - - assert_ref 'C2/C3.html#method-i-m', '::C2::C3#m' - assert_ref 'C2/C3.html#method-i-m', '::C2::C3#m()' - assert_ref 'C2/C3.html#method-i-m', '::C2::C3#m(*)' + assert_equal 'tidy', link end - def test_handle_special_CROSSREF_no_ref - assert_equal '', @xref.convert('') - - refute_ref 'bogus', 'bogus' - refute_ref 'bogus', '\bogus' - refute_ref '\bogus', '\\\bogus' - - refute_ref '#n', '\#n' - refute_ref '#n()', '\#n()' - refute_ref '#n(*)', '\#n(*)' + def test_link + assert_equal 'n', @to.link('n', 'n') - refute_ref 'C1', '\C1' - refute_ref '::C3', '\::C3' + assert_equal 'm', @to.link('m', 'm') + end - refute_ref '::C3::H1#n', '::C3::H1#n' - refute_ref '::C3::H1#n(*)', '::C3::H1#n(*)' - refute_ref '::C3::H1#n', '\::C3::H1#n' + def SPECIAL text + @to.handle_special_CROSSREF special text end - def test_handle_special_CROSSREF_show_hash_false - @xref.show_hash = false + def hyper reference + RDoc::Markup::Special.new 0, "rdoc-ref:#{reference}" + end - assert_equal "\n

m

\n", - @xref.convert('#m') + def special text + RDoc::Markup::Special.new 0, text end - def test_handle_special_CROSSREF_special - assert_equal "\n

C2::C3;method(*)

\n", - @xref.convert('C2::C3;method(*)') + def tidy reference + RDoc::Markup::Special.new 0, "{tidy}[rdoc-ref:#{reference}]" end end -- cgit v1.2.3