diff options
Diffstat (limited to 'test/rdoc')
-rw-r--r-- | test/rdoc/test_rdoc_cross_reference.rb | 3 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_markup_attribute_manager.rb | 22 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_markup_attributes.rb | 8 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_markup_formatter.rb | 38 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_markup_to_html.rb | 14 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_markup_to_html_crossref.rb | 46 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_markup_to_html_snippet.rb | 12 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_parser_ruby.rb | 66 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_servlet.rb | 3 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_store.rb | 11 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_text.rb | 3 |
11 files changed, 142 insertions, 84 deletions
diff --git a/test/rdoc/test_rdoc_cross_reference.rb b/test/rdoc/test_rdoc_cross_reference.rb index 8233fe3f61..183de0930d 100644 --- a/test/rdoc/test_rdoc_cross_reference.rb +++ b/test/rdoc/test_rdoc_cross_reference.rb @@ -162,8 +162,7 @@ class TestRDocCrossReference < XrefTestCase end def test_resolve_page - page = @store.add_file 'README.txt' - page.parser = RDoc::Parser::Simple + page = @store.add_file 'README.txt', parser: RDoc::Parser::Simple assert_ref page, 'README' end diff --git a/test/rdoc/test_rdoc_markup_attribute_manager.rb b/test/rdoc/test_rdoc_markup_attribute_manager.rb index 93338ecb50..d6eccdf76f 100644 --- a/test/rdoc/test_rdoc_markup_attribute_manager.rb +++ b/test/rdoc/test_rdoc_markup_attribute_manager.rb @@ -36,12 +36,12 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase end def crossref(text) - crossref_bitmap = @am.attributes.bitmap_for(:_SPECIAL_) | + crossref_bitmap = @am.attributes.bitmap_for(:_REGEXP_HANDLING_) | @am.attributes.bitmap_for(:CROSSREF) - [ @am.changed_attribute_by_name([], [:CROSSREF, :_SPECIAL_]), - RDoc::Markup::Special.new(crossref_bitmap, text), - @am.changed_attribute_by_name([:CROSSREF, :_SPECIAL_], []) + [ @am.changed_attribute_by_name([], [:CROSSREF, :_REGEXP_HANDLING_]), + RDoc::Markup::RegexpHandling.new(crossref_bitmap, text), + @am.changed_attribute_by_name([:CROSSREF, :_REGEXP_HANDLING_], []) ] end @@ -58,12 +58,12 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase assert(tags.has_key?("test")) end - def test_add_special - @am.add_special "WikiWord", :WIKIWORD - specials = @am.special + def test_add_regexp_handling + @am.add_regexp_handling "WikiWord", :WIKIWORD + regexp_handlings = @am.regexp_handlings - assert_equal 1, specials.size - assert specials.assoc "WikiWord" + assert_equal 1, regexp_handlings.size + assert regexp_handlings.assoc "WikiWord" end def test_add_word_pair @@ -340,8 +340,8 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase @am.flow(str)) end - def test_special - @am.add_special(RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF) + def test_regexp_handling + @am.add_regexp_handling(RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF) # # The apostrophes in "cats'" and "dogs'" suppress the flagging of these diff --git a/test/rdoc/test_rdoc_markup_attributes.rb b/test/rdoc/test_rdoc_markup_attributes.rb index 91c253a6b0..e592fa7145 100644 --- a/test/rdoc/test_rdoc_markup_attributes.rb +++ b/test/rdoc/test_rdoc_markup_attributes.rb @@ -19,10 +19,10 @@ class TestRDocMarkupAttributes < RDoc::TestCase @as.bitmap_for 'two' @as.bitmap_for 'three' - assert_equal 'none', @as.as_string(0) - assert_equal '_SPECIAL_', @as.as_string(1) - assert_equal 'two', @as.as_string(2) - assert_equal '_SPECIAL_,two', @as.as_string(3) + assert_equal 'none', @as.as_string(0) + assert_equal '_REGEXP_HANDLING_', @as.as_string(1) + assert_equal 'two', @as.as_string(2) + assert_equal '_REGEXP_HANDLING_,two', @as.as_string(3) end def test_each_name_of diff --git a/test/rdoc/test_rdoc_markup_formatter.rb b/test/rdoc/test_rdoc_markup_formatter.rb index b1f0855de3..cdc5944cdf 100644 --- a/test/rdoc/test_rdoc_markup_formatter.rb +++ b/test/rdoc/test_rdoc_markup_formatter.rb @@ -19,8 +19,8 @@ class TestRDocMarkupFormatter < RDoc::TestCase convert_flow @am.flow text.dup end - def handle_special_CAPS special - "handled #{special.text}" + def handle_regexp_CAPS target + "handled #{target.text}" end def start_accepting @@ -37,16 +37,16 @@ class TestRDocMarkupFormatter < RDoc::TestCase super @markup = @RM.new - @markup.add_special(/[A-Z]+/, :CAPS) + @markup.add_regexp_handling(/[A-Z]+/, :CAPS) @attribute_manager = @markup.attribute_manager @attributes = @attribute_manager.attributes @to = ToTest.new @markup - @caps = @attributes.bitmap_for :CAPS - @special = @attributes.bitmap_for :_SPECIAL_ - @tt = @attributes.bitmap_for :TT + @caps = @attributes.bitmap_for :CAPS + @regexp_handling = @attributes.bitmap_for :_REGEXP_HANDLING_ + @tt = @attributes.bitmap_for :TT end def test_class_gen_relative_url @@ -62,19 +62,19 @@ class TestRDocMarkupFormatter < RDoc::TestCase assert_equal 'a/c.html', gen('a.html', 'a/c.html') end - def special_names - @attribute_manager.special.map do |_, mask| + def regexp_handling_names + @attribute_manager.regexp_handlings.map do |_, mask| @attributes.as_string mask end end - def test_add_special_RDOCLINK - @to.add_special_RDOCLINK + def test_add_regexp_handling_RDOCLINK + @to.add_regexp_handling_RDOCLINK - assert_includes special_names, 'RDOCLINK' + assert_includes regexp_handling_names, 'RDOCLINK' - def @to.handle_special_RDOCLINK special - "<#{special.text}>" + def @to.handle_regexp_RDOCLINK target + "<#{target.text}>" end document = doc(para('{foo}[rdoc-label:bar].')) @@ -84,13 +84,13 @@ class TestRDocMarkupFormatter < RDoc::TestCase assert_equal '{foo}[<rdoc-label:bar>].', formatted end - def test_add_special_TIDYLINK - @to.add_special_TIDYLINK + def test_add_regexp_handling_TIDYLINK + @to.add_regexp_handling_TIDYLINK - assert_includes special_names, 'TIDYLINK' + assert_includes regexp_handling_names, 'TIDYLINK' - def @to.handle_special_TIDYLINK special - "<#{special.text}>" + def @to.handle_regexp_TIDYLINK target + "<#{target.text}>" end document = doc(para('foo[rdoc-label:bar].')) @@ -166,7 +166,7 @@ class TestRDocMarkupFormatter < RDoc::TestCase assert_nil id end - def test_convert_tt_special + def test_convert_tt_regexp_handling converted = @to.convert '<code>AAA</code>' assert_equal '<code>AAA</code>', converted diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb index 59889dcc5a..c30c89a7e3 100644 --- a/test/rdoc/test_rdoc_markup_to_html.rb +++ b/test/rdoc/test_rdoc_markup_to_html.rb @@ -395,7 +395,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase @to.accept_paragraph para("hello\n", "world\n") - assert_equal "\n<p>hello world</p>\n", @to.res.join + assert_equal "\n<p>hello world </p>\n", @to.res.join end def test_accept_heading_output_decoration @@ -727,18 +727,18 @@ EXPECTED assert_equal '<img src="https://example.com/image.png" />', @to.gen_url('https://example.com/image.png', 'ignored') end - def test_handle_special_HYPERLINK_link - special = RDoc::Markup::Special.new 0, 'link:README.txt' + def test_handle_regexp_HYPERLINK_link + target = RDoc::Markup::RegexpHandling.new 0, 'link:README.txt' - link = @to.handle_special_HYPERLINK special + link = @to.handle_regexp_HYPERLINK target assert_equal '<a href="README.txt">README.txt</a>', link end - def test_handle_special_HYPERLINK_irc - special = RDoc::Markup::Special.new 0, 'irc://irc.freenode.net/#ruby-lang' + def test_handle_regexp_HYPERLINK_irc + target = RDoc::Markup::RegexpHandling.new 0, 'irc://irc.freenode.net/#ruby-lang' - link = @to.handle_special_HYPERLINK special + link = @to.handle_regexp_HYPERLINK target assert_equal '<a href="irc://irc.freenode.net/#ruby-lang">irc.freenode.net/#ruby-lang</a>', link end diff --git a/test/rdoc/test_rdoc_markup_to_html_crossref.rb b/test/rdoc/test_rdoc_markup_to_html_crossref.rb index 63fc95ff51..19cc6a8ec1 100644 --- a/test/rdoc/test_rdoc_markup_to_html_crossref.rb +++ b/test/rdoc/test_rdoc_markup_to_html_crossref.rb @@ -116,66 +116,66 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase @to.gen_url('http://example', 'HTTP example') end - def test_handle_special_CROSSREF - assert_equal "<a href=\"C2/C3.html\">C2::C3</a>", SPECIAL('C2::C3') + def test_handle_regexp_CROSSREF + assert_equal "<a href=\"C2/C3.html\">C2::C3</a>", REGEXP_HANDLING('C2::C3') end - def test_handle_special_CROSSREF_label + def test_handle_regexp_CROSSREF_label assert_equal "<a href=\"C1.html#method-i-m-label-foo\">foo at C1#m</a>", - SPECIAL('C1#m@foo') + REGEXP_HANDLING('C1#m@foo') end - def test_handle_special_CROSSREF_show_hash_false + def test_handle_regexp_CROSSREF_show_hash_false @to.show_hash = false assert_equal "<a href=\"C1.html#method-i-m\">m</a>", - SPECIAL('#m') + REGEXP_HANDLING('#m') end - def test_handle_special_HYPERLINK_rdoc + def test_handle_regexp_HYPERLINK_rdoc readme = @store.add_file 'README.txt' readme.parser = RDoc::Parser::Simple @to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2 - link = @to.handle_special_HYPERLINK hyper 'C2::C3' + link = @to.handle_regexp_HYPERLINK hyper 'C2::C3' assert_equal '<a href="C2/C3.html">C2::C3</a>', link - link = @to.handle_special_HYPERLINK hyper 'C4' + link = @to.handle_regexp_HYPERLINK hyper 'C4' assert_equal '<a href="C4.html">C4</a>', link - link = @to.handle_special_HYPERLINK hyper 'README.txt' + link = @to.handle_regexp_HYPERLINK hyper 'README.txt' assert_equal '<a href="README_txt.html">README.txt</a>', link end - def test_handle_special_TIDYLINK_rdoc + def test_handle_regexp_TIDYLINK_rdoc readme = @store.add_file 'README.txt' readme.parser = RDoc::Parser::Simple @to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2 - link = @to.handle_special_TIDYLINK tidy 'C2::C3' + link = @to.handle_regexp_TIDYLINK tidy 'C2::C3' assert_equal '<a href="C2/C3.html">tidy</a>', link - link = @to.handle_special_TIDYLINK tidy 'C4' + link = @to.handle_regexp_TIDYLINK tidy 'C4' assert_equal '<a href="C4.html">tidy</a>', link - link = @to.handle_special_TIDYLINK tidy 'C1#m' + link = @to.handle_regexp_TIDYLINK tidy 'C1#m' assert_equal '<a href="C1.html#method-i-m">tidy</a>', link - link = @to.handle_special_TIDYLINK tidy 'README.txt' + link = @to.handle_regexp_TIDYLINK tidy 'README.txt' assert_equal '<a href="README_txt.html">tidy</a>', link end - def test_handle_special_TIDYLINK_label - link = @to.handle_special_TIDYLINK tidy 'C1#m@foo' + def test_handle_regexp_TIDYLINK_label + link = @to.handle_regexp_TIDYLINK tidy 'C1#m@foo' assert_equal "<a href=\"C1.html#method-i-m-label-foo\">tidy</a>", link, 'C1#m@foo' @@ -217,20 +217,20 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase "\n<p>#{text}</p>\n" end - def SPECIAL text - @to.handle_special_CROSSREF special text + def REGEXP_HANDLING text + @to.handle_regexp_CROSSREF regexp_handling text end def hyper reference - RDoc::Markup::Special.new 0, "rdoc-ref:#{reference}" + RDoc::Markup::RegexpHandling.new 0, "rdoc-ref:#{reference}" end - def special text - RDoc::Markup::Special.new 0, text + def regexp_handling text + RDoc::Markup::RegexpHandling.new 0, text end def tidy reference - RDoc::Markup::Special.new 0, "{tidy}[rdoc-ref:#{reference}]" + RDoc::Markup::RegexpHandling.new 0, "{tidy}[rdoc-ref:#{reference}]" end end diff --git a/test/rdoc/test_rdoc_markup_to_html_snippet.rb b/test/rdoc/test_rdoc_markup_to_html_snippet.rb index 98102ba553..7e01413dda 100644 --- a/test/rdoc/test_rdoc_markup_to_html_snippet.rb +++ b/test/rdoc/test_rdoc_markup_to_html_snippet.rb @@ -458,8 +458,7 @@ So there you have it expected = <<-EXPECTED <p>Hello -<p>This is some text, it <strong>will</strong> be cut off after 100 characters -and an ellipsis must follow +<p>This is some text, it <strong>will</strong> be cut off after 100 characters and an ellipsis must follow <p>So there you #{@ellipsis} EXPECTED @@ -563,8 +562,7 @@ NOTE: Given Foo::Bar, Bar is considered a class even though it may be a RDOC expected = <<-EXPECTED -<p>Extracts the class, selector and method name parts from <code>name</code> -like Foo::Bar#baz. +<p>Extracts the class, selector and method name parts from <code>name</code> like Foo::Bar#baz. <p>NOTE: Given Foo::Bar, #{@ellipsis} EXPECTED @@ -652,10 +650,10 @@ This routine modifies its +comment+ parameter. assert_equal 3, @to.characters end - def test_handle_special_HYPERLINK_link - special = RDoc::Markup::Special.new 0, 'link:README.txt' + def test_handle_regexp_HYPERLINK_link + target = RDoc::Markup::RegexpHandling.new 0, 'link:README.txt' - link = @to.handle_special_HYPERLINK special + link = @to.handle_regexp_HYPERLINK target assert_equal 'README.txt', link end diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb index 8a3e723614..8188318769 100644 --- a/test/rdoc/test_rdoc_parser_ruby.rb +++ b/test/rdoc/test_rdoc_parser_ruby.rb @@ -495,6 +495,43 @@ ruby assert_equal 'my attr', bar.comment.text end + def test_parse_attr_accessor_with_newline + klass = RDoc::NormalClass.new 'Foo' + klass.parent = @top_level + + comment = RDoc::Comment.new "##\n# my attr\n", @top_level + + util_parser "attr_accessor :foo, :bar,\n :baz,\n :qux" + + tk = @parser.get_tk + + @parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment + + assert_equal 4, klass.attributes.length + + foo = klass.attributes[0] + assert_equal 'foo', foo.name + assert_equal 'RW', foo.rw + assert_equal 'my attr', foo.comment.text + assert_equal @top_level, foo.file + assert_equal 1, foo.line + + bar = klass.attributes[1] + assert_equal 'bar', bar.name + assert_equal 'RW', bar.rw + assert_equal 'my attr', bar.comment.text + + bar = klass.attributes[2] + assert_equal 'baz', bar.name + assert_equal 'RW', bar.rw + assert_equal 'my attr', bar.comment.text + + bar = klass.attributes[3] + assert_equal 'qux', bar.name + assert_equal 'RW', bar.rw + assert_equal 'my attr', bar.comment.text + end + def test_parse_attr_accessor_nodoc klass = RDoc::NormalClass.new 'Foo' klass.parent = @top_level @@ -2848,6 +2885,35 @@ EXPECTED assert_equal expected, markup_code end + def test_parse_mutable_heredocbeg + @filename = 'file.rb' + util_parser <<RUBY +class Foo + def blah() + @str = -<<-EOM + EOM + end +end +RUBY + + expected = <<EXPECTED + <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">blah</span>() + <span class="ruby-ivar">@str</span> = <span class="ruby-identifier">-<<-EOM</span> +<span class="ruby-value"></span><span class="ruby-identifier"> EOM</span> + <span class="ruby-keyword">end</span> +EXPECTED + expected = expected.rstrip + + @parser.scan + + foo = @top_level.classes.first + assert_equal 'Foo', foo.full_name + + blah = foo.method_list.first + markup_code = blah.markup_code.sub(/^.*\n/, '') + assert_equal expected, markup_code + end + def test_parse_statements_method_oneliner_with_regexp util_parser <<RUBY class Foo diff --git a/test/rdoc/test_rdoc_servlet.rb b/test/rdoc/test_rdoc_servlet.rb index c0c0869293..0a197a31b6 100644 --- a/test/rdoc/test_rdoc_servlet.rb +++ b/test/rdoc/test_rdoc_servlet.rb @@ -224,8 +224,7 @@ class TestRDocServlet < RDoc::TestCase generator = @s.generator_for store - readme = store.add_file 'README.rdoc' - readme.parser = RDoc::Parser::Simple + readme = store.add_file 'README.rdoc', parser: RDoc::Parser::Simple @s.documentation_page store, generator, 'README_rdoc.html', @req, @res diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb index e5cf75203f..5a884c0b5f 100644 --- a/test/rdoc/test_rdoc_store.rb +++ b/test/rdoc/test_rdoc_store.rb @@ -14,8 +14,7 @@ class TestRDocStore < XrefTestCase @top_level = @s.add_file 'file.rb' - @page = @s.add_file 'README.txt' - @page.parser = RDoc::Parser::Simple + @page = @s.add_file 'README.txt', parser: RDoc::Parser::Simple @page.comment = RDoc::Comment.new 'This is a page', @page @klass = @top_level.add_class RDoc::NormalClass, 'Object' @@ -146,7 +145,7 @@ class TestRDocStore < XrefTestCase end def test_add_file_relative - top_level = @store.add_file 'path/file.rb', 'file.rb' + top_level = @store.add_file 'path/file.rb', relative_name: 'file.rb' assert_kind_of RDoc::TopLevel, top_level assert_equal @store, top_level.store @@ -310,8 +309,7 @@ class TestRDocStore < XrefTestCase end def test_find_text_page - page = @store.add_file 'PAGE.txt' - page.parser = RDoc::Parser::Simple + page = @store.add_file 'PAGE.txt', parser: RDoc::Parser::Simple assert_nil @store.find_text_page 'no such page' @@ -601,8 +599,7 @@ class TestRDocStore < XrefTestCase end def test_page - page = @store.add_file 'PAGE.txt' - page.parser = RDoc::Parser::Simple + page = @store.add_file 'PAGE.txt', parser: RDoc::Parser::Simple assert_nil @store.page 'no such page' diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb index 61f528a5a4..2669766e71 100644 --- a/test/rdoc/test_rdoc_text.rb +++ b/test/rdoc/test_rdoc_text.rb @@ -259,8 +259,7 @@ paragraph will be cut off some point after the one-hundredth character. TEXT expected = <<-EXPECTED -<p>This is one-hundred characters or more of text in a single paragraph. This -paragraph will be cut off … +<p>This is one-hundred characters or more of text in a single paragraph. This paragraph will be cut off … EXPECTED assert_equal expected, snippet(text) |