summaryrefslogtreecommitdiff
path: root/test/rdoc
diff options
context:
space:
mode:
Diffstat (limited to 'test/rdoc')
-rw-r--r--test/rdoc/helper.rb6
-rw-r--r--test/rdoc/support/test_case.rb6
-rw-r--r--test/rdoc/support/text_formatter_test_case.rb1
-rw-r--r--test/rdoc/test_rdoc_alias.rb3
-rw-r--r--test/rdoc/test_rdoc_any_method.rb54
-rw-r--r--test/rdoc/test_rdoc_class_module.rb3
-rw-r--r--test/rdoc/test_rdoc_code_object.rb2
-rw-r--r--test/rdoc/test_rdoc_comment.rb9
-rw-r--r--test/rdoc/test_rdoc_constant.rb2
-rw-r--r--test/rdoc/test_rdoc_context.rb8
-rw-r--r--test/rdoc/test_rdoc_context_section.rb1
-rw-r--r--test/rdoc/test_rdoc_cross_reference.rb49
-rw-r--r--test/rdoc/test_rdoc_extend.rb3
-rw-r--r--test/rdoc/test_rdoc_generator_darkfish.rb109
-rw-r--r--test/rdoc/test_rdoc_generator_json_index.rb14
-rw-r--r--test/rdoc/test_rdoc_generator_markup.rb1
-rw-r--r--test/rdoc/test_rdoc_include.rb3
-rw-r--r--test/rdoc/test_rdoc_markdown.rb46
-rw-r--r--test/rdoc/test_rdoc_markdown_test.rb4
-rw-r--r--test/rdoc/test_rdoc_markup.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_attribute_manager.rb3
-rw-r--r--test/rdoc/test_rdoc_markup_attributes.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_document.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_formatter.rb6
-rw-r--r--test/rdoc/test_rdoc_markup_hard_break.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_heading.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_include.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_indented_paragraph.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_paragraph.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_raw.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_ansi.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_html.rb142
-rw-r--r--test/rdoc/test_rdoc_markup_to_html_crossref.rb21
-rw-r--r--test/rdoc/test_rdoc_markup_to_joined_paragraph.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_label.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_markdown.rb8
-rw-r--r--test/rdoc/test_rdoc_markup_to_rdoc.rb19
-rw-r--r--test/rdoc/test_rdoc_markup_to_table_of_contents.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_tt_only.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_verbatim.rb1
-rw-r--r--test/rdoc/test_rdoc_method_attr.rb3
-rw-r--r--test/rdoc/test_rdoc_normal_class.rb3
-rw-r--r--test/rdoc/test_rdoc_normal_module.rb3
-rw-r--r--test/rdoc/test_rdoc_options.rb108
-rw-r--r--test/rdoc/test_rdoc_parser.rb14
-rw-r--r--test/rdoc/test_rdoc_parser_c.rb244
-rw-r--r--test/rdoc/test_rdoc_parser_changelog.rb1
-rw-r--r--test/rdoc/test_rdoc_parser_markdown.rb1
-rw-r--r--test/rdoc/test_rdoc_parser_rd.rb1
-rw-r--r--test/rdoc/test_rdoc_parser_ruby.rb60
-rw-r--r--test/rdoc/test_rdoc_parser_simple.rb1
-rw-r--r--test/rdoc/test_rdoc_rd.rb1
-rw-r--r--test/rdoc/test_rdoc_rd_block_parser.rb21
-rw-r--r--test/rdoc/test_rdoc_rd_inline.rb1
-rw-r--r--test/rdoc/test_rdoc_rdoc.rb57
-rw-r--r--test/rdoc/test_rdoc_require.rb3
-rw-r--r--test/rdoc/test_rdoc_ri_driver.rb51
-rw-r--r--test/rdoc/test_rdoc_ri_paths.rb1
-rw-r--r--test/rdoc/test_rdoc_rubygems_hook.rb10
-rw-r--r--test/rdoc/test_rdoc_single_class.rb1
-rw-r--r--test/rdoc/test_rdoc_stats.rb1
-rw-r--r--test/rdoc/test_rdoc_store.rb13
-rw-r--r--test/rdoc/test_rdoc_task.rb10
-rw-r--r--test/rdoc/test_rdoc_token_stream.rb53
-rw-r--r--test/rdoc/test_rdoc_top_level.rb3
-rw-r--r--test/rdoc/xref_data.rb13
-rw-r--r--test/rdoc/xref_test_case.rb1
67 files changed, 946 insertions, 271 deletions
diff --git a/test/rdoc/helper.rb b/test/rdoc/helper.rb
index 2ba26c296b..7985433060 100644
--- a/test/rdoc/helper.rb
+++ b/test/rdoc/helper.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require_relative './support/test_case'
-require_relative './support/formatter_test_case'
-require_relative './support/text_formatter_test_case'
+require_relative 'support/test_case'
+require_relative 'support/formatter_test_case'
+require_relative 'support/text_formatter_test_case'
diff --git a/test/rdoc/support/test_case.rb b/test/rdoc/support/test_case.rb
index 7617fc8471..d98dbe0d7b 100644
--- a/test/rdoc/support/test_case.rb
+++ b/test/rdoc/support/test_case.rb
@@ -13,7 +13,7 @@ require 'tempfile'
require 'tmpdir'
require 'stringio'
-require 'rdoc'
+require_relative '../../../lib/rdoc'
##
# RDoc::TestCase is an abstract TestCase to provide common setup and teardown
@@ -37,7 +37,8 @@ class RDoc::TestCase < Test::Unit::TestCase
super
@orig_home = ENV["HOME"]
- ENV["HOME"] = Dir.tmpdir
+ FileUtils.mkdir_p(@test_home = Dir.mktmpdir("test_rdoc_"))
+ ENV["HOME"] = @test_home
@top_level = nil
@@ -64,6 +65,7 @@ class RDoc::TestCase < Test::Unit::TestCase
def teardown
ENV["HOME"] = @orig_home if defined?(@orig_home)
+ defined?(@test_home) and FileUtils.rm_rf @test_home
super
end
diff --git a/test/rdoc/support/text_formatter_test_case.rb b/test/rdoc/support/text_formatter_test_case.rb
index 22a762b5f0..e359028a29 100644
--- a/test/rdoc/support/text_formatter_test_case.rb
+++ b/test/rdoc/support/text_formatter_test_case.rb
@@ -112,4 +112,3 @@ class RDoc::Markup::TextFormatterTestCase < RDoc::Markup::FormatterTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_alias.rb b/test/rdoc/test_rdoc_alias.rb
index 89ae2d5a56..3c096a49b4 100644
--- a/test/rdoc/test_rdoc_alias.rb
+++ b/test/rdoc/test_rdoc_alias.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocAlias < XrefTestCase
@@ -11,4 +11,3 @@ class TestRDocAlias < XrefTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb
index caff86b059..b11c15420c 100644
--- a/test/rdoc/test_rdoc_any_method.rb
+++ b/test/rdoc/test_rdoc_any_method.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocAnyMethod < XrefTestCase
@@ -51,10 +51,38 @@ method(a, b) { |c, d| ... }
assert_equal 'foo', m.call_seq
end
+ def test_call_seq_alias_for
+ a = RDoc::AnyMethod.new nil, "each"
+ m = RDoc::AnyMethod.new nil, "each_line"
+
+ a.call_seq = <<-CALLSEQ
+each(foo)
+each_line(foo)
+ CALLSEQ
+
+ m.is_alias_for = a
+
+ assert_equal "each_line(foo)", m.call_seq
+ end
+
def test_full_name
assert_equal 'C1::m', @c1.method_list.first.full_name
end
+ def test_has_call_seq?
+ m = RDoc::AnyMethod.new nil, "each_line"
+ m2 = RDoc::AnyMethod.new nil, "each"
+ assert_equal false, m.has_call_seq?
+ m.call_seq = "each_line()"
+ assert_equal true, m.has_call_seq?
+
+ m = RDoc::AnyMethod.new nil, "each_line"
+ m.is_alias_for = m2
+ assert_equal false, m.has_call_seq?
+ m2.call_seq = "each_line()"
+ assert_equal true, m.has_call_seq?
+ end
+
def test_is_alias_for
assert_equal @c2_b, @c2_a.is_alias_for
@@ -501,6 +529,30 @@ method(a, b) { |c, d| ... }
assert_equal 'C1', @c1.method_list.last.parent_name
end
+ def test_skip_description?
+ m = RDoc::AnyMethod.new nil, "each_line"
+ m2 = RDoc::AnyMethod.new nil, "each"
+ assert_equal false, m.skip_description?
+ assert_equal false, m2.skip_description?
+
+ m.is_alias_for = m2
+ m2.aliases << m
+ assert_equal false, m.skip_description?
+ assert_equal false, m2.skip_description?
+
+ m2.call_seq = "each()"
+ assert_equal true, m.skip_description?
+ assert_equal false, m2.skip_description?
+
+ m2.call_seq = "each_line()"
+ assert_equal false, m.skip_description?
+ assert_equal true, m2.skip_description?
+
+ m2.call_seq = "each()\neach_line()"
+ assert_equal false, m.skip_description?
+ assert_equal false, m2.skip_description?
+ end
+
def test_store_equals
loaded = Marshal.load Marshal.dump(@c1.method_list.last)
diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb
index 13021b9cc7..27d37cb7dd 100644
--- a/test/rdoc/test_rdoc_class_module.rb
+++ b/test/rdoc/test_rdoc_class_module.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocClassModule < XrefTestCase
@@ -1501,4 +1501,3 @@ class TestRDocClassModule < XrefTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_code_object.rb b/test/rdoc/test_rdoc_code_object.rb
index fad182722a..24e228cce1 100644
--- a/test/rdoc/test_rdoc_code_object.rb
+++ b/test/rdoc/test_rdoc_code_object.rb
@@ -1,7 +1,7 @@
# coding: US-ASCII
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocCodeObject < XrefTestCase
diff --git a/test/rdoc/test_rdoc_comment.rb b/test/rdoc/test_rdoc_comment.rb
index d3c16bceca..28e8cf76b4 100644
--- a/test/rdoc/test_rdoc_comment.rb
+++ b/test/rdoc/test_rdoc_comment.rb
@@ -206,6 +206,15 @@ lines, one line per element. Lines are assumed to be separated by _sep_.
assert_equal expected, comment.text
end
+ def test_extract_call_linear_performance
+ pre = ->(n) {[n, RDoc::Comment.new("\n"*n + 'call-seq:' + 'a'*n)]}
+ method_obj = RDoc::AnyMethod.new nil, 'blah'
+ assert_linear_performance((2..5).map {|i| 10**i}, pre: pre) do |n, comment|
+ comment.extract_call_seq method_obj
+ assert_equal n, method_obj.call_seq.size
+ end
+ end
+
def test_force_encoding
@comment = RDoc::Encoding.change_encoding @comment, Encoding::UTF_8
diff --git a/test/rdoc/test_rdoc_constant.rb b/test/rdoc/test_rdoc_constant.rb
index 79dcdad57e..32ffe3f84d 100644
--- a/test/rdoc/test_rdoc_constant.rb
+++ b/test/rdoc/test_rdoc_constant.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocConstant < XrefTestCase
diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb
index f77fb31383..c4de04e083 100644
--- a/test/rdoc/test_rdoc_context.rb
+++ b/test/rdoc/test_rdoc_context.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocContext < XrefTestCase
@@ -927,6 +927,12 @@ class TestRDocContext < XrefTestCase
assert_equal :private, @c6.find_method_named('priv6').visibility
assert_equal :protected, @c6.find_method_named('prot6').visibility
assert_equal :public, @c6.find_method_named('pub6').visibility
+ assert_equal :public, @c6.find_method_named('s_pub1').visibility
+ assert_equal :public, @c6.find_method_named('s_pub2').visibility
+ assert_equal :public, @c6.find_method_named('s_pub3').visibility
+ assert_equal :public, @c6.find_method_named('s_pub4').visibility
+ assert_equal :private, @c6.find_method_named('s_priv1').visibility
+ assert_equal :protected, @c6.find_method_named('s_prot1').visibility
end
def util_visibilities
diff --git a/test/rdoc/test_rdoc_context_section.rb b/test/rdoc/test_rdoc_context_section.rb
index 24c68c49dd..6834cccafb 100644
--- a/test/rdoc/test_rdoc_context_section.rb
+++ b/test/rdoc/test_rdoc_context_section.rb
@@ -144,4 +144,3 @@ class TestRDocContextSection < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_cross_reference.rb b/test/rdoc/test_rdoc_cross_reference.rb
index f73681ebc8..cbda77a798 100644
--- a/test/rdoc/test_rdoc_cross_reference.rb
+++ b/test/rdoc/test_rdoc_cross_reference.rb
@@ -1,7 +1,10 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocCrossReference < XrefTestCase
+ EXAMPLE_METHODS = %w'== === != =~ !~ < > <= >= <=> [] []= << >>
+ -@ +@ ! - + * / % ** !@ ` | & ^ ~ __id__
+ '
def setup
super
@@ -18,9 +21,9 @@ class TestRDocCrossReference < XrefTestCase
end
def test_METHOD_REGEXP_STR
- re = /#{RDoc::CrossReference::METHOD_REGEXP_STR}/
+ re = /\A(?:#{RDoc::CrossReference::METHOD_REGEXP_STR})\z/
- %w'== === [] []= << >>'.each do |x|
+ EXAMPLE_METHODS.each do |x|
re =~ x
assert_equal x, $&
end
@@ -163,34 +166,35 @@ class TestRDocCrossReference < XrefTestCase
assert_ref @c9_a_c_bar, 'C9::B.bar'
end
- def test_resolve_method_equals3
- m = RDoc::AnyMethod.new '', '==='
- @c1.add_method m
-
- assert_ref m, '==='
- end
-
def test_resolve_page
page = @store.add_file 'README.txt', parser: RDoc::Parser::Simple
assert_ref page, 'README'
end
- def test_resolve_percent
- i_percent = RDoc::AnyMethod.new nil, '%'
- i_percent.singleton = false
- @c1.add_method i_percent
+ def assert_resolve_method(x)
+ @c1.methods_hash.clear
+
+ i_op = RDoc::AnyMethod.new nil, x
+ i_op.singleton = false
+ @c1.add_method i_op
- c_percent = RDoc::AnyMethod.new nil, '%'
- c_percent.singleton = true
- @c1.add_method c_percent
+ c_op = RDoc::AnyMethod.new nil, x
+ c_op.singleton = true
+ @c1.add_method c_op
- assert_ref i_percent, '%'
- assert_ref i_percent, '#%'
- assert_ref c_percent, '::%'
+ assert_ref i_op, x
+ assert_ref i_op, "##{x}"
+ assert_ref c_op, "::#{x}"
- assert_ref i_percent, 'C1#%'
- assert_ref c_percent, 'C1::%'
+ assert_ref i_op, "C1##{x}"
+ assert_ref c_op, "C1::#{x}"
+ end
+
+ EXAMPLE_METHODS.each do |x|
+ define_method("test_resolve_method:#{x}") do
+ assert_resolve_method(x)
+ end
end
def test_resolve_no_ref
@@ -213,4 +217,3 @@ class TestRDocCrossReference < XrefTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_extend.rb b/test/rdoc/test_rdoc_extend.rb
index e78f287b83..cc5038cc51 100644
--- a/test/rdoc/test_rdoc_extend.rb
+++ b/test/rdoc/test_rdoc_extend.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocExtend < XrefTestCase
@@ -92,4 +92,3 @@ class TestRDocExtend < XrefTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_generator_darkfish.rb b/test/rdoc/test_rdoc_generator_darkfish.rb
index b78a3fb45f..96319bb4f7 100644
--- a/test/rdoc/test_rdoc_generator_darkfish.rb
+++ b/test/rdoc/test_rdoc_generator_darkfish.rb
@@ -72,11 +72,30 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
def test_generate
top_level = @store.add_file 'file.rb'
top_level.add_class @klass.class, @klass.name
+ @klass.add_class RDoc::NormalClass, 'Inner'
+ @klass.add_comment <<~RDOC, top_level
+ = Heading 1
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
+ == Heading 1.1
+ tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
+ === Heading 1.1.1
+ quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
+ ==== Heading 1.1.1.1
+ consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
+ == Heading 1.2
+ cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
+ == Heading 1.3
+ non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+ === Heading 1.3.1
+ etc etc...
+ RDOC
@g.generate
assert_file 'index.html'
assert_file 'Object.html'
+ assert_file 'Klass.html'
+ assert_file 'Klass/Inner.html'
assert_file 'table_of_contents.html'
assert_file 'js/search_index.js'
@@ -88,10 +107,48 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
encoding = Regexp.escape Encoding::UTF_8.name
- assert_match %r%<meta charset="#{encoding}">%, File.read('index.html')
- assert_match %r%<meta charset="#{encoding}">%, File.read('Object.html')
+ assert_match %r%<meta charset="#{encoding}">%, File.binread('index.html')
+ assert_match %r%<meta charset="#{encoding}">%, File.binread('Object.html')
+
+ refute_match(/Ignored/, File.binread('index.html'))
+ summary = File.binread('index.html')[%r[<summary.*Klass\.html.*</summary>.*</details>]m]
+ assert_match(%r[Klass/Inner\.html".*>Inner<], summary)
+
+ klass = File.binread('Klass.html')
+ klassnav = klass[%r[<div class="nav-section">.*<div id="class-metadata">]m]
+ assert_match(
+ %r[<li>\s*<details open>\s*<summary>\s*<a href=\S+>Heading 1</a>\s*</summary>\s*<ul]m,
+ klassnav
+ )
+ assert_match(
+ %r[<li>\s*<a href=\S+>Heading 1.1.1.1</a>\s*</ul>\s*</details>\s*</li>]m,
+ klassnav
+ )
+
+ assert_match(/<h1 id="class-Klass-label-Heading\+1">Heading 1(?!\.)/,
+ klass[%r[<section class=\"description\">.*</section>]m])
+ toc = File.binread('table_of_contents.html')
+ assert_match(
+ %r[<a\s+href="Klass\.html#class-Klass-label-Heading\+1">Heading 1</a>]m,
+ toc[%r[<h2\s+id=\"classes\">.*(?=<h2\b)]m][%r[<a\s+href="Klass\.html".*(?=</li\b)]m]
+ )
+ end
- refute_match(/Ignored/, File.read('index.html'))
+ def test_generate_page
+ @store.add_file 'outer.rdoc', parser: RDoc::Parser::Simple
+ @store.add_file 'outer/inner.rdoc', parser: RDoc::Parser::Simple
+ @g.generate
+ assert_file 'outer_rdoc.html'
+ assert_file 'outer/inner_rdoc.html'
+ index = File.binread('index.html')
+ re = %r[<summary><a href="\./outer_rdoc\.html">outer</a></summary>.*?</details>]m
+ assert_match(re, index)
+ summary = index[re]
+ assert_match %r[<a href="\./outer/inner_rdoc.html">inner</a>], summary
+ re = %r[<details open><summary><a href="\./outer_rdoc\.html">outer</a></summary>.*?</details>]m
+ assert_match(re, File.binread('outer_rdoc.html'))
+ re = %r[<details open><summary><a href="\.\./outer_rdoc\.html">outer</a></summary>.*?</details>]m
+ assert_match(re, File.binread('outer/inner_rdoc.html'))
end
def test_generate_dry_run
@@ -211,6 +268,29 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
assert_includes method_name, '{ |%&lt;&lt;script&gt;alert(&quot;atui&quot;)&lt;/script&gt;&gt;, yield_arg| ... }'
end
+ def test_generated_filename_with_html_tag
+ filename = '"><em>should be escaped'
+ begin # in @tmpdir
+ File.write(filename, '')
+ rescue SystemCallError
+ # ", <, > chars are prohibited as filename
+ return
+ else
+ File.unlink(filename)
+ end
+ @store.add_file filename
+ doc = @store.all_files.last
+ doc.parser = RDoc::Parser::Simple
+
+ @g.generate
+
+ Dir.glob("*.html", base: @tmpdir) do |html|
+ File.binread(File.join(@tmpdir, html)).scan(/.*should be escaped.*/) do |line|
+ assert_not_include line, "<em>", html
+ end
+ end
+ end
+
def test_template_stylesheets
css = Tempfile.create(%W'hoge .css', Dir.mktmpdir('tmp', '.'))
File.write(css, '')
@@ -223,7 +303,23 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
@g.generate
assert_file base
- assert_include File.read('index.html'), %Q[href="./#{base}"]
+ assert_include File.binread('index.html'), %Q[href="./#{base}"]
+ end
+
+ def test_title
+ title = "RDoc Test".freeze
+ @options.title = title
+ @g.generate
+
+ assert_main_title(File.binread('index.html'), title)
+ end
+
+ def test_title_escape
+ title = %[<script>alert("RDoc")</script>].freeze
+ @options.title = title
+ @g.generate
+
+ assert_main_title(File.binread('index.html'), title)
end
##
@@ -249,4 +345,9 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
"#{filename} is not hard-linked"
end
+ def assert_main_title(content, title)
+ title = CGI.escapeHTML(title)
+ assert_equal(title, content[%r[<title>(.*?)<\/title>]im, 1])
+ assert_include(content[%r[<main\s[^<>]*+>\s*(.*?)</main>]im, 1], title)
+ end
end
diff --git a/test/rdoc/test_rdoc_generator_json_index.rb b/test/rdoc/test_rdoc_generator_json_index.rb
index 6b69337b45..62d1ccec95 100644
--- a/test/rdoc/test_rdoc_generator_json_index.rb
+++ b/test/rdoc/test_rdoc_generator_json_index.rb
@@ -104,8 +104,20 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
orig_file = Pathname(File.join srcdir, 'generator/template/json_index/js/navigation.js')
generated_file = Pathname(File.join @tmpdir, 'js/navigation.js')
+ # The following assertion for the generated file's modified time randomly
+ # fails in a ppc64le environment.
+ # https://github.com/ruby/rdoc/issues/1048
+ if orig_file.mtime.inspect != generated_file.mtime.inspect &&
+ RUBY_PLATFORM =~ /powerpc64le/
+ pend <<~EOC
+ Unstable test in ppc64le.
+ <#{orig_file.mtime.inspect}> expected but was
+ <#{generated_file.mtime.inspect}>.
+ EOC
+ end
+
# This is dirty hack on JRuby
- assert orig_file.mtime.inspect == generated_file.mtime.inspect,
+ assert_equal orig_file.mtime.inspect, generated_file.mtime.inspect,
'.js files should be the same timestamp of original'
json = File.read 'js/search_index.js'
diff --git a/test/rdoc/test_rdoc_generator_markup.rb b/test/rdoc/test_rdoc_generator_markup.rb
index 5491b7c61e..7c021e432e 100644
--- a/test/rdoc/test_rdoc_generator_markup.rb
+++ b/test/rdoc/test_rdoc_generator_markup.rb
@@ -57,4 +57,3 @@ class TestRDocGeneratorMarkup < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_include.rb b/test/rdoc/test_rdoc_include.rb
index b8e8f26039..380464f6cc 100644
--- a/test/rdoc/test_rdoc_include.rb
+++ b/test/rdoc/test_rdoc_include.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocInclude < XrefTestCase
@@ -107,4 +107,3 @@ class TestRDocInclude < XrefTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markdown.rb b/test/rdoc/test_rdoc_markdown.rb
index ad53e9473c..31d5b068f9 100644
--- a/test/rdoc/test_rdoc_markdown.rb
+++ b/test/rdoc/test_rdoc_markdown.rb
@@ -2,8 +2,8 @@
# frozen_string_literal: true
require_relative 'helper'
-require 'rdoc/markup/block_quote'
-require 'rdoc/markdown'
+require_relative '../../lib/rdoc/markup/block_quote'
+require_relative '../../lib/rdoc/markdown'
class TestRDocMarkdown < RDoc::TestCase
@@ -305,6 +305,25 @@ that also extends to two lines
assert_equal expected, doc
end
+ def test_parse_definition_list_rich_label
+ doc = parse <<-MD
+`one`
+: This is a definition
+
+**two**
+: This is another definition
+ MD
+
+ expected = doc(
+ list(:NOTE,
+ item(%w[<code>one</code>],
+ para("This is a definition")),
+ item(%w[*two*],
+ para("This is another definition"))))
+
+ assert_equal expected, doc
+ end
+
def test_parse_definition_list_no
@parser.definition_lists = false
@@ -761,7 +780,6 @@ with inline notes^[like this]
and an extra note.[^2]
[^1]: With a footnote
-
[^2]: Which should be numbered correctly
MD
@@ -1063,9 +1081,29 @@ and an extra note.[^2]
assert_equal expected, doc
end
+ def test_gfm_table_2
+ doc = parse <<~'MD'
+ | Cmd | Returns | Meaning
+ ----- | :-----: | -------
+ |"b" | boolean | True if file1 is a block device
+ "c" | boolean | True if file1 is a character device
+ |"\|" | boolean | escaped bar \| test
+ MD
+
+ head = %w[Cmd Returns Meaning]
+ align = [nil, :center, nil]
+ body = [
+ ['"b"', 'boolean', 'True if file1 is a block device'],
+ ['"c"', 'boolean', 'True if file1 is a character device'],
+ ['"|"', 'boolean', 'escaped bar | test'],
+ ]
+ expected = doc(@RM::Table.new(head, align, body))
+
+ assert_equal expected, doc
+ end
+
def parse text
@parser.parse text
end
end
-
diff --git a/test/rdoc/test_rdoc_markdown_test.rb b/test/rdoc/test_rdoc_markdown_test.rb
index 0ecd000136..d4f894c924 100644
--- a/test/rdoc/test_rdoc_markdown_test.rb
+++ b/test/rdoc/test_rdoc_markdown_test.rb
@@ -2,8 +2,8 @@
require_relative 'helper'
require 'pp'
-require 'rdoc'
-require 'rdoc/markdown'
+require_relative '../../lib/rdoc'
+require_relative '../../lib/rdoc/markdown'
class TestRDocMarkdownTest < RDoc::TestCase
diff --git a/test/rdoc/test_rdoc_markup.rb b/test/rdoc/test_rdoc_markup.rb
index b9bdafab2a..4d79f8bc3f 100644
--- a/test/rdoc/test_rdoc_markup.rb
+++ b/test/rdoc/test_rdoc_markup.rb
@@ -93,4 +93,3 @@ the time
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_attribute_manager.rb b/test/rdoc/test_rdoc_markup_attribute_manager.rb
index 944364ba89..dcae48525d 100644
--- a/test/rdoc/test_rdoc_markup_attribute_manager.rb
+++ b/test/rdoc/test_rdoc_markup_attribute_manager.rb
@@ -145,6 +145,8 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
assert_equal(["cat and ", @em_on, "5", @em_off, " dogs"],
@am.flow("cat and _5_ dogs"))
+
+ assert_equal([@tt_on, "__id__", @tt_off], @am.flow("+__id__+"))
end
def test_bold
@@ -391,4 +393,3 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_attributes.rb b/test/rdoc/test_rdoc_markup_attributes.rb
index 0dfd72bdb6..1ab408d801 100644
--- a/test/rdoc/test_rdoc_markup_attributes.rb
+++ b/test/rdoc/test_rdoc_markup_attributes.rb
@@ -37,4 +37,3 @@ class TestRDocMarkupAttributes < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_document.rb b/test/rdoc/test_rdoc_markup_document.rb
index 3db834b85d..e4f3b9daf1 100644
--- a/test/rdoc/test_rdoc_markup_document.rb
+++ b/test/rdoc/test_rdoc_markup_document.rb
@@ -205,4 +205,3 @@ class TestRDocMarkupDocument < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_formatter.rb b/test/rdoc/test_rdoc_markup_formatter.rb
index 8702db379d..af19d832ca 100644
--- a/test/rdoc/test_rdoc_markup_formatter.rb
+++ b/test/rdoc/test_rdoc_markup_formatter.rb
@@ -104,6 +104,12 @@ class TestRDocMarkupFormatter < RDoc::TestCase
formatted = document.accept @to
assert_equal '<{foo}[rdoc-label:bar]>.', formatted
+
+ document = doc(para('<tt>{abc}</tt>: {foo}[rdoc-label:bar].'))
+
+ formatted = document.accept @to
+
+ assert_equal '<code>{abc}</code>: <{foo}[rdoc-label:bar]>.', formatted
end
def test_parse_url
diff --git a/test/rdoc/test_rdoc_markup_hard_break.rb b/test/rdoc/test_rdoc_markup_hard_break.rb
index adebfdc311..ac67c68d10 100644
--- a/test/rdoc/test_rdoc_markup_hard_break.rb
+++ b/test/rdoc/test_rdoc_markup_hard_break.rb
@@ -29,4 +29,3 @@ class TestRDocMarkupHardBreak < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_heading.rb b/test/rdoc/test_rdoc_markup_heading.rb
index 05a8e005ba..de92af91a0 100644
--- a/test/rdoc/test_rdoc_markup_heading.rb
+++ b/test/rdoc/test_rdoc_markup_heading.rb
@@ -27,4 +27,3 @@ class TestRDocMarkupHeading < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_include.rb b/test/rdoc/test_rdoc_markup_include.rb
index 9126526b73..b3e9b845c3 100644
--- a/test/rdoc/test_rdoc_markup_include.rb
+++ b/test/rdoc/test_rdoc_markup_include.rb
@@ -17,4 +17,3 @@ class TestRDocMarkupInclude < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_indented_paragraph.rb b/test/rdoc/test_rdoc_markup_indented_paragraph.rb
index 7b5758998f..d2a9cbe5ca 100644
--- a/test/rdoc/test_rdoc_markup_indented_paragraph.rb
+++ b/test/rdoc/test_rdoc_markup_indented_paragraph.rb
@@ -51,4 +51,3 @@ class TestRDocMarkupIndentedParagraph < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_paragraph.rb b/test/rdoc/test_rdoc_markup_paragraph.rb
index ca89a74fc3..1b26846eb3 100644
--- a/test/rdoc/test_rdoc_markup_paragraph.rb
+++ b/test/rdoc/test_rdoc_markup_paragraph.rb
@@ -30,4 +30,3 @@ class TestRDocMarkupParagraph < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_raw.rb b/test/rdoc/test_rdoc_markup_raw.rb
index c7795b24e1..52887e6f6c 100644
--- a/test/rdoc/test_rdoc_markup_raw.rb
+++ b/test/rdoc/test_rdoc_markup_raw.rb
@@ -20,4 +20,3 @@ class TestRDocMarkupRaw < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_to_ansi.rb b/test/rdoc/test_rdoc_markup_to_ansi.rb
index 1d1fc7db46..81372c64d2 100644
--- a/test/rdoc/test_rdoc_markup_to_ansi.rb
+++ b/test/rdoc/test_rdoc_markup_to_ansi.rb
@@ -367,4 +367,3 @@ bar:
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb
index b2b21de806..e3affa533c 100644
--- a/test/rdoc/test_rdoc_markup_to_html.rb
+++ b/test/rdoc/test_rdoc_markup_to_html.rb
@@ -391,11 +391,43 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
end
def test_accept_paragraph_newline
+ hellos = ["hello", "\u{393 3b5 3b9 3ac} \u{3c3 3bf 3c5}"]
+ worlds = ["world", "\u{3ba 3cc 3c3 3bc 3bf 3c2}"]
+ ohayo, sekai = %W"\u{304a 306f 3088 3046} \u{4e16 754c}"
+
+ hellos.product(worlds) do |hello, world|
+ @to.start_accepting
+ @to.accept_paragraph para("#{hello}\n", "#{world}\n")
+ assert_equal "\n<p>#{hello} #{world}</p>\n", @to.res.join
+ end
+
+ hellos.each do |hello|
+ @to.start_accepting
+ @to.accept_paragraph para("#{hello}\n", "#{sekai}\n")
+ assert_equal "\n<p>#{hello}#{sekai}</p>\n", @to.res.join
+ end
+
+ worlds.each do |world|
+ @to.start_accepting
+ @to.accept_paragraph para("#{ohayo}\n", "#{world}\n")
+ assert_equal "\n<p>#{ohayo}#{world}</p>\n", @to.res.join
+ end
+
@to.start_accepting
+ @to.accept_paragraph para("#{ohayo}\n", "#{sekai}\n")
+ assert_equal "\n<p>#{ohayo}#{sekai}</p>\n", @to.res.join
- @to.accept_paragraph para("hello\n", "world\n")
+ @to.start_accepting
+ @to.accept_paragraph para("+hello+\n", "world\n")
+ assert_equal "\n<p><code>hello</code> world</p>\n", @to.res.join
+
+ @to.start_accepting
+ @to.accept_paragraph para("hello\n", "+world+\n")
+ assert_equal "\n<p>hello <code>world</code></p>\n", @to.res.join
- assert_equal "\n<p>hello world </p>\n", @to.res.join
+ @to.start_accepting
+ @to.accept_paragraph para("+hello+\n", "+world+\n")
+ assert_equal "\n<p><code>hello</code> <code>world</code></p>\n", @to.res.join
end
def test_accept_heading_output_decoration
@@ -602,9 +634,9 @@ end
end
def test_accept_verbatim_redefinable_operators
- functions = %w[| ^ & <=> == === =~ > >= < <= << >> + - * / % ** ~ +@ -@ [] []= ` ! != !~].map { |redefinable_op|
+ functions = %w[| ^ & <=> == === =~ > >= < <= << >> + - * / % ** ~ +@ -@ [] []= ` ! != !~].flat_map { |redefinable_op|
["def #{redefinable_op}\n", "end\n"]
- }.flatten
+ }
verb = @RM::Verbatim.new(*functions)
@@ -665,6 +697,26 @@ EXPECTED
assert_equal "\n<p>C</p>\n", result
end
+ def test_convert_RDOCLINK_escape_image
+ assert_escaped '<script>', 'rdoc-image:"><script>alert(`rdoc-image`)</script>"'
+ end
+
+ def test_convert_RDOCLINK_escape_label_id
+ assert_escaped '<script>', 'rdoc-label::path::"><script>alert(`rdoc-label_id`)</script>"'
+ end
+
+ def test_convert_RDOCLINK_escape_label_path
+ assert_escaped '<script>', 'rdoc-label::"><script>alert(`rdoc-label_path`)</script>"'
+ end
+
+ def test_convert_RDOCLINK_escape_ref
+ assert_escaped '<script>', 'rdoc-ref:"><script>alert(`rdoc-ref`)</script>"'
+ end
+
+ def test_convert_RDOCLINK_escape_xxx
+ assert_escaped '<script>', 'rdoc-xxx:"><script>alert(`rdoc-xxx`)</script>"'
+ end
+
def test_convert_TIDYLINK_footnote
result = @to.convert 'text{*1}[rdoc-label:foottext-1:footmark-1]'
@@ -690,6 +742,11 @@ EXPECTED
"\n<p><a href=\"http://example.com\"><img src=\"path/to/image.jpg\"></a></p>\n"
assert_equal expected, result
+
+ result =
+ @to.convert '{rdoc-image:<script>alert`link text`</script>}[http://example.com]'
+
+ assert_not_include result, "<script>"
end
def test_convert_TIDYLINK_rdoc_label
@@ -704,9 +761,27 @@ EXPECTED
assert_equal "\n<p><a href=\"irc://irc.freenode.net/#ruby-lang\">ruby-lang</a></p>\n", result
end
+ def test_convert_TIDYLINK_escape_text
+ assert_escaped '<script>', '{<script>alert`link text`</script>}[a]'
+ assert_escaped '<script>', 'x:/<script>alert(1);</script>[[]'
+ end
+
+ def test_convert_TIDYLINK_escape_javascript
+ assert_not_include '{click}[javascript:alert`javascript_scheme`]', '<a href="javascript:'
+ end
+
+ def test_convert_TIDYLINK_escape_onmouseover
+ assert_escaped '"/onmouseover="', '{onmouseover}[http://"/onmouseover="alert`on_mouse_link`"]'
+ end
+
+ def test_convert_TIDYLINK_escape_onerror
+ assert_escaped '"onerror="', '{link_image}[http://"onerror="alert`link_image`".png]'
+ end
+
def test_convert_with_exclude_tag
assert_equal "\n<p><code>aaa</code>[:symbol]</p>\n", @to.convert('+aaa+[:symbol]')
assert_equal "\n<p><code>aaa[:symbol]</code></p>\n", @to.convert('+aaa[:symbol]+')
+ assert_equal "\n<p><code>https:</code>-foobar</p>\n", @to.convert('<tt>https:</tt>-foobar')
assert_equal "\n<p><a href=\":symbol\">aaa</a></p>\n", @to.convert('aaa[:symbol]')
end
@@ -793,6 +868,11 @@ EXPECTED
assert_equal '<a href="irc://irc.freenode.net/#ruby-lang">irc.freenode.net/#ruby-lang</a>', link
end
+ def test_handle_regexp_HYPERLINK_escape
+ code = 'irc://irc.freenode.net/"><script>alert(`irc`)</script><a"'
+ assert_escaped '<script>', code
+ end
+
def test_list_verbatim_2
str = "* one\n verb1\n verb2\n* two\n"
@@ -811,6 +891,26 @@ EXPECTED
assert_equal expected, @m.convert(str, @to)
end
+ def test_block_quote_in_verbatim
+ str = "BlockQuote\n >>>\n"
+
+ expected = <<-EXPECTED
+<p>BlockQuote</p>
+<pre>&gt;&gt;&gt;</pre>
+ EXPECTED
+
+ assert_equal expected, @m.convert(str, @to).gsub(/^\n/, "")
+
+ str = "BlockQuote\n >>> word\n"
+
+ expected = <<-EXPECTED
+<p>BlockQuote</p>
+<pre>&gt;&gt;&gt; word</pre>
+ EXPECTED
+
+ assert_equal expected, @m.convert(str, @to).gsub(/^\n/, "")
+ end
+
def test_parseable_eh
valid_syntax = [
'def x() end',
@@ -855,5 +955,37 @@ EXPECTED
@to.end_accepting
end
+ def test_accept_table
+ header = %w[Col1 Col2 Col3]
+ body = [
+ %w[cell1_1 cell1_2 cell1_3],
+ %w[cell2_1 cell2_2 cell2_3],
+ ['<script>alert("foo");</script>',],
+ %w[+code+ _em_ **strong**],
+ ]
+ aligns = [:left, :right, nil]
+ @to.start_accepting
+ @to.accept_table(header, body, aligns)
+ res = @to.end_accepting
+ assert_include(res[%r<<th[^<>]*>Col1</th>>], 'align="left"')
+ assert_include(res[%r<<th[^<>]*>Col2</th>>], 'align="right"')
+ assert_not_include(res[%r<<th[^<>]*>Col3</th>>], 'align=')
+ assert_include(res[%r<<td[^<>]*>cell1_1</td>>], 'align="left"')
+ assert_include(res[%r<<td[^<>]*>cell1_2</td>>], 'align="right"')
+ assert_not_include(res[%r<<td[^<>]*>cell1_3</td>>], 'align=')
+ assert_include(res[%r<<td[^<>]*>cell2_1</td>>], 'align="left"')
+ assert_include(res[%r<<td[^<>]*>cell2_2</td>>], 'align="right"')
+ assert_not_include(res[%r<<td[^<>]*>cell2_3</td>>], 'align=')
+ assert_not_include(res, '<script>')
+ assert_include(res[%r<<td[^<>]*>.*script.*</td>>], '&lt;script&gt;')
+ assert_include(res[%r<<td[^<>]*>.*code.*</td>>], '<code>code</code>')
+ assert_include(res[%r<<td[^<>]*>.*em.*</td>>], '<em>em</em>')
+ assert_include(res[%r<<td[^<>]*>.*strong.*</td>>], '<strong>strong</strong>')
+ end
+
+ def assert_escaped(unexpected, code)
+ result = @to.convert(code)
+ assert_not_include result, unexpected
+ assert_include result, CGI.escapeHTML(unexpected)
+ end
end
-
diff --git a/test/rdoc/test_rdoc_markup_to_html_crossref.rb b/test/rdoc/test_rdoc_markup_to_html_crossref.rb
index f6fabfb7db..dc4488195a 100644
--- a/test/rdoc/test_rdoc_markup_to_html_crossref.rb
+++ b/test/rdoc/test_rdoc_markup_to_html_crossref.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocMarkupToHtmlCrossref < XrefTestCase
@@ -17,6 +17,12 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
assert_equal para("<a href=\"C1.html\"><code>C1</code></a>"), result
end
+ def test_convert_CROSSREF_method
+ result = @to.convert 'C1#m(foo, bar, baz)'
+
+ assert_equal para("<a href=\"C1.html#method-i-m\"><code>C1#m(foo, bar, baz)</code></a>"), result
+ end
+
def test_convert_CROSSREF_label
result = @to.convert 'C1@foo'
assert_equal para("<a href=\"C1.html#class-C1-label-foo\">foo at <code>C1</code></a>"), result
@@ -127,6 +133,18 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
'rdoc-ref:C1@foo'
end
+ def test_convert_RDOCLINK_rdoc_ref_label_in_current_file
+ result = @to.convert 'rdoc-ref:@foo'
+
+ assert_equal para("<a href=\"#label-foo\">foo</a>"), result,
+ 'rdoc-ref:@foo'
+
+ result = @to.convert '{Foo}[rdoc-ref:@foo]'
+
+ assert_equal para("<a href=\"#label-foo\">Foo</a>"), result,
+ '{Foo}[rdoc-ref:@foo]'
+ end
+
def test_gen_url
assert_equal '<a href="C1.html">Some class</a>',
@to.gen_url('rdoc-ref:C1', 'Some class')
@@ -260,4 +278,3 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb b/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb
index cbaf75a04e..8bd2d67247 100644
--- a/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb
+++ b/test/rdoc/test_rdoc_markup_to_joined_paragraph.rb
@@ -30,4 +30,3 @@ class TestRDocMarkupToJoinedParagraph < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_to_label.rb b/test/rdoc/test_rdoc_markup_to_label.rb
index 70ea7f0f1b..2bf2e0ecdf 100644
--- a/test/rdoc/test_rdoc_markup_to_label.rb
+++ b/test/rdoc/test_rdoc_markup_to_label.rb
@@ -110,4 +110,3 @@ class TestRDocMarkupToLabel < RDoc::Markup::FormatterTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_to_markdown.rb b/test/rdoc/test_rdoc_markup_to_markdown.rb
index c8c5fd4d52..92ed37bc50 100644
--- a/test/rdoc/test_rdoc_markup_to_markdown.rb
+++ b/test/rdoc/test_rdoc_markup_to_markdown.rb
@@ -69,7 +69,7 @@ class TestRDocMarkupToMarkdown < RDoc::Markup::TextFormatterTestCase
end
def accept_list_item_end_label
- assert_equal "cat\n: ", @to.res.join
+ assert_equal "cat\n: \n", @to.res.join
assert_equal 0, @to.indent, 'indent'
end
@@ -79,7 +79,7 @@ class TestRDocMarkupToMarkdown < RDoc::Markup::TextFormatterTestCase
end
def accept_list_item_end_note
- assert_equal "cat\n: ", @to.res.join
+ assert_equal "cat\n: \n", @to.res.join
assert_equal 0, @to.indent, 'indent'
end
@@ -319,9 +319,7 @@ words words words words
expected = <<-EXPECTED
* l1
* l1.1
-
* l2
-
EXPECTED
assert_equal expected, @to.end_accepting
@@ -343,7 +341,6 @@ words words words words
* second
-
EXPECTED
assert_equal expected, @to.end_accepting
@@ -387,4 +384,3 @@ words words words words
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_to_rdoc.rb b/test/rdoc/test_rdoc_markup_to_rdoc.rb
index 1d833b156a..50f4b6dc8b 100644
--- a/test/rdoc/test_rdoc_markup_to_rdoc.rb
+++ b/test/rdoc/test_rdoc_markup_to_rdoc.rb
@@ -69,7 +69,7 @@ class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase
end
def accept_list_item_end_label
- assert_equal "cat:\n", @to.res.join
+ assert_equal "[cat]\n", @to.res.join
assert_equal 0, @to.indent, 'indent'
end
@@ -79,7 +79,7 @@ class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase
end
def accept_list_item_end_note
- assert_equal "cat:\n", @to.res.join
+ assert_equal "cat::\n", @to.res.join
assert_equal 0, @to.indent, 'indent'
end
@@ -100,7 +100,7 @@ class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase
def accept_list_item_start_label
assert_equal [""], @to.res
- assert_equal "cat:\n ", @to.prefix
+ assert_equal "[cat]\n ", @to.prefix
assert_equal 2, @to.indent
end
@@ -115,7 +115,7 @@ class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase
def accept_list_item_start_note
assert_equal [""], @to.res
- assert_equal "cat:\n ", @to.prefix
+ assert_equal "cat::\n ", @to.prefix
assert_equal 2, @to.indent
end
@@ -243,16 +243,16 @@ class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase
end
def accept_list_item_start_note_2
- assert_equal "<tt>teletype</tt>:\n teletype description\n\n", @to.res.join
+ assert_equal "<tt>teletype</tt>::\n teletype description\n\n", @to.res.join
end
def accept_list_item_start_note_multi_description
- assert_equal "label:\n description one\n\n description two\n\n",
+ assert_equal "label::\n description one\n\n description two\n\n",
@to.res.join
end
def accept_list_item_start_note_multi_label
- assert_equal "one\ntwo:\n two headers\n\n", @to.res.join
+ assert_equal "one::\ntwo::\n two headers\n\n", @to.res.join
end
def accept_paragraph_b
@@ -355,8 +355,8 @@ bar ::
NOTE_LIST
expected = <<-EXPECTED
-foo
-bar:
+foo::
+bar::
hi
EXPECTED
@@ -375,4 +375,3 @@ bar:
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_to_table_of_contents.rb b/test/rdoc/test_rdoc_markup_to_table_of_contents.rb
index 11ab6f197b..7512495aec 100644
--- a/test/rdoc/test_rdoc_markup_to_table_of_contents.rb
+++ b/test/rdoc/test_rdoc_markup_to_table_of_contents.rb
@@ -124,4 +124,3 @@ class TestRDocMarkupToTableOfContents < RDoc::Markup::FormatterTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_to_tt_only.rb b/test/rdoc/test_rdoc_markup_to_tt_only.rb
index 8508f823df..c709d7a4d5 100644
--- a/test/rdoc/test_rdoc_markup_to_tt_only.rb
+++ b/test/rdoc/test_rdoc_markup_to_tt_only.rb
@@ -244,4 +244,3 @@ class TestRDocMarkupToTtOnly < RDoc::Markup::FormatterTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_markup_verbatim.rb b/test/rdoc/test_rdoc_markup_verbatim.rb
index 1a650c44ef..2f8a57266a 100644
--- a/test/rdoc/test_rdoc_markup_verbatim.rb
+++ b/test/rdoc/test_rdoc_markup_verbatim.rb
@@ -27,4 +27,3 @@ class TestRDocMarkupVerbatim < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_method_attr.rb b/test/rdoc/test_rdoc_method_attr.rb
index 68a9d6cc21..d607619a60 100644
--- a/test/rdoc/test_rdoc_method_attr.rb
+++ b/test/rdoc/test_rdoc_method_attr.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocMethodAttr < XrefTestCase
@@ -191,4 +191,3 @@ class TestRDocMethodAttr < XrefTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_normal_class.rb b/test/rdoc/test_rdoc_normal_class.rb
index 7cb5e4bfc7..3d097ebb52 100644
--- a/test/rdoc/test_rdoc_normal_class.rb
+++ b/test/rdoc/test_rdoc_normal_class.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocNormalClass < XrefTestCase
@@ -45,4 +45,3 @@ class TestRDocNormalClass < XrefTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_normal_module.rb b/test/rdoc/test_rdoc_normal_module.rb
index 68e776c41f..cccee5c44c 100644
--- a/test/rdoc/test_rdoc_normal_module.rb
+++ b/test/rdoc/test_rdoc_normal_module.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocNormalModule < XrefTestCase
@@ -40,4 +40,3 @@ class TestRDocNormalModule < XrefTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb
index 7c264c5e86..5e8b1ae3d8 100644
--- a/test/rdoc/test_rdoc_options.rb
+++ b/test/rdoc/test_rdoc_options.rb
@@ -55,11 +55,10 @@ class TestRDocOptions < RDoc::TestCase
refute @options.dry_run
end
- def test_encode_with
- coder = {}
- class << coder; alias add []=; end
+ def test_to_yaml
+ RDoc.load_yaml
- @options.encode_with coder
+ coder = YAML.load(@options.to_yaml)
encoding = 'UTF-8'
@@ -69,7 +68,6 @@ class TestRDocOptions < RDoc::TestCase
'exclude' => %w[~\z \.orig\z \.rej\z \.bak\z \.gemspec\z],
'hyperlink_all' => false,
'line_numbers' => false,
- 'locale' => nil,
'locale_dir' => 'locale',
'locale_name' => nil,
'main_page' => nil,
@@ -84,15 +82,17 @@ class TestRDocOptions < RDoc::TestCase
'title' => nil,
'visibility' => :protected,
'webcvs' => nil,
+ 'skip_tests' => true,
}
assert_equal expected, coder
end
- def test_encode_with_trim_paths
+ def test_to_yaml_trim_paths
+ RDoc.load_yaml
+
subdir = nil
- coder = {}
- class << coder; alias add []=; end
+ coder = nil
temp_dir do |dir|
FileUtils.mkdir 'project'
@@ -113,7 +113,7 @@ class TestRDocOptions < RDoc::TestCase
--include /
]
- @options.encode_with coder
+ coder = YAML.load(@options.to_yaml)
end
end
@@ -145,7 +145,9 @@ class TestRDocOptions < RDoc::TestCase
@options.encoding = Encoding::IBM437
- options = YAML.safe_load(YAML.dump(@options), permitted_classes: [RDoc::Options, Symbol])
+ options = @options.to_yaml
+ options = YAML.safe_load(options, permitted_classes: [Symbol])
+ options = RDoc::Options.new(options)
assert_equal Encoding::IBM437, options.encoding
end
@@ -154,14 +156,15 @@ class TestRDocOptions < RDoc::TestCase
RDoc.load_yaml
yaml = <<-YAML
---- !ruby/object:RDoc::Options
+---
static_path:
- /etc
rdoc_include:
- /etc
YAML
- options = YAML.safe_load(yaml, permitted_classes: [RDoc::Options, Symbol])
+ options = YAML.safe_load(yaml, permitted_classes: [Symbol])
+ options = RDoc::Options.new(options)
assert_empty options.rdoc_include
assert_empty options.static_path
@@ -205,6 +208,13 @@ rdoc_include:
assert @options.force_update
end
+ def test_parse_coverage_C
+ @options.parse %w[-C]
+
+ assert @options.coverage_report
+ assert @options.force_update
+ end
+
def test_parse_coverage_no
@options.parse %w[--no-dcov]
@@ -217,6 +227,19 @@ rdoc_include:
assert_equal 1, @options.coverage_report
end
+ def test_parse_coverage_C_level_1
+ @options.parse %w[-C1]
+
+ assert_equal 1, @options.coverage_report
+ end
+
+ def test_parse_coverage_C_level_0
+ @options.parse %w[-C0]
+
+ assert_equal 0, @options.coverage_report
+ assert @options.force_update
+ end
+
def test_parse_dash_p
out, err = capture_output do
@options.parse %w[-p]
@@ -243,6 +266,7 @@ rdoc_include:
def test_parse_default
@options.parse []
+ @options.finish
assert_equal RDoc::Generator::Darkfish, @options.generator
assert_equal 'darkfish', @options.template
@@ -502,6 +526,7 @@ rdoc_include:
out, err = capture_output do
@options.parse %W[--page-dir #{Dir.tmpdir}]
+ @options.finish
end
assert_empty out
@@ -530,6 +555,7 @@ rdoc_include:
out, err = capture_output do
@options.parse %W[--page-dir #{abs_page_dir} --root #{abs_root}]
+ @options.finish
end
assert_empty out
@@ -558,6 +584,8 @@ rdoc_include:
assert_empty err
assert_equal Pathname(Dir.tmpdir), @options.root
+
+ @options.finish
assert_includes @options.rdoc_include, @options.root.to_s
end
@@ -602,6 +630,7 @@ rdoc_include:
assert_empty out
assert_equal "could not find template NONEXISTENT\n", err
+ @options.finish
assert_equal 'darkfish', @options.template
assert_match %r%rdoc/generator/template/darkfish$%, @options.template_dir
end
@@ -668,6 +697,7 @@ rdoc_include:
Dir.chdir tmpdir do
e = assert_raise SystemExit do
@options.parse %w[--write-options]
+ @options.finish
end
assert_equal 0, e.status
@@ -689,6 +719,28 @@ rdoc_include:
assert_empty err
end
+ def test_parse_locale_name_default
+ temp_dir do
+ @options.parse %w[]
+ assert_equal 'locale', @options.instance_variable_get(:@locale_dir)
+ assert_nil @options.instance_variable_get(:@locale_name)
+ assert_nil @options.locale
+ @options.finish
+ assert_nil @options.locale
+ end
+ end
+
+ def test_parse_locale_name
+ temp_dir do
+ @options.parse %w[--locale fr]
+ assert_equal 'locale', @options.instance_variable_get(:@locale_dir)
+ assert_equal 'fr', @options.instance_variable_get(:@locale_name)
+ assert_nil @options.locale
+ @options.finish
+ assert_equal 'fr', @options.locale.name
+ end
+ end
+
def test_setup_generator
test_generator = Class.new do
def self.setup_options op
@@ -764,7 +816,9 @@ rdoc_include:
assert File.exist? '.rdoc_options'
- assert_equal @options, YAML.safe_load(File.read('.rdoc_options'), permitted_classes: [RDoc::Options, Symbol])
+ options = File.read('.rdoc_options')
+ options = YAML.safe_load(options, permitted_classes: [Symbol])
+ assert_equal @options, RDoc::Options.new(options)
end
end
@@ -834,20 +888,44 @@ rdoc_include:
def test_load_options_partial_override
temp_dir do
File.open '.rdoc_options', 'w' do |io|
- io.write "markup: Markdown"
+ io.puts "markup: Markdown"
+ io.puts "encoding: iso-8859-1"
+ io.puts "static_path: [static]"
+ io.puts "rdoc_include: [.]"
+ io.puts "page_dir: pages"
end
options = RDoc::Options.load_options
assert_equal 'Markdown', options.markup
+ assert_equal Encoding::ISO_8859_1, options.encoding
+ assert_equal ["static"], options.static_path
+ assert_equal ["."], options.rdoc_include
+ assert_equal "pages", options.page_dir
end
end
- def load_options_no_file
+ def test_load_options_no_file
temp_dir do
options = RDoc::Options.load_options
assert_kind_of RDoc::Options, options
end
end
+
+ def test_skip_test_default_value
+ @options.parse %w[]
+ assert_equal true, @options.skip_tests
+ end
+
+ def test_no_skip_test_value
+ @options.parse %w[--no-skipping-tests]
+ assert_equal false, @options.skip_tests
+ end
+
+ class DummyCoder < Hash
+ alias add :[]=
+ def tag=(tag)
+ end
+ end
end
diff --git a/test/rdoc/test_rdoc_parser.rb b/test/rdoc/test_rdoc_parser.rb
index 7cc3c2d926..fa6443f3d3 100644
--- a/test/rdoc/test_rdoc_parser.rb
+++ b/test/rdoc/test_rdoc_parser.rb
@@ -151,6 +151,20 @@ class TestRDocParser < RDoc::TestCase
File.unlink readme_ext
end
+ def test_can_parse_modeline_c
+ readme_inc = File.join Dir.tmpdir, "README.inc.#{$$}"
+
+ File.open readme_inc, 'w' do |io|
+ io.puts "/* README.inc - -*- c -*- created at: Mon Aug 7 16:45:54 JST 1995 */"
+ io.puts
+ io.puts "/* This document explains how to make extension libraries for Ruby. */"
+ end
+
+ assert_equal RDoc::Parser::C, @RP.can_parse(readme_inc)
+ ensure
+ File.unlink readme_inc
+ end
+
##
# Selenium hides a .jar file using a .txt extension.
diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb
index 8f51f32f26..ab4f149869 100644
--- a/test/rdoc/test_rdoc_parser_c.rb
+++ b/test/rdoc/test_rdoc_parser_c.rb
@@ -101,6 +101,31 @@ class TestRDocParserC < RDoc::TestCase
end
end
+ def test_known_classes
+ RDoc::KNOWN_CLASSES.each do |var, name|
+ case name
+ when "Refinement"
+ next unless defined?(Refinement)
+ when "RubyVM"
+ next unless defined?(RubyVM)
+ when "Bignum", "Fixnum", "Data", "Socket", /\A(?![A-Z])/
+ next
+ end
+ obj = Object.const_get(name)
+ assert_equal obj.name, name
+ case var
+ when /\Arb_c/
+ assert_kind_of Class, obj
+ when /\Arb_m/
+ assert_kind_of Module, obj
+ when /\Arb_e/
+ assert_operator obj, :<=, Exception
+ else
+ raise "unknown prefix: #{var} => #{name}"
+ end
+ end
+ end
+
def test_initialize
some_ext = @top_level.add_class RDoc::NormalClass, 'SomeExt'
@top_level.add_class RDoc::SingleClass, 'SomeExtSingle'
@@ -132,7 +157,7 @@ class TestRDocParserC < RDoc::TestCase
assert_equal expected, known_classes
end
- def test_do_attr_rb_attr
+ def assert_do_attr(flags)
content = <<-EOF
void Init_Blah(void) {
cBlah = rb_define_class("Blah", rb_cObject);
@@ -140,17 +165,17 @@ void Init_Blah(void) {
/*
* This is an accessor
*/
- rb_attr(cBlah, rb_intern("accessor"), 1, 1, Qfalse);
+ #{yield "cBlah", "accessor", flags[1], flags[1]};
/*
* This is a reader
*/
- rb_attr(cBlah, rb_intern("reader"), 1, 0, Qfalse);
+ #{yield "cBlah", "reader", flags[1], flags[0]};
/*
* This is a writer
*/
- rb_attr(cBlah, rb_intern("writer"), 0, 1, Qfalse);
+ #{yield "cBlah", "writer", flags[0], flags[1]};
}
EOF
@@ -176,72 +201,21 @@ void Init_Blah(void) {
assert_equal 'This is a writer', writer.comment.text
end
- def test_do_attr_rb_attr_2
- content = <<-EOF
-void Init_Blah(void) {
- cBlah = rb_define_class("Blah", rb_cObject);
-
- /*
- * This is an accessor
- */
- rb_attr(cBlah, rb_intern_const("accessor"), 1, 1, Qfalse);
-
- /*
- * This is a reader
- */
- rb_attr(cBlah, rb_intern_const("reader"), 1, 0, Qfalse);
-
- /*
- * This is a writer
- */
- rb_attr(cBlah, rb_intern_const("writer"), 0, 1, Qfalse);
-}
- EOF
-
- klass = util_get_class content, 'cBlah'
-
- attrs = klass.attributes
- assert_equal 3, attrs.length, attrs.inspect
-
- accessor = attrs.shift
- assert_equal 'accessor', accessor.name
- assert_equal 'RW', accessor.rw
- assert_equal 'This is an accessor', accessor.comment.text
- assert_equal @top_level, accessor.file
-
- reader = attrs.shift
- assert_equal 'reader', reader.name
- assert_equal 'R', reader.rw
- assert_equal 'This is a reader', reader.comment.text
-
- writer = attrs.shift
- assert_equal 'writer', writer.name
- assert_equal 'W', writer.rw
- assert_equal 'This is a writer', writer.comment.text
- end
-
- def test_do_attr_rb_define_attr
- content = <<-EOF
-void Init_Blah(void) {
- cBlah = rb_define_class("Blah", rb_cObject);
-
- /*
- * This is an accessor
- */
- rb_define_attr(cBlah, "accessor", 1, 1);
-}
- EOF
-
- klass = util_get_class content, 'cBlah'
-
- attrs = klass.attributes
- assert_equal 1, attrs.length, attrs.inspect
-
- accessor = attrs.shift
- assert_equal 'accessor', accessor.name
- assert_equal 'RW', accessor.rw
- assert_equal 'This is an accessor', accessor.comment.text
- assert_equal @top_level, accessor.file
+ {
+ num: %w[0 1],
+ macro: %w[FALSE TRUE],
+ ruby: %w[Qfalse Qtrue],
+ bool: %w[false true],
+ }.each_pair do |name, values|
+ define_method("test_do_attr:rb_attr:intern:#{name}") do
+ assert_do_attr(values) {|c, name, r, w| %[rb_attr(#{c}, rb_intern("#{name}"), #{r}, #{w}, Qfalse)]}
+ end
+ define_method("test_do_attr:rb_attr:intern_const:#{name}") do
+ assert_do_attr(values) {|c, name, r, w| %[rb_attr(#{c}, rb_intern_const("#{name}"), #{r}, #{w}, Qfalse)]}
+ end
+ define_method("test_do_attr:rb_define_attr:#{name}") do
+ assert_do_attr(values) {|c, name, r, w| %[rb_define_attr(#{c}, "#{name}", #{r}, #{w})]}
+ end
end
def test_do_aliases
@@ -355,6 +329,47 @@ VALUE cFoo = rb_define_class("Foo", rb_cObject);
/* Document-class: Foo
* this is the Foo class
*/
+VALUE cFoo = rb_struct_define(
+ "Foo",
+ "some", "various", "fields", NULL);
+ EOF
+
+ klass = util_get_class content, 'cFoo'
+ assert_equal "this is the Foo class", klass.comment.text
+
+ attributes = klass.attributes
+ assert_equal 3, attributes.size, -> {attributes}
+ ["some", "various", "fields"].zip(attributes) do |name, attr|
+ assert_equal RDoc::Attr.new("", name, "RW", ""), attr
+ end
+ end
+
+ def test_do_classes_struct_under
+ content = <<-EOF
+/* Document-class: Kernel::Foo
+ * this is the Foo class under Kernel
+ */
+VALUE cFoo = rb_struct_define_under(
+ rb_mKernel, "Foo",
+ "some", "various", "fields", NULL);
+ EOF
+
+ klass = util_get_class content, 'cFoo'
+ assert_equal 'Kernel::Foo', klass.full_name
+ assert_equal "this is the Foo class under Kernel", klass.comment.text
+
+ attributes = klass.attributes
+ assert_equal 3, attributes.size, -> {attributes}
+ ["some", "various", "fields"].zip(attributes) do |name, attr|
+ assert_equal RDoc::Attr.new("", name, "RW", ""), attr
+ end
+ end
+
+ def test_do_classes_struct_without_accessor
+ content = <<-EOF
+/* Document-class: Foo
+ * this is the Foo class
+ */
VALUE cFoo = rb_struct_define_without_accessor(
"Foo", rb_cObject, foo_alloc,
"some", "various", "fields", NULL);
@@ -362,6 +377,23 @@ VALUE cFoo = rb_struct_define_without_accessor(
klass = util_get_class content, 'cFoo'
assert_equal "this is the Foo class", klass.comment.text
+ assert_empty klass.attributes
+ end
+
+ def test_do_classes_struct_without_accessor_under
+ content = <<-EOF
+/* Document-class: Kernel::Foo
+ * this is the Foo class under Kernel
+ */
+VALUE cFoo = rb_struct_define_without_accessor_under(
+ rb_mKernel, "Foo", rb_cObject, foo_alloc,
+ "some", "various", "fields", NULL);
+ EOF
+
+ klass = util_get_class content, 'cFoo'
+ assert_equal 'Kernel::Foo', klass.full_name
+ assert_equal "this is the Foo class under Kernel", klass.comment.text
+ assert_empty klass.attributes
end
def test_do_classes_class_under
@@ -428,7 +460,7 @@ VALUE mFoo = rb_define_module_under(rb_mKernel, "Foo");
end
def test_do_constants
- content = <<-EOF
+ content = <<-'EOF'
#include <ruby.h>
void Init_foo(){
@@ -443,6 +475,9 @@ void Init_foo(){
/* TEST\:TEST: Checking to see if escaped colon works */
rb_define_const(cFoo, "TEST", rb_str_new2("TEST:TEST"));
+ /* TEST: TEST:Checking to see if only word-ending colon works */
+ rb_define_const(cFoo, "TEST2", rb_str_new2("TEST:TEST"));
+
/* \\: The file separator on MS Windows */
rb_define_const(cFoo, "MSEPARATOR", rb_str_new2("\\"));
@@ -506,6 +541,9 @@ void Init_foo(){
assert_equal ['TEST', 'TEST:TEST',
'Checking to see if escaped colon works '],
constants.shift
+ assert_equal ['TEST2', 'TEST',
+ 'TEST:Checking to see if only word-ending colon works '],
+ constants.shift
assert_equal ['MSEPARATOR', '\\',
'The file separator on MS Windows '],
constants.shift
@@ -545,8 +583,6 @@ void Init_curses(){
mCurses = rb_define_module("Curses");
/*
- * Document-const: Curses::COLOR_BLACK
- *
* Value of the color black
*/
rb_curses_define_const(COLOR_BLACK);
@@ -571,8 +607,7 @@ void Init_curses(){
def test_do_constants_file
content = <<-EOF
void Init_File(void) {
- /* Document-const: LOCK_SH
- *
+ /*
* Shared lock
*/
rb_file_const("LOCK_SH", INT2FIX(LOCK_SH));
@@ -594,6 +629,17 @@ void Init_File(void) {
assert_equal 'LOCK_SH', constant.name
assert_equal 'INT2FIX(LOCK_SH)', constant.value
assert_equal 'Shared lock', constant.comment.text
+
+ @parser = util_parser <<-EOF
+void Init_File(void) {
+ rb_cFile = rb_define_class("File", rb_cIO);
+ rb_mFConst = rb_define_module_under(rb_cFile, "Constants");
+}
+ EOF
+ @parser.do_classes_and_modules
+ @parser.do_constants
+
+ assert_equal 'File::Constants', klass.full_name
end
def test_do_includes
@@ -853,6 +899,23 @@ Init_Foo(void) {
assert_equal "a comment for class Foo", klass.comment.text
end
+
+ def test_find_class_comment_initvm
+ content = <<-EOF
+/*
+ * a comment for class Foo
+ */
+void
+InitVM_Foo(void) {
+ VALUE foo = rb_define_class("Foo", rb_cObject);
+}
+ EOF
+
+ klass = util_get_class content, 'foo'
+
+ assert_equal "a comment for class Foo", klass.comment.text
+ end
+
def test_find_class_comment_define_class
content = <<-EOF
/*
@@ -1313,6 +1376,36 @@ Init_Foo(void) {
assert_equal "DLL_LOCAL VALUE\nother_function() {\n}", code
end
+ def test_find_body_static_inline
+ content = <<-EOF
+/*
+ * a comment for other_function
+ */
+static inline VALUE
+other_function() {
+}
+
+void
+Init_Foo(void) {
+ VALUE foo = rb_define_class("Foo", rb_cObject);
+
+ rb_define_method(foo, "my_method", other_function, 0);
+}
+ EOF
+
+ klass = util_get_class content, 'foo'
+ other_function = klass.method_list.first
+
+ assert_equal 'my_method', other_function.name
+ assert_equal "a comment for other_function",
+ other_function.comment.text
+ assert_equal '()', other_function.params
+
+ code = other_function.token_stream.first[:text]
+
+ assert_equal "static inline VALUE\nother_function() {\n}", code
+ end
+
def test_find_modifiers_call_seq
comment = RDoc::Comment.new <<-COMMENT
call-seq:
@@ -2008,4 +2101,3 @@ void Init_Blah(void) {
end
end
-
diff --git a/test/rdoc/test_rdoc_parser_changelog.rb b/test/rdoc/test_rdoc_parser_changelog.rb
index 6584840572..587a156d3a 100644
--- a/test/rdoc/test_rdoc_parser_changelog.rb
+++ b/test/rdoc/test_rdoc_parser_changelog.rb
@@ -482,4 +482,3 @@ ChangeLog
RDoc::Parser::ChangeLog::Git::LogEntry.new(*a)
end
end
-
diff --git a/test/rdoc/test_rdoc_parser_markdown.rb b/test/rdoc/test_rdoc_parser_markdown.rb
index 06c6700d96..cca9c1ddfd 100644
--- a/test/rdoc/test_rdoc_parser_markdown.rb
+++ b/test/rdoc/test_rdoc_parser_markdown.rb
@@ -59,4 +59,3 @@ class TestRDocParserMarkdown < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_parser_rd.rb b/test/rdoc/test_rdoc_parser_rd.rb
index bac9c65592..48663e6d7d 100644
--- a/test/rdoc/test_rdoc_parser_rd.rb
+++ b/test/rdoc/test_rdoc_parser_rd.rb
@@ -53,4 +53,3 @@ class TestRDocParserRd < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb
index 337cf9ea1a..3e2a85ffba 100644
--- a/test/rdoc/test_rdoc_parser_ruby.rb
+++ b/test/rdoc/test_rdoc_parser_ruby.rb
@@ -921,7 +921,7 @@ end
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
end
err = stds[1]
- assert_match(/Expected class name or '<<'\. Got/, err)
+ assert_match(/Expected class name or '<<\'\. Got/, err)
end
def test_parse_syntax_error_code
@@ -1960,10 +1960,10 @@ end
def test_parse_method_bracket
util_parser <<-RUBY
class C
- def [] end
- def self.[] end
- def []= end
- def self.[]= end
+ def []; end
+ def self.[]; end
+ def []=; end
+ def self.[]=; end
end
RUBY
@@ -3065,6 +3065,28 @@ RUBY
assert_nil m.params, 'Module parameter not removed'
end
+ def test_parse_statements_nodoc_identifier_alias
+ klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+
+ util_parser "\nalias :old :new # :nodoc:"
+
+ @parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
+
+ assert_empty klass.aliases
+ assert_empty klass.unmatched_alias_lists
+ end
+
+ def test_parse_statements_nodoc_identifier_alias_method
+ klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+
+ util_parser "\nalias_method :old :new # :nodoc:"
+
+ @parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
+
+ assert_empty klass.aliases
+ assert_empty klass.unmatched_alias_lists
+ end
+
def test_parse_statements_stopdoc_alias
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
@@ -3205,6 +3227,14 @@ RUBY
assert_nil @parser.parse_symbol_in_arg
end
+ def test_parse_percent_symbol
+ content = '%s[foo bar]'
+ util_parser content
+ tk = @parser.get_tk
+ assert_equal :on_symbol, tk[:kind]
+ assert_equal content, tk[:text]
+ end
+
def test_parse_statements_alias_method
content = <<-CONTENT
class A
@@ -3350,6 +3380,13 @@ end
assert_equal :on_const, parser.get_tk[:kind]
end
+ def test_read_directive_linear_performance
+ pre = ->(i) {util_parser '# ' + '0'*i + '=000:'}
+ assert_linear_performance((1..5).map{|i|10**i}, pre: pre) do |parser|
+ assert_nil parser.read_directive []
+ end
+ end
+
def test_read_documentation_modifiers
c = RDoc::Context.new
@@ -4345,4 +4382,17 @@ end
assert_equal 'Hello', meth.comment.text
end
+ def test_parenthesized_cdecl
+ util_parser <<-RUBY
+module DidYouMean
+ class << (NameErrorCheckers = Object.new)
+ end
+end
+ RUBY
+
+ @parser.scan
+
+ refute_predicate @store.find_class_or_module('DidYouMean'), :nil?
+ refute_predicate @store.find_class_or_module('DidYouMean::NameErrorCheckers'), :nil?
+ end
end
diff --git a/test/rdoc/test_rdoc_parser_simple.rb b/test/rdoc/test_rdoc_parser_simple.rb
index 2f1ad00de4..4255cb97d8 100644
--- a/test/rdoc/test_rdoc_parser_simple.rb
+++ b/test/rdoc/test_rdoc_parser_simple.rb
@@ -113,4 +113,3 @@ contents of a string.
end
end
-
diff --git a/test/rdoc/test_rdoc_rd.rb b/test/rdoc/test_rdoc_rd.rb
index 83ee423455..38de575bb0 100644
--- a/test/rdoc/test_rdoc_rd.rb
+++ b/test/rdoc/test_rdoc_rd.rb
@@ -28,4 +28,3 @@ class TestRDocRd < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_rd_block_parser.rb b/test/rdoc/test_rdoc_rd_block_parser.rb
index 22f432eaf4..ca0ac9f9e9 100644
--- a/test/rdoc/test_rdoc_rd_block_parser.rb
+++ b/test/rdoc/test_rdoc_rd_block_parser.rb
@@ -168,6 +168,27 @@ class TestRDocRdBlockParser < RDoc::TestCase
tf.close!
end
+=begin
+ def test_parse_include_other_format
+ @block_parser.include_path = [Dir.tmpdir]
+
+ expected =
+ doc(
+ blank_line,
+ para("include ((*worked*))"),
+ blank_line,
+ blank_line)
+
+ str = <<~STR
+ =begin nonrd
+ <<< worked
+ =end
+ STR
+
+ assert_equal(expected, @block_parser.parse str.lines.to_a)
+ end
+=end
+
def test_parse_heading
assert_equal doc(head(1, "H")), parse("= H")
assert_equal doc(head(2, "H")), parse("== H")
diff --git a/test/rdoc/test_rdoc_rd_inline.rb b/test/rdoc/test_rdoc_rd_inline.rb
index 13ab86d3d9..6bfb229933 100644
--- a/test/rdoc/test_rdoc_rd_inline.rb
+++ b/test/rdoc/test_rdoc_rd_inline.rb
@@ -61,4 +61,3 @@ class TestRDocRdInline < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb
index eaf92c8a9f..5168932430 100644
--- a/test/rdoc/test_rdoc_rdoc.rb
+++ b/test/rdoc/test_rdoc_rdoc.rb
@@ -165,12 +165,7 @@ class TestRDocRDoc < RDoc::TestCase
b = Dir.glob(b).first
c = Dir.glob(c).first
- dot_doc = File.expand_path('.document')
- FileUtils.touch dot_doc
- open(dot_doc, 'w') do |f|
- f.puts 'a.rb'
- f.puts 'b.rb'
- end
+ File.write('.document', "a.rb\n""b.rb\n")
expected_files << a
expected_files << b
@@ -196,12 +191,7 @@ class TestRDocRDoc < RDoc::TestCase
b = Dir.glob(b).first
c = Dir.glob(c).first
- dot_doc = File.expand_path('.document')
- FileUtils.touch dot_doc
- open(dot_doc, 'w') do |f|
- f.puts 'a.rb'
- f.puts 'b.rb'
- end
+ File.write('.document', "a.rb\n""b.rb\n")
expected_files << a
@rdoc.options.exclude = Regexp.new(['b.rb'].join('|'))
@@ -213,6 +203,48 @@ class TestRDocRDoc < RDoc::TestCase
assert_equal expected_files, files
end
+ def test_normalized_file_list_with_skipping_tests_enabled
+ files = temp_dir do |dir|
+ @a = File.expand_path('a.rb')
+ spec_dir = File.expand_path('spec')
+ spec_file = File.expand_path(File.join('spec', 'my_spec.rb'))
+ test_dir = File.expand_path('test')
+ test_file = File.expand_path(File.join('test', 'my_test.rb'))
+ FileUtils.touch @a
+ FileUtils.mkdir_p spec_dir
+ FileUtils.touch spec_file
+ FileUtils.mkdir_p test_dir
+ FileUtils.touch test_file
+
+ @rdoc.options.skip_tests = true
+ @rdoc.normalized_file_list [File.realpath(dir)]
+ end
+
+ files = files.map { |file, *| File.expand_path file }
+ assert_equal [@a], files
+ end
+
+ def test_normalized_file_list_with_skipping_tests_disabled
+ files = temp_dir do |dir|
+ @a = File.expand_path('a.rb')
+ spec_dir = File.expand_path('spec')
+ @spec_file = File.expand_path(File.join('spec', 'my_spec.rb'))
+ test_dir = File.expand_path('test')
+ @test_file = File.expand_path(File.join('test', 'my_test.rb'))
+ FileUtils.touch @a
+ FileUtils.mkdir_p spec_dir
+ FileUtils.touch @spec_file
+ FileUtils.mkdir_p test_dir
+ FileUtils.touch @test_file
+
+ @rdoc.options.skip_tests = false
+ @rdoc.normalized_file_list [File.realpath(dir)]
+ end
+
+ files = files.map { |file, *| File.expand_path file }
+ assert_equal [@a, @spec_file, @test_file], files.sort
+ end
+
def test_parse_file
@rdoc.store = RDoc::Store.new
@@ -254,6 +286,7 @@ class TestRDocRDoc < RDoc::TestCase
top_level = nil
temp_dir do |dir|
@rdoc.options.parse %W[--root #{test_path}]
+ @rdoc.options.finish
File.open 'include.txt', 'w' do |io|
io.puts ':include: test.txt'
diff --git a/test/rdoc/test_rdoc_require.rb b/test/rdoc/test_rdoc_require.rb
index 46c225299a..4cc53e6c6c 100644
--- a/test/rdoc/test_rdoc_require.rb
+++ b/test/rdoc/test_rdoc_require.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocRequire < XrefTestCase
@@ -23,4 +23,3 @@ class TestRDocRequire < XrefTestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb
index 87e4ebd2b1..39e6e67759 100644
--- a/test/rdoc/test_rdoc_ri_driver.rb
+++ b/test/rdoc/test_rdoc_ri_driver.rb
@@ -6,17 +6,13 @@ class TestRDocRIDriver < RDoc::TestCase
def setup
super
- @tmpdir = File.join Dir.tmpdir, "test_rdoc_ri_driver_#{$$}"
- @home_ri = File.join @tmpdir, 'dot_ri'
+ @home_ri = File.join @test_home, 'dot_ri'
- FileUtils.mkdir_p @tmpdir
FileUtils.mkdir_p @home_ri
- @orig_ri = ENV['RI']
- ENV['HOME'] = @tmpdir
- @rdoc_home = File.join ENV["HOME"], ".rdoc"
+ @orig_ri = ENV.delete('RI')
+ @rdoc_home = File.join @test_home, ".rdoc"
FileUtils.mkdir_p @rdoc_home
- ENV.delete 'RI'
@options = RDoc::RI::Driver.default_options
@options[:use_system] = false
@@ -24,7 +20,7 @@ class TestRDocRIDriver < RDoc::TestCase
@options[:use_home] = false
@options[:use_gems] = false
- @options[:home] = @tmpdir
+ @options[:home] = @rdoc_home
@options[:use_stdout] = true
@options[:formatter] = @RM::ToRdoc
@@ -32,13 +28,17 @@ class TestRDocRIDriver < RDoc::TestCase
end
def teardown
- ENV['RI'] = @orig_ri
- FileUtils.rm_rf @tmpdir
+ defined?(@orig_ri) and ENV['RI'] = @orig_ri
super
end
- DUMMY_PAGER = ":;\n"
+ case RUBY_PLATFORM
+ when /mswin|mingw/
+ DUMMY_PAGER = "type nul"
+ else
+ DUMMY_PAGER = "true"
+ end
def with_dummy_pager
pager_env, ENV['RI_PAGER'] = ENV['RI_PAGER'], DUMMY_PAGER
@@ -598,7 +598,7 @@ class TestRDocRIDriver < RDoc::TestCase
assert_match %r%^= Attributes:%, out
assert_match %r%^ attr_accessor attr%, out
- assert_equal 1, out.scan(/-\n/).length
+ assert_equal 1, out.scan(/^-{50,}$/).length, out
refute_match %r%Foo::Bar#blah%, out
end
@@ -622,7 +622,7 @@ class TestRDocRIDriver < RDoc::TestCase
assert_match %r%^= Attributes:%, out
assert_match %r%^ attr_accessor attr%, out
- assert_equal 6, out.scan(/-\n/).length
+ assert_equal 6, out.scan(/^-{50,}$/).length, out
assert_match %r%Foo::Bar#blah%, out
end
@@ -1091,23 +1091,6 @@ Foo::Bar#bother
assert_instance_of @RM::ToBs, driver.formatter(StringIO.new)
end
- def test_in_path_eh
- path = ENV['PATH']
-
- test_path = File.expand_path '..', __FILE__
-
- temp_dir do |dir|
- nonexistent = File.join dir, 'nonexistent'
- refute @driver.in_path?(nonexistent)
-
- ENV['PATH'] = test_path
-
- assert @driver.in_path?(File.basename(__FILE__))
- end
- ensure
- ENV['PATH'] = path
- end
-
def test_method_type
assert_equal :both, @driver.method_type(nil)
assert_equal :both, @driver.method_type('.')
@@ -1246,7 +1229,7 @@ Foo::Bar#bother
assert_equal '(unknown)#inherit', method.full_name
end
- def _test_page # this test doesn't do anything anymore :(
+ def test_page
@driver.use_stdout = false
with_dummy_pager do
@@ -1260,9 +1243,7 @@ Foo::Bar#bother
refute @driver.paging?
end
- # this test is too fragile. Perhaps using Process.spawn will make this
- # reliable
- def _test_page_in_presence_of_child_status
+ def test_page_in_presence_of_child_status
@driver.use_stdout = false
with_dummy_pager do
@@ -1425,7 +1406,7 @@ Foo::Bar#bother
end
end
- def _test_setup_pager # this test doesn't do anything anymore :(
+ def test_setup_pager # this test doesn't do anything anymore :(
@driver.use_stdout = false
pager = with_dummy_pager do @driver.setup_pager end
diff --git a/test/rdoc/test_rdoc_ri_paths.rb b/test/rdoc/test_rdoc_ri_paths.rb
index c01a4711ee..6dccd6dbdd 100644
--- a/test/rdoc/test_rdoc_ri_paths.rb
+++ b/test/rdoc/test_rdoc_ri_paths.rb
@@ -155,4 +155,3 @@ class TestRDocRIPaths < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb
index 04f84d4bcc..59a7ed0f89 100644
--- a/test/rdoc/test_rdoc_rubygems_hook.rb
+++ b/test/rdoc/test_rdoc_rubygems_hook.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require "rubygems"
-require "fileutils"
-require "tmpdir"
-require 'rdoc/rubygems_hook'
-require "test/unit"
+require 'rubygems'
+require 'fileutils'
+require 'tmpdir'
+require_relative '../../lib/rdoc/rubygems_hook'
+require 'test/unit'
class TestRDocRubygemsHook < Test::Unit::TestCase
def setup
diff --git a/test/rdoc/test_rdoc_single_class.rb b/test/rdoc/test_rdoc_single_class.rb
index ee242d7bc9..e81a1498ba 100644
--- a/test/rdoc/test_rdoc_single_class.rb
+++ b/test/rdoc/test_rdoc_single_class.rb
@@ -18,4 +18,3 @@ class TestRDocSingleClass < RDoc::TestCase
end
end
-
diff --git a/test/rdoc/test_rdoc_stats.rb b/test/rdoc/test_rdoc_stats.rb
index b9918e4fd3..ce272d36cf 100644
--- a/test/rdoc/test_rdoc_stats.rb
+++ b/test/rdoc/test_rdoc_stats.rb
@@ -720,4 +720,3 @@ m(a, b) { |c, d| ... }
end
end
-
diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb
index 0abad42328..50e8667d81 100644
--- a/test/rdoc/test_rdoc_store.rb
+++ b/test/rdoc/test_rdoc_store.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocStore < XrefTestCase
@@ -319,8 +319,7 @@ class TestRDocStore < XrefTestCase
end
def test_friendly_path
- @orig_xdg_data_home = ENV['XDG_DATA_HOME']
- ENV.delete('XDG_DATA_HOME')
+ @orig_xdg_data_home = ENV.delete('XDG_DATA_HOME')
@s.path = @tmpdir
@s.type = nil
@@ -374,9 +373,9 @@ class TestRDocStore < XrefTestCase
assert_equal [@mod], s.all_modules.sort
assert_equal [@page, @top_level], s.all_files.sort
- methods = s.all_classes_and_modules.map do |mod|
+ methods = s.all_classes_and_modules.flat_map do |mod|
mod.method_list
- end.flatten.sort
+ end.sort
_meth_bang_alias = RDoc::AnyMethod.new nil, 'method_bang'
_meth_bang_alias.parent = @klass
@@ -389,9 +388,9 @@ class TestRDocStore < XrefTestCase
assert_equal @klass, methods.last.parent
- attributes = s.all_classes_and_modules.map do |mod|
+ attributes = s.all_classes_and_modules.flat_map do |mod|
mod.attributes
- end.flatten.sort
+ end.sort
assert_equal [@attr], attributes
diff --git a/test/rdoc/test_rdoc_task.rb b/test/rdoc/test_rdoc_task.rb
index 77f2af33a3..67d223087b 100644
--- a/test/rdoc/test_rdoc_task.rb
+++ b/test/rdoc/test_rdoc_task.rb
@@ -50,6 +50,7 @@ class TestRDocTask < RDoc::TestCase
assert Rake::Task[:rdoc]
assert Rake::Task[:clobber_rdoc]
assert Rake::Task[:rerdoc]
+ assert Rake::Task[:"rdoc:coverage"]
assert_equal ["html/created.rid"], Rake::Task[:rdoc].prerequisites
end
@@ -58,6 +59,7 @@ class TestRDocTask < RDoc::TestCase
assert Rake::Task[:rdoc_dev]
assert Rake::Task[:clobber_rdoc_dev]
assert Rake::Task[:rerdoc_dev]
+ assert Rake::Task[:"rdoc_dev:coverage"]
assert_equal :rdoc_dev, rd.name
end
@@ -110,11 +112,16 @@ class TestRDocTask < RDoc::TestCase
assert_equal 'Rebuild RDoc HTML files', @t.rerdoc_task_description
end
+ def test_coverage_task_description
+ assert_equal 'Print RDoc coverage report', @t.coverage_task_description
+ end
+
def test_tasks_creation_with_custom_name_string
rd = RDoc::Task.new("rdoc_dev")
assert Rake::Task[:rdoc_dev]
assert Rake::Task[:clobber_rdoc_dev]
assert Rake::Task[:rerdoc_dev]
+ assert Rake::Task[:"rdoc_dev:coverage"]
assert_equal "rdoc_dev", rd.name
end
@@ -131,6 +138,7 @@ class TestRDocTask < RDoc::TestCase
assert Rake::Task[:"rdoc"]
assert Rake::Task[:"rdoc:clean"]
assert Rake::Task[:"rdoc:force"]
+ assert Rake::Task[:"rdoc:coverage"]
assert_raise(RuntimeError) { Rake::Task[:clobber_rdoc] }
assert_equal options, rd.name
end
@@ -140,6 +148,7 @@ class TestRDocTask < RDoc::TestCase
assert Rake::Task[:rdoc]
assert Rake::Task[:"rdoc:clean"]
assert Rake::Task[:rerdoc]
+ assert Rake::Task[:"rdoc:coverage"]
end
def test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option_given
@@ -171,4 +180,3 @@ class TestRDocTask < RDoc::TestCase
end
end if defined?(Rake::Task)
-
diff --git a/test/rdoc/test_rdoc_token_stream.rb b/test/rdoc/test_rdoc_token_stream.rb
index cdfa615dae..8fcd3d8f68 100644
--- a/test/rdoc/test_rdoc_token_stream.rb
+++ b/test/rdoc/test_rdoc_token_stream.rb
@@ -39,6 +39,49 @@ class TestRDocTokenStream < RDoc::TestCase
assert_equal '', RDoc::TokenStream.to_html([])
end
+ def test_add_tokens
+ foo = Class.new do
+ include RDoc::TokenStream
+ end.new
+ foo.collect_tokens
+ foo.add_tokens([:token])
+ assert_equal [:token], foo.token_stream
+ end
+
+ def test_add_token
+ foo = Class.new do
+ include RDoc::TokenStream
+ end.new
+ foo.collect_tokens
+ foo.add_token(:token)
+ assert_equal [:token], foo.token_stream
+ end
+
+ def test_collect_tokens
+ foo = Class.new do
+ include RDoc::TokenStream
+ end.new
+ foo.collect_tokens
+ assert_equal [], foo.token_stream
+ end
+
+ def test_pop_token
+ foo = Class.new do
+ include RDoc::TokenStream
+ end.new
+ foo.collect_tokens
+ foo.add_token(:token)
+ foo.pop_token
+ assert_equal [], foo.token_stream
+ end
+
+ def test_token_stream
+ foo = Class.new do
+ include RDoc::TokenStream
+ end.new
+ assert_equal nil, foo.token_stream
+ end
+
def test_tokens_to_s
foo = Class.new do
include RDoc::TokenStream
@@ -53,6 +96,14 @@ class TestRDocTokenStream < RDoc::TestCase
end.new
assert_equal "foo 'bar'", foo.tokens_to_s
+
+ foo = Class.new do
+ include RDoc::TokenStream
+
+ def initialize
+ @token_stream = nil
+ end
+ end.new
+ assert_equal "", foo.tokens_to_s
end
end
-
diff --git a/test/rdoc/test_rdoc_top_level.rb b/test/rdoc/test_rdoc_top_level.rb
index 3f6d153b68..3cfaa9b763 100644
--- a/test/rdoc/test_rdoc_top_level.rb
+++ b/test/rdoc/test_rdoc_top_level.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require File.expand_path '../xref_test_case', __FILE__
+require_relative 'xref_test_case'
class TestRDocTopLevel < XrefTestCase
@@ -288,4 +288,3 @@ class TestRDocTopLevel < XrefTestCase
end
end
-
diff --git a/test/rdoc/xref_data.rb b/test/rdoc/xref_data.rb
index de76a90602..257b821f4f 100644
--- a/test/rdoc/xref_data.rb
+++ b/test/rdoc/xref_data.rb
@@ -74,6 +74,12 @@ class C6
def priv4() end
public def pub5() end
def priv5() end
+ def self.s_pub1() end
+ class << self
+ def s_pub2() end
+ private
+ def s_priv1() end
+ end
protected
private def priv6() end
@@ -82,6 +88,12 @@ class C6
def prot5() end
public def pub6() end
def prot6() end
+ def self.s_pub3() end
+ class << self
+ def s_pub4() end
+ protected
+ def s_prot1() end
+ end
end
class C7
@@ -149,4 +161,3 @@ class Child < Parent
end
XREF_DATA
-
diff --git a/test/rdoc/xref_test_case.rb b/test/rdoc/xref_test_case.rb
index 22b00d04bc..0f7395e516 100644
--- a/test/rdoc/xref_test_case.rb
+++ b/test/rdoc/xref_test_case.rb
@@ -91,4 +91,3 @@ class XrefTestCase < RDoc::TestCase
end
end
-