aboutsummaryrefslogtreecommitdiffstats
path: root/test/rdoc/test_rdoc_context.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-16 04:59:24 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-16 04:59:24 +0000
commitb7528b5edb1f9148ea00ebb6151720e5943b3f0b (patch)
tree4caf55c53adb188170240f54b924892fbc5f9814 /test/rdoc/test_rdoc_context.rb
parent97ac172d58d695305c39d555155318edb99f1ea7 (diff)
downloadruby-b7528b5edb1f9148ea00ebb6151720e5943b3f0b.tar.gz
* lib/rdoc.rb: Import RDoc 3.7 release candidate
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc/test_rdoc_context.rb')
-rw-r--r--test/rdoc/test_rdoc_context.rb70
1 files changed, 70 insertions, 0 deletions
diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb
index 55c6c6e6e3..2fb8ef7bb7 100644
--- a/test/rdoc/test_rdoc_context.rb
+++ b/test/rdoc/test_rdoc_context.rb
@@ -17,6 +17,7 @@ class TestRDocContext < XrefTestCase
assert_equal nil, @context.parent
assert_equal :public, @context.visibility
assert_equal 1, @context.sections.length
+ assert_equal nil, @context.temporary_section
assert_empty @context.classes_hash
assert_empty @context.modules_hash
@@ -137,6 +138,13 @@ class TestRDocContext < XrefTestCase
assert_equal 'Object', object.superclass.full_name
end
+ def test_add_class_singleton
+ @c1.add_class RDoc::NormalClass, 'Klass', 'Object'
+
+ assert_includes @c1.classes.map { |k| k.full_name }, 'C1::Klass'
+ assert_includes RDoc::TopLevel.classes.map { |k| k.full_name }, 'C1::Klass'
+ end
+
def test_add_class_superclass
@c1.add_class RDoc::NormalClass, 'Klass', 'Object'
@c1.add_class RDoc::NormalClass, 'Klass', 'Other'
@@ -244,6 +252,29 @@ class TestRDocContext < XrefTestCase
assert_includes @c1.top_level.requires, req
end
+ def test_add_section
+ default_section = @context.sections.first
+
+ @context.add_section nil, '# comment'
+
+ assert_equal 1, @context.sections.length
+ assert_equal '# comment', @context.sections.first.comment
+
+ @context.add_section nil, '# new comment'
+
+ assert_equal 1, @context.sections.length
+ assert_equal "# comment\n# ---\n# new comment",
+ @context.sections.first.comment
+
+ @context.add_section 'other', ''
+
+ assert_equal 2, @context.sections.length
+
+ new_section = @context.sections.find { |section| section.title == 'other' }
+ assert new_section
+ assert_equal default_section, @context.current_section
+ end
+
def test_add_to
incl = RDoc::Include.new 'Name', 'comment'
arr = []
@@ -254,6 +285,19 @@ class TestRDocContext < XrefTestCase
assert_equal @context.current_section, incl.section
end
+ def test_add_to_temporary_section
+ incl = RDoc::Include.new 'Name', 'comment'
+ arr = []
+ section = @context.add_section 'temporary', ''
+ @context.temporary_section = section
+
+ @context.add_to arr, incl
+
+ assert_includes arr, incl
+ assert_equal @context, incl.parent
+ assert_equal section, incl.section
+ end
+
def test_add_to_no_document_self
incl = RDoc::Include.new 'Name', 'comment'
arr = []
@@ -281,6 +325,16 @@ class TestRDocContext < XrefTestCase
assert_equal %w[C3::H1 C3::H2], @c3.classes.map { |k| k.full_name }
end
+ def test_current_section
+ default_section = @context.current_section
+
+ new_section = @context.add_section 'other', ''
+ @context.temporary_section = new_section
+
+ assert_equal new_section, @context.current_section
+ assert_equal default_section, @context.current_section
+ end
+
def test_defined_in_eh
assert @c1.defined_in?(@c1.top_level)
@@ -596,6 +650,22 @@ class TestRDocContext < XrefTestCase
assert_equal [@pub, @prot, @priv], methods
end
+ def test_set_current_section
+ default_section = @context.sections.first
+
+ @context.set_current_section nil, ''
+
+ assert_equal default_section, @context.current_section
+
+ @context.set_current_section 'other', ''
+
+ new_section = @context.sections.find { |section|
+ section != default_section
+ }
+
+ assert_equal new_section, @context.current_section
+ end
+
def util_visibilities
@pub = RDoc::AnyMethod.new nil, 'pub'
@prot = RDoc::AnyMethod.new nil, 'prot'