summaryrefslogtreecommitdiff
path: root/test/rdoc
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-05 10:35:30 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-05 10:35:30 +0000
commit23863ff75d3ec9205d5f365b98b6608e38a93749 (patch)
tree362b9fc870edb3820ef488a6618baf5669d3aa48 /test/rdoc
parent0d715e1b7540e1c876a4c53862355d5c43dd8683 (diff)
* lib/rdoc/*, test/rdoc/*: Update rdoc/rdoc master(f191513)
https://github.com/rdoc/rdoc/blob/master/History.rdoc#423--2016-- https://github.com/rdoc/rdoc/blob/master/History.rdoc#422--2016-02-09 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc')
-rw-r--r--test/rdoc/test_rdoc_context.rb2
-rw-r--r--test/rdoc/test_rdoc_context_section.rb24
-rw-r--r--test/rdoc/test_rdoc_encoding.rb39
-rw-r--r--test/rdoc/test_rdoc_markup_to_html_crossref.rb6
-rw-r--r--test/rdoc/test_rdoc_parser_c.rb44
-rw-r--r--test/rdoc/test_rdoc_rdoc.rb1
-rw-r--r--test/rdoc/test_rdoc_ri_driver.rb18
-rw-r--r--test/rdoc/test_rdoc_servlet.rb19
8 files changed, 144 insertions, 9 deletions
diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb
index c619c6cacb..7b700bc234 100644
--- a/test/rdoc/test_rdoc_context.rb
+++ b/test/rdoc/test_rdoc_context.rb
@@ -417,7 +417,7 @@ class TestRDocContext < XrefTestCase
def bench_add_include
cm = RDoc::ClassModule.new 'Klass'
- assert_performance_linear 0.9 do |count|
+ assert_performance_linear 0.5 do |count|
count.times do |i|
cm.add_include RDoc::Include.new("N::M#{i}", nil)
end
diff --git a/test/rdoc/test_rdoc_context_section.rb b/test/rdoc/test_rdoc_context_section.rb
index bd82d191b6..b008c60c57 100644
--- a/test/rdoc/test_rdoc_context_section.rb
+++ b/test/rdoc/test_rdoc_context_section.rb
@@ -48,6 +48,22 @@ class TestRDocContextSection < RDoc::TestCase
assert_equal 'one+two', @S.new(nil, 'one two', nil).aref
end
+ def test_eql_eh
+ other = @S.new @klass, 'other', comment('# comment', @top_level)
+
+ assert @s.eql? @s
+ assert @s.eql? @s.dup
+ refute @s.eql? other
+ end
+
+ def test_equals
+ other = @S.new @klass, 'other', comment('# comment', @top_level)
+
+ assert_equal @s, @s
+ assert_equal @s, @s.dup
+ refute_equal @s, other
+ end
+
def test_extract_comment
assert_equal '', @s.extract_comment(comment('')).text
assert_equal '', @s.extract_comment(comment("# :section: b\n")).text
@@ -56,6 +72,14 @@ class TestRDocContextSection < RDoc::TestCase
@s.extract_comment(comment("# a\n# :section: b\n# c")).text
end
+ def test_hash
+ other = @S.new @klass, 'other', comment('# comment', @top_level)
+
+ assert_equal @s.hash, @s.hash
+ assert_equal @s.hash, @s.dup.hash
+ refute_equal @s.hash, other.hash
+ end
+
def test_marshal_dump
loaded = Marshal.load Marshal.dump @s
diff --git a/test/rdoc/test_rdoc_encoding.rb b/test/rdoc/test_rdoc_encoding.rb
index 313ede2bde..74d2a2668a 100644
--- a/test/rdoc/test_rdoc_encoding.rb
+++ b/test/rdoc/test_rdoc_encoding.rb
@@ -217,6 +217,45 @@ class TestRDocEncoding < RDoc::TestCase
end
end
+ def test_skip_frozen_string_literal
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
+
+ expected = "# frozen_string_literal: false\nhi everybody"
+
+ @tempfile.write expected
+ @tempfile.flush
+
+ contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
+ assert_equal "hi everybody", contents
+ assert_equal Encoding::UTF_8, contents.encoding
+ end
+
+ def test_skip_frozen_string_literal_after_coding
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
+
+ expected = "# coding: utf-8\n# frozen-string-literal: false\nhi everybody"
+
+ @tempfile.write expected
+ @tempfile.flush
+
+ contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
+ assert_equal "hi everybody", contents
+ assert_equal Encoding::UTF_8, contents.encoding
+ end
+
+ def test_skip_frozen_string_literal_before_coding
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
+
+ expected = "# frozen_string_literal: false\n# coding: utf-8\nhi everybody"
+
+ @tempfile.write expected
+ @tempfile.flush
+
+ contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
+ assert_equal "hi everybody", contents
+ assert_equal Encoding::UTF_8, contents.encoding
+ end
+
def test_sanity
skip "Encoding not implemented" unless Object.const_defined? :Encoding
diff --git a/test/rdoc/test_rdoc_markup_to_html_crossref.rb b/test/rdoc/test_rdoc_markup_to_html_crossref.rb
index 39a482740f..b9b5629554 100644
--- a/test/rdoc/test_rdoc_markup_to_html_crossref.rb
+++ b/test/rdoc/test_rdoc_markup_to_html_crossref.rb
@@ -44,6 +44,12 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
assert_equal para("<a href=\"C1.html#Section\">Section at C1</a>"), result
end
+ def test_convert_CROSSREF_constant
+ result = @to.convert 'C1::CONST'
+
+ assert_equal para("<a href=\"C1.html#CONST\">C1::CONST</a>"), result
+ end
+
def test_convert_RDOCLINK_rdoc_ref
result = @to.convert 'rdoc-ref:C1'
diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb
index fdc303e3e5..09d7c4b16d 100644
--- a/test/rdoc/test_rdoc_parser_c.rb
+++ b/test/rdoc/test_rdoc_parser_c.rb
@@ -176,6 +176,50 @@ 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) {
diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb
index 793580de86..b87f44b652 100644
--- a/test/rdoc/test_rdoc_rdoc.rb
+++ b/test/rdoc/test_rdoc_rdoc.rb
@@ -300,6 +300,7 @@ class TestRDocRDoc < RDoc::TestCase
blah.eps
blah.erb
blah.scpt.txt
+ blah.svg
blah.ttf
blah.yml
]
diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb
index cba7bedb2a..ba334d3708 100644
--- a/test/rdoc/test_rdoc_ri_driver.rb
+++ b/test/rdoc/test_rdoc_ri_driver.rb
@@ -834,6 +834,24 @@ Foo::Bar#bother
end
end
+ def test_expand_class_2
+ @store1 = RDoc::RI::Store.new @home_ri, :home
+
+ @top_level = @store1.add_file 'file.rb'
+
+ @cFoo = @top_level.add_class RDoc::NormalClass, 'Foo'
+ @mFox = @top_level.add_module RDoc::NormalModule, 'Fox'
+ @cFoo_Bar = @cFoo.add_class RDoc::NormalClass, 'Bar'
+ @store1.save
+
+ @driver.stores = [@store1]
+ assert_raises RDoc::RI::Driver::NotFoundError do
+ @driver.expand_class 'F'
+ end
+ assert_equal 'Foo::Bar', @driver.expand_class('F::Bar')
+ assert_equal 'Foo::Bar', @driver.expand_class('F::B')
+ end
+
def test_expand_name
util_store
diff --git a/test/rdoc/test_rdoc_servlet.rb b/test/rdoc/test_rdoc_servlet.rb
index 37ce148114..947d8c896c 100644
--- a/test/rdoc/test_rdoc_servlet.rb
+++ b/test/rdoc/test_rdoc_servlet.rb
@@ -66,14 +66,15 @@ class TestRDocServlet < RDoc::TestCase
def test_asset
temp_dir do
- now = Time.now
+ FileUtils.mkdir 'css'
- open 'rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end
- File.utime now, now, 'rdoc.css'
+ now = Time.now
+ open 'css/rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end
+ File.utime now, now, 'css/rdoc.css'
@s.asset_dirs[:darkfish] = '.'
- @req.path = 'rdoc.css'
+ @req.path = '/css/rdoc.css'
@s.asset :darkfish, @req, @res
@@ -95,11 +96,12 @@ class TestRDocServlet < RDoc::TestCase
def test_do_GET_asset_darkfish
temp_dir do
- FileUtils.touch 'rdoc.css'
+ FileUtils.mkdir 'css'
+ FileUtils.touch 'css/rdoc.css'
@s.asset_dirs[:darkfish] = '.'
- @req.path = '/rdoc.css'
+ @req.path = '/css/rdoc.css'
@s.do_GET @req, @res
@@ -136,11 +138,12 @@ class TestRDocServlet < RDoc::TestCase
@s = RDoc::Servlet.new @server, @stores, @cache, '/mount/path'
temp_dir do
- FileUtils.touch 'rdoc.css'
+ FileUtils.mkdir 'css'
+ FileUtils.touch 'css/rdoc.css'
@s.asset_dirs[:darkfish] = '.'
- @req.path = '/mount/path/rdoc.css'
+ @req.path = '/mount/path/css/rdoc.css'
@s.do_GET @req, @res