Import RDoc 3.5.2

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2011-02-05 06:20:57 +00:00
parent d8ebf3829f
commit 8aa895294b
17 changed files with 564 additions and 290 deletions

View file

@ -47,7 +47,7 @@ method(a, b) { |c, d| ... }
def test_markup_code
tokens = [
RDoc::RubyToken::TkCONSTANT. new(0, 0, 0, 'CONSTANT'),
RDoc::RubyToken::TkKW. new(0, 0, 0, 'KW'),
RDoc::RubyToken::TkDEF. new(0, 0, 0, 'KW'),
RDoc::RubyToken::TkIVAR. new(0, 0, 0, 'IVAR'),
RDoc::RubyToken::TkOp. new(0, 0, 0, 'Op'),
RDoc::RubyToken::TkId. new(0, 0, 0, 'Id'),
@ -90,6 +90,12 @@ method(a, b) { |c, d| ... }
assert_equal 'C1', instance_method.parent_name
assert_equal '(foo)', instance_method.params
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
class_method = Marshal.load Marshal.dump(@c1.method_list.first)
assert_equal 'C1::m', class_method.full_name

View file

@ -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

View file

@ -0,0 +1,54 @@
require 'rubygems'
require 'cgi'
require 'minitest/autorun'
require 'rdoc'
require 'rdoc/code_objects'
class TestRDocContextSection < MiniTest::Unit::TestCase
def setup
@S = RDoc::Context::Section
@s = @S.new nil, 'section', '# comment'
end
def test_aref
assert_equal 'section', @s.aref
assert_equal '5Buntitled-5D', @S.new(nil, nil, nil).aref
assert_equal 'one+two', @S.new(nil, 'one two', nil).aref
end
def test_comment_equals
@s.comment = "# :section: section\n"
assert_equal "# comment", @s.comment
@s.comment = "# :section: section\n# other"
assert_equal "# comment\n# ---\n# other", @s.comment
s = @S.new nil, nil, nil
s.comment = "# :section:\n# other"
assert_equal "# other", s.comment
end
def test_extract_comment
assert_equal '', @s.extract_comment('')
assert_equal '', @s.extract_comment("# :section: b\n")
assert_equal '# c', @s.extract_comment("# :section: b\n# c")
assert_equal '# c', @s.extract_comment("# a\n# :section: b\n# c")
end
def test_sequence
_, err = capture_io do
assert_match(/\ASEC\d{5}\Z/, @s.sequence)
end
assert_equal "#{@S}#sequence is deprecated, use #aref\n", err
end
end

View file

@ -17,16 +17,26 @@ class TestRDocOptions < MiniTest::Unit::TestCase
end
def test_check_files
skip "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
out, err = capture_io do
Dir.mktmpdir do |dir|
Dir.chdir dir do
FileUtils.touch 'unreadable'
FileUtils.chmod 0, 'unreadable'
begin
unreadable = nil # variable for windows
@options.files = %w[nonexistent unreadable]
Dir.chdir dir do
if RUBY_PLATFORM =~ /mswin|mingw/ then
unreadable = open 'unreadable'
File.delete 'unreadable'
else
FileUtils.touch 'unreadable'
FileUtils.chmod 0, 'unreadable'
end
@options.check_files
@options.files = %w[nonexistent unreadable]
@options.check_files
end
ensure
unreadable.close if unreadable
end
end
end

View file

@ -2,8 +2,13 @@ XREF_DATA = <<-XREF_DATA
class C1
attr :attr
# :section: separate
attr_reader :attr_reader
attr_writer :attr_writer
# :section:
attr_accessor :attr_accessor
CONST = :const