From 4260aa1dc399e1bb4a2147409ed1139112cfefb8 Mon Sep 17 00:00:00 2001 From: drbrain Date: Sun, 7 Dec 2014 01:22:37 +0000 Subject: * lib/rdoc: Update to RDoc 4.2.0. * test/rdoc: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rdoc/test_rdoc_generator_darkfish.rb | 4 +- test/rdoc/test_rdoc_generator_json_index.rb | 55 +++++++++++++++++++ test/rdoc/test_rdoc_generator_markup.rb | 2 +- test/rdoc/test_rdoc_markup_attribute_manager.rb | 3 ++ test/rdoc/test_rdoc_markup_heading.rb | 8 +-- test/rdoc/test_rdoc_markup_to_html.rb | 72 ++++++++++++++++--------- test/rdoc/test_rdoc_markup_to_html_snippet.rb | 15 +++--- test/rdoc/test_rdoc_markup_to_label.rb | 8 +-- test/rdoc/test_rdoc_single_class.rb | 18 +++++-- test/rdoc/test_rdoc_stats.rb | 55 +++++++++++++++++++ 10 files changed, 191 insertions(+), 49 deletions(-) (limited to 'test/rdoc') diff --git a/test/rdoc/test_rdoc_generator_darkfish.rb b/test/rdoc/test_rdoc_generator_darkfish.rb index 79c52f0805..fc77e4b105 100644 --- a/test/rdoc/test_rdoc_generator_darkfish.rb +++ b/test/rdoc/test_rdoc_generator_darkfish.rb @@ -76,8 +76,8 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase assert_file 'table_of_contents.html' assert_file 'js/search_index.js' - assert_hard_link 'rdoc.css' - assert_hard_link 'fonts.css' + assert_hard_link 'css/rdoc.css' + assert_hard_link 'css/fonts.css' assert_hard_link 'fonts/SourceCodePro-Bold.ttf' assert_hard_link 'fonts/SourceCodePro-Regular.ttf' diff --git a/test/rdoc/test_rdoc_generator_json_index.rb b/test/rdoc/test_rdoc_generator_json_index.rb index 214e4a0d91..f25ee27d5e 100644 --- a/test/rdoc/test_rdoc_generator_json_index.rb +++ b/test/rdoc/test_rdoc_generator_json_index.rb @@ -136,6 +136,61 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase assert_equal expected, index end + def test_generate_gzipped + require 'zlib' + @g.generate + @g.generate_gzipped + + assert_file 'js/searcher.js' + assert_file 'js/searcher.js.gz' + assert_file 'js/navigation.js' + assert_file 'js/navigation.js.gz' + assert_file 'js/search_index.js' + assert_file 'js/search_index.js.gz' + + gzip = File.open 'js/search_index.js.gz' + json = Zlib::GzipReader.new(gzip).read + + json =~ /\Avar search_data = / + + assignment = $& + index = $' + + refute_empty assignment + + index = JSON.parse index + + info = [ + @klass.search_record[2..-1], + @nest_klass.search_record[2..-1], + @meth.search_record[2..-1], + @nest_meth.search_record[2..-1], + @page.search_record[2..-1], + ] + + expected = { + 'index' => { + 'searchIndex' => [ + 'c', + 'd', + 'meth()', + 'meth()', + 'page', + ], + 'longSearchIndex' => [ + 'c', + 'c::d', + 'c#meth()', + 'c::d#meth()', + '', + ], + 'info' => info, + }, + } + + assert_equal expected, index + end + def test_generate_utf_8 skip "Encoding not implemented" unless Object.const_defined? :Encoding diff --git a/test/rdoc/test_rdoc_generator_markup.rb b/test/rdoc/test_rdoc_generator_markup.rb index b3b5c04588..5f8a45bd0e 100644 --- a/test/rdoc/test_rdoc_generator_markup.rb +++ b/test/rdoc/test_rdoc_generator_markup.rb @@ -38,7 +38,7 @@ class TestRDocGeneratorMarkup < RDoc::TestCase @comment = '= Hello' links = ' ' + - '' + '' assert_equal "\n

Hello#{links}

\n", description end diff --git a/test/rdoc/test_rdoc_markup_attribute_manager.rb b/test/rdoc/test_rdoc_markup_attribute_manager.rb index 34615aa625..6a085fe7f5 100644 --- a/test/rdoc/test_rdoc_markup_attribute_manager.rb +++ b/test/rdoc/test_rdoc_markup_attribute_manager.rb @@ -141,6 +141,9 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase assert_equal(["cat ", @em_on, "_", @em_off, " dog"], @am.flow("cat ___ dog")) + + assert_equal(["cat and ", @em_on, "5", @em_off, " dogs"], + @am.flow("cat and _5_ dogs")) end def test_bold diff --git a/test/rdoc/test_rdoc_markup_heading.rb b/test/rdoc/test_rdoc_markup_heading.rb index ff53ff5ac3..26d4b5bffc 100644 --- a/test/rdoc/test_rdoc_markup_heading.rb +++ b/test/rdoc/test_rdoc_markup_heading.rb @@ -9,16 +9,16 @@ class TestRDocMarkupHeading < RDoc::TestCase end def test_aref - assert_equal 'label-Hello+Friend%21', @h.aref + assert_equal 'label-Hello+Friend-21', @h.aref end def test_label - assert_equal 'label-Hello+Friend%21', @h.label - assert_equal 'label-Hello+Friend%21', @h.label(nil) + assert_equal 'label-Hello+Friend-21', @h.label + assert_equal 'label-Hello+Friend-21', @h.label(nil) context = RDoc::NormalClass.new 'Foo' - assert_equal 'class-Foo-label-Hello+Friend%21', @h.label(context) + assert_equal 'class-Foo-label-Hello+Friend-21', @h.label(context) end def test_plain_html diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb index b1addc5dcb..1e4b84fe9e 100644 --- a/test/rdoc/test_rdoc_markup_to_html.rb +++ b/test/rdoc/test_rdoc_markup_to_html.rb @@ -24,7 +24,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase def accept_heading links = ' ' + - '' + '' expected = "\n
Hello#{links}
\n" assert_equal expected, @to.res.join @@ -32,35 +32,35 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase def accept_heading_1 links = ' ' + - '' + '' assert_equal "\n

Hello#{links}

\n", @to.res.join end def accept_heading_2 links = ' ' + - '' + '' assert_equal "\n

Hello#{links}

\n", @to.res.join end def accept_heading_3 links = ' ' + - '' + '' assert_equal "\n

Hello#{links}

\n", @to.res.join end def accept_heading_4 links = ' ' + - '' + '' assert_equal "\n

Hello#{links}

\n", @to.res.join end def accept_heading_b links = ' ' + - '' + '' inner = "Hello" assert_equal "\n

#{inner}#{links}

\n", @@ -69,7 +69,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase def accept_heading_suppressed_crossref links = ' ' + - '' + '' assert_equal "\n

Hello#{links}

\n", @to.res.join end @@ -292,7 +292,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase end def accept_verbatim - assert_equal "\n
hi\n  world
\n", @to.res.join + assert_equal "\n
hi\n  world\n
\n", @to.res.join end def end_accepting @@ -348,7 +348,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase @to.accept_heading @RM::Heading.new(7, 'Hello') links = ' ' + - '' + '' assert_equal "\n
Hello#{links}
\n", @to.res.join end @@ -360,7 +360,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase @to.accept_heading head(1, 'Hello') links = ' ' + - '' + '' assert_equal "\n

Hello#{links}

\n", @to.res.join @@ -373,7 +373,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase @to.accept_heading @RM::Heading.new(1, 'Hello') links = ' ' + - '' + '' assert_equal "\n

Hello#{links}

\n", @to.res.join @@ -404,7 +404,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase @to.accept_heading @RM::Heading.new(1, 'Hello') - assert_equal "\n

Hello

\n", @to.res.join + assert_equal "\n

Hello

\n", @to.res.join end def test_accept_heading_output_decoration_with_pipe @@ -444,8 +444,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase expected = <<-EXPECTED -
#{inner}
-
+
#{inner}
EXPECTED assert_equal expected, @to.res.join @@ -604,8 +603,9 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase @@ -615,16 +615,36 @@ verb2 end def test_parseable_eh - assert @to.parseable?('def x() end'), 'def' - assert @to.parseable?('class C end'), 'class' - assert @to.parseable?('module M end'), 'module' - assert @to.parseable?('a # => blah'), '=>' - assert @to.parseable?('x { |y| ... }'), '{ |x|' - assert @to.parseable?('x do |y| ... end'), 'do |x|' - refute @to.parseable?('* 1'), '* 1' - refute @to.parseable?('# only a comment'), '# only a comment' - refute @to.parseable?('<% require "foo" %>'), 'ERB' - refute @to.parseable?('class="foo"'), 'HTML class' + valid_syntax = [ + 'def x() end', + 'def x; end', + 'class C; end', + "module M end", + 'a # => blah', + 'x { |y| nil }', + 'x do |y| nil end', + '# only a comment', + 'require "foo"', + 'cls="foo"' + ] + invalid_syntax = [ + 'def x end', + 'class C end', + 'class C < end', + 'module M < C end', + 'a=># blah', + 'x { |y| ... }', + 'x do |y| ... end', + '// only a comment', + '<% require "foo" %>', + 'class="foo"' + ] + valid_syntax.each do |t| + assert @to.parseable?(t), "valid syntax considered invalid: #{t}" + end + invalid_syntax.each do |t| + refute @to.parseable?(t), "invalid syntax considered valid: #{t}" + end end def test_to_html diff --git a/test/rdoc/test_rdoc_markup_to_html_snippet.rb b/test/rdoc/test_rdoc_markup_to_html_snippet.rb index 4bb8ed1b47..f861db1849 100644 --- a/test/rdoc/test_rdoc_markup_to_html_snippet.rb +++ b/test/rdoc/test_rdoc_markup_to_html_snippet.rb @@ -309,7 +309,7 @@ class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase end def accept_verbatim - assert_equal "\n
hi\n  world
\n", @to.res.join + assert_equal "\n
hi\n  world\n
\n", @to.res.join assert_equal 10, @to.characters end @@ -427,8 +427,7 @@ class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase expected = <<-EXPECTED -
#{inner}
-
+
#{inner}
EXPECTED assert_equal expected, @to.res.join @@ -588,8 +587,9 @@ This routine modifies its +comment+ parameter. expected = <<-EXPECTED

Look for directives in a normal comment block: -

# :stopdoc:
-#{inner}
+
# :stopdoc:
+#{inner}
+
EXPECTED actual = @to.convert rdoc @@ -665,8 +665,9 @@ This routine modifies its +comment+ parameter. expected = <<-EXPECTED

one -

verb1
-verb2
+
verb1
+verb2
+

two EXPECTED diff --git a/test/rdoc/test_rdoc_markup_to_label.rb b/test/rdoc/test_rdoc_markup_to_label.rb index 5fb358bee3..d8cc365069 100644 --- a/test/rdoc/test_rdoc_markup_to_label.rb +++ b/test/rdoc/test_rdoc_markup_to_label.rb @@ -82,8 +82,8 @@ class TestRDocMarkupToLabel < RDoc::Markup::FormatterTestCase assert_equal 'some_method', @to.convert('some_method') assert_equal 'some_method', @to.convert('\\some_method') - assert_equal '%23some_method', @to.convert('#some_method') - assert_equal '%23some_method', @to.convert('\\#some_method') + assert_equal '23some_method', @to.convert('#some_method') + assert_equal '23some_method', @to.convert('\\#some_method') end def test_convert_em @@ -92,11 +92,11 @@ class TestRDocMarkupToLabel < RDoc::Markup::FormatterTestCase end def test_convert_em_dash # for HTML conversion - assert_equal '--', @to.convert('--') + assert_equal '-', @to.convert('--') end def test_convert_escape - assert_equal 'a+%3E+b', @to.convert('a > b') + assert_equal 'a+-3E+b', @to.convert('a > b') end def test_convert_tidylink diff --git a/test/rdoc/test_rdoc_single_class.rb b/test/rdoc/test_rdoc_single_class.rb index d0c71e9eeb..e368b3d6fd 100644 --- a/test/rdoc/test_rdoc_single_class.rb +++ b/test/rdoc/test_rdoc_single_class.rb @@ -1,11 +1,19 @@ -require File.expand_path '../xref_test_case', __FILE__ +require 'rdoc/test_case' -class TestRDocSingleClass < XrefTestCase +class TestRDocSingleClass < RDoc::TestCase - def test_definition - c = RDoc::SingleClass.new 'C' + def setup + super + + @c = RDoc::SingleClass.new 'C' + end - assert_equal 'class << C', c.definition + def test_aref_prefix + assert_equal 'sclass', @c.aref_prefix + end + + def test_definition + assert_equal 'class << C', @c.definition end end diff --git a/test/rdoc/test_rdoc_stats.rb b/test/rdoc/test_rdoc_stats.rb index 7d336bedc8..cd37c29fce 100644 --- a/test/rdoc/test_rdoc_stats.rb +++ b/test/rdoc/test_rdoc_stats.rb @@ -663,5 +663,60 @@ m(a, b) { |c, d| ... } RDoc::Markup::ToRdoc.new end + def test_undoc_params + method = RDoc::AnyMethod.new [], 'm' + method.params = '(a)' + method.comment = comment 'comment' + + total, undoc = @s.undoc_params method + + assert_equal 1, total + assert_equal %w[a], undoc + end + + def test_undoc_params_block + method = RDoc::AnyMethod.new [], 'm' + method.params = '(&a)' + method.comment = comment '+a+' + + total, undoc = @s.undoc_params method + + assert_equal 1, total + assert_empty undoc + end + + def test_undoc_params_documented + method = RDoc::AnyMethod.new [], 'm' + method.params = '(a)' + method.comment = comment '+a+' + + total, undoc = @s.undoc_params method + + assert_equal 1, total + assert_empty undoc + end + + def test_undoc_params_keywords + method = RDoc::AnyMethod.new [], 'm' + method.params = '(**a)' + method.comment = comment '+a+' + + total, undoc = @s.undoc_params method + + assert_equal 1, total + assert_empty undoc + end + + def test_undoc_params_splat + method = RDoc::AnyMethod.new [], 'm' + method.params = '(*a)' + method.comment = comment '+a+' + + total, undoc = @s.undoc_params method + + assert_equal 1, total + assert_empty undoc + end + end -- cgit v1.2.3