diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-23 01:02:24 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-23 01:02:24 +0000 |
commit | 5864dbc9f16ea388f0038669c86ac79f2a0ac432 (patch) | |
tree | d602899b4f3f2f1465688123acd05dce7ad9fe84 /test | |
parent | 95548d9dc32238fc2134ceefb7efd8450fe793d7 (diff) | |
download | ruby-5864dbc9f16ea388f0038669c86ac79f2a0ac432.tar.gz |
* lib/rdoc/servlet.rb: Fixed display of site and home documentation.
Fixes rdoc issue #170 by Thomas Leitner.
* test/rdoc/test_rdoc_servlet.rb: Test for above.
* lib/rdoc/code_object.rb: Split #initialize_visibility from
#initialize for reuse when loading a stored object.
Fixes rdoc issue #171 by Thomas Leitner.
* lib/rdoc/any_method.rb: Initialize visibility for #display? For
rdoc issue #171
* lib/rdoc/attr.rb: ditto.
* lib/rdoc/class_module.rb: ditto.
* lib/rdoc/top_level.rb: ditto.
* test/rdoc/test_rdoc_any_method.rb: Test for above.
* test/rdoc/test_rdoc_attr.rb: ditto.
* test/rdoc/test_rdoc_class_module.rb: ditto.
* test/rdoc/test_rdoc_constant.rb: ditto.
* test/rdoc/test_rdoc_top_level.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/rdoc/test_rdoc_any_method.rb | 23 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_attr.rb | 4 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_class_module.rb | 2 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_constant.rb | 4 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_servlet.rb | 46 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_top_level.rb | 2 |
6 files changed, 70 insertions, 11 deletions
diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb index abf749c4c9..cb4a979392 100644 --- a/test/rdoc/test_rdoc_any_method.rb +++ b/test/rdoc/test_rdoc_any_method.rb @@ -100,24 +100,31 @@ method(a, b) { |c, d| ... } assert_equal section, loaded.section end - def test_marshal_load - instance_method = Marshal.load Marshal.dump(@c1.method_list.last) - - assert_equal 'C1#m', instance_method.full_name - assert_equal 'C1', instance_method.parent_name - assert_equal '(foo)', instance_method.params - + def test_marshal_load_aliased_method aliased_method = Marshal.load Marshal.dump(@c2.method_list.last) assert_equal 'C2#a', aliased_method.full_name assert_equal 'C2', aliased_method.parent_name assert_equal '()', aliased_method.params + assert aliased_method.display? + end + def test_marshal_load_class_method class_method = Marshal.load Marshal.dump(@c1.method_list.first) assert_equal 'C1::m', class_method.full_name assert_equal 'C1', class_method.parent_name assert_equal '()', class_method.params + assert class_method.display? + end + + def test_marshal_load_instance_method + instance_method = Marshal.load Marshal.dump(@c1.method_list.last) + + assert_equal 'C1#m', instance_method.full_name + assert_equal 'C1', instance_method.parent_name + assert_equal '(foo)', instance_method.params + assert instance_method.display? end def test_marshal_load_version_0 @@ -163,6 +170,8 @@ method(a, b) { |c, d| ... } assert_equal nil, loaded.file assert_equal cm, loaded.parent assert_equal section, loaded.section + + assert loaded.display? end def test_name diff --git a/test/rdoc/test_rdoc_attr.rb b/test/rdoc/test_rdoc_attr.rb index 92ff1b9856..a4922df06c 100644 --- a/test/rdoc/test_rdoc_attr.rb +++ b/test/rdoc/test_rdoc_attr.rb @@ -137,6 +137,8 @@ class TestRDocAttr < RDoc::TestCase # version 3 assert_equal cm, loaded.parent assert_equal section, loaded.section + + assert loaded.display? end def test_marshal_load_version_2 @@ -165,6 +167,8 @@ class TestRDocAttr < RDoc::TestCase # version 3 assert_equal cm, loaded.parent assert_equal section, loaded.section + + assert loaded.display? end def test_params diff --git a/test/rdoc/test_rdoc_class_module.rb b/test/rdoc/test_rdoc_class_module.rb index 670f732290..ec81282c35 100644 --- a/test/rdoc/test_rdoc_class_module.rb +++ b/test/rdoc/test_rdoc_class_module.rb @@ -289,6 +289,8 @@ class TestRDocClassModule < XrefTestCase expected = { nil => s0 } assert_equal expected, loaded.sections_hash + + assert loaded.display? end def test_marshal_load_version_1 diff --git a/test/rdoc/test_rdoc_constant.rb b/test/rdoc/test_rdoc_constant.rb index 1a2e43a6e4..5c347f62ae 100644 --- a/test/rdoc/test_rdoc_constant.rb +++ b/test/rdoc/test_rdoc_constant.rb @@ -86,6 +86,8 @@ class TestRDocConstant < XrefTestCase assert_nil loaded.visibility assert_equal cm, loaded.parent assert_equal section, loaded.section + + assert loaded.display? end def test_marshal_load_version_0 @@ -116,6 +118,8 @@ class TestRDocConstant < XrefTestCase assert_nil loaded.visibility assert_equal cm, loaded.parent assert_equal section, loaded.section + + assert loaded.display? end def test_marshal_round_trip diff --git a/test/rdoc/test_rdoc_servlet.rb b/test/rdoc/test_rdoc_servlet.rb index 5c2ba4e6a7..7072a7dd86 100644 --- a/test/rdoc/test_rdoc_servlet.rb +++ b/test/rdoc/test_rdoc_servlet.rb @@ -12,7 +12,7 @@ class TestRDocServlet < RDoc::TestCase Gem.ensure_gem_subdirectories @tempdir @spec = Gem::Specification.new 'spec', '1.0' - @spec.loaded_from = File.join @tempdir, @spec.spec_file + @spec.loaded_from = @spec.spec_file Gem::Specification.reset Gem::Specification.all = [@spec] @@ -34,13 +34,15 @@ class TestRDocServlet < RDoc::TestCase @req.instance_variable_set :@header, Hash.new { |h, k| h[k] = [] } - @base = File.join @tempdir, 'base' - @system_dir = File.join @tempdir, 'base', 'system' + @base = File.join @tempdir, 'base' + @system_dir = File.join @tempdir, 'base', 'system' + @home_dir = File.join @tempdir, 'home' + @gem_doc_dir = File.join @tempdir, 'doc' @orig_base = RDoc::RI::Paths::BASE RDoc::RI::Paths::BASE.replace @base @orig_ri_path_homedir = RDoc::RI::Paths::HOMEDIR - RDoc::RI::Paths::HOMEDIR.replace File.join @tempdir, 'home' + RDoc::RI::Paths::HOMEDIR.replace @home_dir RDoc::RI::Paths.instance_variable_set \ :@gemdirs, %w[/nonexistent/gems/example-1.0/ri] @@ -416,6 +418,42 @@ class TestRDocServlet < RDoc::TestCase assert_match %r%\Avar search_data =%, @res.body end + def test_store_for_gem + store = @s.store_for 'spec-1.0' + + assert_equal File.join(@gem_doc_dir, 'spec-1.0', 'ri'), store.path + assert_equal :gem, store.type + end + + def test_store_for_home + store = @s.store_for 'home' + + assert_equal @home_dir, store.path + assert_equal :home, store.type + end + + def test_store_for_missing + e = assert_raises RDoc::Error do + @s.store_for 'missing' + end + + assert_equal 'could not find ri documentation for missing', e.message + end + + def test_store_for_ruby + store = @s.store_for 'ruby' + + assert_equal @system_dir, store.path + assert_equal :system, store.type + end + + def test_store_for_site + store = @s.store_for 'site' + + assert_equal File.join(@base, 'site'), store.path + assert_equal :site, store.type + end + def touch_system_cache_path store = RDoc::Store.new @system_dir store.title = 'Standard Library Documentation' diff --git a/test/rdoc/test_rdoc_top_level.rb b/test/rdoc/test_rdoc_top_level.rb index 99f7b22ae0..f3ee6a4784 100644 --- a/test/rdoc/test_rdoc_top_level.rb +++ b/test/rdoc/test_rdoc_top_level.rb @@ -205,6 +205,8 @@ class TestRDocTopLevel < XrefTestCase assert_equal RDoc::Parser::Simple, loaded.parser assert_equal comment, loaded.comment + + assert loaded.display? end def test_name |