From 8aa895294b8d696489b51a5e69b2986f452da905 Mon Sep 17 00:00:00 2001 From: drbrain Date: Sat, 5 Feb 2011 06:20:57 +0000 Subject: Import RDoc 3.5.2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rdoc/test_rdoc_context.rb | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'test/rdoc/test_rdoc_context.rb') diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb index 9f110fc9f8..71870c545f 100644 --- a/test/rdoc/test_rdoc_context.rb +++ b/test/rdoc/test_rdoc_context.rb @@ -251,6 +251,34 @@ class TestRDocContext < XrefTestCase refute_equal @c2_c3, @c3 end + def test_each_section + sects = [] + consts = [] + attrs = [] + + @c1.each_section do |section, constants, attributes| + sects << section + consts << constants + attrs << attributes + end + + assert_equal [nil, 'separate'], sects.map { |section| section.title } + + expected_consts = [ + [@c1.constants.first], + [], + ] + + assert_equal expected_consts, consts + + expected_attrs = [ + [@c1.attributes[0], @c1.attributes[3]], + [@c1.attributes[1], @c1.attributes[2]], + ] + + assert_equal expected_attrs, attrs + end + def test_find_attribute_named assert_equal nil, @c1.find_attribute_named('none') assert_equal 'R', @c1.find_attribute_named('attr').rw @@ -373,5 +401,42 @@ class TestRDocContext < XrefTestCase assert_equal(-1, @c2_c3.<=>(@c3)) end + def test_methods_by_type + expected = { + 'instance' => { + :private => [], + :protected => [], + :public => [@c1_m], + }, + 'class' => { + :private => [], + :protected => [], + :public => [@c1__m], + }, + } + + assert_equal expected, @c1.methods_by_type + end + + def test_methods_by_type_section + separate = @c1.sections_hash['separate'] + @c1_m.section = separate + + expected = { + 'instance' => { + :private => [], + :protected => [], + :public => [@c1_m], + }, + 'class' => { + :private => [], + :protected => [], + :public => [], + }, + } + + assert_equal expected, @c1.methods_by_type(separate) + end + end -- cgit v1.2.3