summaryrefslogtreecommitdiff
path: root/test/rdoc
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-07 01:22:37 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-07 01:22:37 +0000
commit4260aa1dc399e1bb4a2147409ed1139112cfefb8 (patch)
tree72b378fdcef83d532147bb6deeafe2ad55134f3e /test/rdoc
parent7d2d6d0a2f600943ab484238b4722036151376a5 (diff)
* 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
Diffstat (limited to 'test/rdoc')
-rw-r--r--test/rdoc/test_rdoc_generator_darkfish.rb4
-rw-r--r--test/rdoc/test_rdoc_generator_json_index.rb55
-rw-r--r--test/rdoc/test_rdoc_generator_markup.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_attribute_manager.rb3
-rw-r--r--test/rdoc/test_rdoc_markup_heading.rb8
-rw-r--r--test/rdoc/test_rdoc_markup_to_html.rb72
-rw-r--r--test/rdoc/test_rdoc_markup_to_html_snippet.rb15
-rw-r--r--test/rdoc/test_rdoc_markup_to_label.rb8
-rw-r--r--test/rdoc/test_rdoc_single_class.rb18
-rw-r--r--test/rdoc/test_rdoc_stats.rb55
10 files changed, 191 insertions, 49 deletions
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 = '<span><a href="#label-Hello">&para;</a> ' +
- '<a href="#documentation">&uarr;</a></span>'
+ '<a href="#top">&uarr;</a></span>'
assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\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 = '<span><a href="#label-Hello">&para;</a> ' +
- '<a href="#documentation">&uarr;</a></span>'
+ '<a href="#top">&uarr;</a></span>'
expected = "\n<h5 id=\"label-Hello\">Hello#{links}</h5>\n"
assert_equal expected, @to.res.join
@@ -32,35 +32,35 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
def accept_heading_1
links = '<span><a href="#label-Hello">&para;</a> ' +
- '<a href="#documentation">&uarr;</a></span>'
+ '<a href="#top">&uarr;</a></span>'
assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", @to.res.join
end
def accept_heading_2
links = '<span><a href="#label-Hello">&para;</a> ' +
- '<a href="#documentation">&uarr;</a></span>'
+ '<a href="#top">&uarr;</a></span>'
assert_equal "\n<h2 id=\"label-Hello\">Hello#{links}</h2>\n", @to.res.join
end
def accept_heading_3
links = '<span><a href="#label-Hello">&para;</a> ' +
- '<a href="#documentation">&uarr;</a></span>'
+ '<a href="#top">&uarr;</a></span>'
assert_equal "\n<h3 id=\"label-Hello\">Hello#{links}</h3>\n", @to.res.join
end
def accept_heading_4
links = '<span><a href="#label-Hello">&para;</a> ' +
- '<a href="#documentation">&uarr;</a></span>'
+ '<a href="#top">&uarr;</a></span>'
assert_equal "\n<h4 id=\"label-Hello\">Hello#{links}</h4>\n", @to.res.join
end
def accept_heading_b
links = '<span><a href="#label-Hello">&para;</a> ' +
- '<a href="#documentation">&uarr;</a></span>'
+ '<a href="#top">&uarr;</a></span>'
inner = "<strong>Hello</strong>"
assert_equal "\n<h1 id=\"label-Hello\">#{inner}#{links}</h1>\n",
@@ -69,7 +69,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
def accept_heading_suppressed_crossref
links = '<span><a href="#label-Hello">&para;</a> ' +
- '<a href="#documentation">&uarr;</a></span>'
+ '<a href="#top">&uarr;</a></span>'
assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", @to.res.join
end
@@ -292,7 +292,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
end
def accept_verbatim
- assert_equal "\n<pre>hi\n world</pre>\n", @to.res.join
+ assert_equal "\n<pre class=\"ruby\"><span class=\"ruby-identifier\">hi</span>\n <span class=\"ruby-identifier\">world</span>\n</pre>\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 = '<span><a href="#label-Hello">&para;</a> ' +
- '<a href="#documentation">&uarr;</a></span>'
+ '<a href="#top">&uarr;</a></span>'
assert_equal "\n<h6 id=\"label-Hello\">Hello#{links}</h6>\n", @to.res.join
end
@@ -360,7 +360,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@to.accept_heading head(1, 'Hello')
links = '<span><a href="#class-Foo-label-Hello">&para;</a> ' +
- '<a href="#documentation">&uarr;</a></span>'
+ '<a href="#top">&uarr;</a></span>'
assert_equal "\n<h1 id=\"class-Foo-label-Hello\">Hello#{links}</h1>\n",
@to.res.join
@@ -373,7 +373,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@to.accept_heading @RM::Heading.new(1, 'Hello')
links = '<span><a href="#method-i-foo-label-Hello">&para;</a> ' +
- '<a href="#documentation">&uarr;</a></span>'
+ '<a href="#top">&uarr;</a></span>'
assert_equal "\n<h1 id=\"method-i-foo-label-Hello\">Hello#{links}</h1>\n",
@to.res.join
@@ -404,7 +404,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@to.accept_heading @RM::Heading.new(1, 'Hello')
- assert_equal "\n<h1>Hello<span><a href=\"#label-Hello\">&para;</a> <a href=\"#documentation\">&uarr;</a></span></h1>\n", @to.res.join
+ assert_equal "\n<h1>Hello<span><a href=\"#label-Hello\">&para;</a> <a href=\"#top\">&uarr;</a></span></h1>\n", @to.res.join
end
def test_accept_heading_output_decoration_with_pipe
@@ -444,8 +444,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
expected = <<-EXPECTED
-<pre>#{inner}
-</pre>
+<pre>#{inner}</pre>
EXPECTED
assert_equal expected, @to.res.join
@@ -604,8 +603,9 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
<ul><li>
<p>one</p>
-<pre>verb1
-verb2</pre>
+<pre class=\"ruby\"><span class=\"ruby-identifier\">verb1</span>
+<span class=\"ruby-identifier\">verb2</span>
+</pre>
</li><li>
<p>two</p>
</li></ul>
@@ -615,16 +615,36 @@ verb2</pre>
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<pre>hi\n world</pre>\n", @to.res.join
+ assert_equal "\n<pre class=\"ruby\"><span class=\"ruby-identifier\">hi</span>\n <span class=\"ruby-identifier\">world</span>\n</pre>\n", @to.res.join
assert_equal 10, @to.characters
end
@@ -427,8 +427,7 @@ class TestRDocMarkupToHtmlSnippet < RDoc::Markup::FormatterTestCase
expected = <<-EXPECTED
-<pre>#{inner}
-</pre>
+<pre>#{inner}</pre>
EXPECTED
assert_equal expected, @to.res.join
@@ -588,8 +587,9 @@ This routine modifies its +comment+ parameter.
expected = <<-EXPECTED
<p>Look for directives in a normal comment block:
-<pre># :stopdoc:
-#{inner}</pre>
+<pre class=\"ruby\"><span class=\"ruby-comment\"># :stopdoc:</span>
+<span class=\"ruby-comment\">#{inner}</span>
+</pre>
EXPECTED
actual = @to.convert rdoc
@@ -665,8 +665,9 @@ This routine modifies its +comment+ parameter.
expected = <<-EXPECTED
<p>one
-<pre>verb1
-verb2</pre>
+<pre class=\"ruby\"><span class=\"ruby-identifier\">verb1</span>
+<span class=\"ruby-identifier\">verb2</span>
+</pre>
<p>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