summaryrefslogtreecommitdiff
path: root/test/rdoc
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-21 18:35:14 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-21 18:35:14 +0000
commitcd9e9c6debcf893ea5fa70e42dc1875afaf0066f (patch)
tree5921615c87529d73ed017b58ee1ce57ef6861cfc /test/rdoc
parentc62db0676bbb8051dac4f462240962e044db6cd4 (diff)
Update to RDoc 2.1.0 r112
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc')
-rw-r--r--test/rdoc/test_rdoc_info_formatting.rb22
-rw-r--r--test/rdoc/test_rdoc_info_sections.rb4
-rw-r--r--test/rdoc/test_rdoc_parser_c.rb10
-rw-r--r--test/rdoc/test_rdoc_parser_ruby.rb139
-rw-r--r--test/rdoc/test_rdoc_ri_driver.rb12
5 files changed, 105 insertions, 82 deletions
diff --git a/test/rdoc/test_rdoc_info_formatting.rb b/test/rdoc/test_rdoc_info_formatting.rb
index bcc55dd..6c024f7 100644
--- a/test/rdoc/test_rdoc_info_formatting.rb
+++ b/test/rdoc/test_rdoc_info_formatting.rb
@@ -1,29 +1,25 @@
-$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib/'
require 'fileutils'
+require 'tmpdir'
require 'test/unit'
+
require 'rdoc/generator/texinfo'
-require 'yaml'
# From chapter 18 of the Pickaxe 3rd ed. and the TexInfo manual.
class TestRdocInfoFormatting < Test::Unit::TestCase
- OUTPUT_DIR = "/tmp/rdoc-#{$$}"
-
def setup
- # supress stdout
- $stdout = File.new('/dev/null','w')
- $stderr = File.new('/dev/null','w')
+ @output_dir = File.join Dir.tmpdir, "test_rdoc_info_formatting_#{$$}"
+ @output_file = File.join @output_dir, 'rdoc.texinfo'
- RDoc::RDoc.new.document(['--fmt=texinfo',
+ RDoc::RDoc.new.document(['--fmt=texinfo', '--quiet',
File.expand_path(__FILE__),
- "--op=#{OUTPUT_DIR}"])
- @text = File.read(OUTPUT_DIR + '/rdoc.texinfo')
+ "--op=#{@output_dir}"])
+ @text = File.read @output_file
+
# File.open('rdoc.texinfo', 'w') { |f| f.puts @text }
end
def teardown
- $stdout = STDOUT
- $stderr = STDERR
- FileUtils.rm_rf OUTPUT_DIR
+ FileUtils.rm_rf @output_dir
end
# Make sure tags like *this* do not make HTML
diff --git a/test/rdoc/test_rdoc_info_sections.rb b/test/rdoc/test_rdoc_info_sections.rb
index 4cc9826..cceba18 100644
--- a/test/rdoc/test_rdoc_info_sections.rb
+++ b/test/rdoc/test_rdoc_info_sections.rb
@@ -76,8 +76,8 @@ class TestRdocInfoSections < Test::Unit::TestCase
# if system "makeinfo --version > /dev/null"
# def test_compiles_to_info
-# makeinfo_output = `cd #{OUTPUT_DIR} && makeinfo rdoc.texinfo`
-# assert(File.exist?(File.join(OUTPUT_DIR, 'rdoc.info')),
+# makeinfo_output = `cd #{@output_dir} && makeinfo rdoc.texinfo`
+# assert(File.exist?(File.join(@output_dir, 'rdoc.info')),
# "Info file was not compiled: #{makeinfo_output}")
# end
# end
diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb
index a52018f..fd75007 100644
--- a/test/rdoc/test_rdoc_parser_c.rb
+++ b/test/rdoc/test_rdoc_parser_c.rb
@@ -18,10 +18,8 @@ class TestRdocParserC < Test::Unit::TestCase
@top_level = RDoc::TopLevel.new filename
@fn = filename
- @options = RDoc::Options.new Hash.new
- @stats = RDoc::Stats.new
-
- @progress = StringIO.new
+ @options = RDoc::Options.new
+ @stats = RDoc::Stats.new 0
end
def teardown
@@ -253,9 +251,7 @@ Init_Foo(void) {
end
def util_parser(content)
- parser = RDoc::Parser::C.new @top_level, @fn, content, @options, @stats
- parser.progress = @progress
- parser
+ RDoc::Parser::C.new @top_level, @fn, content, @options, @stats
end
end
diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb
index 2bf659e..46c95bd 100644
--- a/test/rdoc/test_rdoc_parser_ruby.rb
+++ b/test/rdoc/test_rdoc_parser_ruby.rb
@@ -13,11 +13,9 @@ class TestRdocParserRuby < Test::Unit::TestCase
@filename = @tempfile.path
util_toplevel
- @options = RDoc::Options.new Hash.new
+ @options = RDoc::Options.new
@options.quiet = true
- @stats = RDoc::Stats.new
-
- @progress = StringIO.new
+ @stats = RDoc::Stats.new 0
end
def teardown
@@ -132,6 +130,84 @@ class TestRdocParserRuby < Test::Unit::TestCase
assert_equal 'hi', @options.title
end
+ def test_parse_class
+ comment = "##\n# my method\n"
+
+ util_parser 'class Foo; end'
+
+ tk = @parser.get_tk
+
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
+
+ foo = @top_level.classes.first
+ assert_equal 'Foo', foo.full_name
+ assert_equal comment, foo.comment
+ end
+
+ def test_parse_class_nested_superclass
+ foo = RDoc::NormalModule.new 'Foo'
+ foo.parent = @top_level
+
+ util_parser "class Bar < Super\nend"
+
+ tk = @parser.get_tk
+
+ @parser.parse_class foo, RDoc::Parser::Ruby::NORMAL, tk, ''
+
+ bar = foo.classes.first
+ assert_equal 'Super', bar.superclass
+ end
+
+ def test_parse_comment
+ content = <<-EOF
+class Foo
+ ##
+ # :method: my_method
+ # my method comment
+
+end
+ EOF
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+
+ comment = "##\n# :method: foo\n# my method\n"
+
+ util_parser "\n"
+
+ tk = @parser.get_tk
+
+ @parser.parse_comment klass, tk, comment
+
+ foo = klass.method_list.first
+ assert_equal 'foo', foo.name
+ assert_equal comment, foo.comment
+
+ assert_equal [], foo.aliases
+ assert_equal nil, foo.block_params
+ assert_equal nil, foo.call_seq
+ assert_equal nil, foo.is_alias_for
+ assert_equal nil, foo.viewer
+ assert_equal true, foo.document_children
+ assert_equal true, foo.document_self
+ assert_equal '', foo.params
+ assert_equal false, foo.done_documenting
+ assert_equal false, foo.dont_rename_initialize
+ assert_equal false, foo.force_documentation
+ assert_equal klass, foo.parent
+ assert_equal false, foo.singleton
+ assert_equal :public, foo.visibility
+ assert_equal "\n", foo.text
+ assert_equal klass.current_section, foo.section
+
+ stream = [
+ tk(:COMMENT, 1, 1, nil, "# File #{@top_level.file_absolute_name}, line 1"),
+ RDoc::Parser::Ruby::NEWLINE_TOKEN,
+ tk(:SPACE, 1, 1, nil, ''),
+ ]
+
+ assert_equal stream, foo.token_stream
+ end
+
def test_parse_meta_method
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@@ -301,54 +377,19 @@ class TestRdocParserRuby < Test::Unit::TestCase
assert_equal stream, foo.token_stream
end
- def test_parse_statements_comment
- content = <<-EOF
-class Foo
- ##
- # :method: my_method
- # my method comment
-
-end
- EOF
- klass = RDoc::NormalClass.new 'Foo'
- klass.parent = @top_level
-
- comment = "##\n# :method: foo\n# my method\n"
-
- util_parser "\n"
-
- tk = @parser.get_tk
-
- @parser.parse_comment klass, tk, comment
+ def test_parse_statements_class_nested
+ comment = "##\n# my method\n"
- foo = klass.method_list.first
- assert_equal 'foo', foo.name
- assert_equal comment, foo.comment
+ util_parser "module Foo\n#{comment}class Bar\nend\nend"
- assert_equal [], foo.aliases
- assert_equal nil, foo.block_params
- assert_equal nil, foo.call_seq
- assert_equal nil, foo.is_alias_for
- assert_equal nil, foo.viewer
- assert_equal true, foo.document_children
- assert_equal true, foo.document_self
- assert_equal '', foo.params
- assert_equal false, foo.done_documenting
- assert_equal false, foo.dont_rename_initialize
- assert_equal false, foo.force_documentation
- assert_equal klass, foo.parent
- assert_equal false, foo.singleton
- assert_equal :public, foo.visibility
- assert_equal "\n", foo.text
- assert_equal klass.current_section, foo.section
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
- stream = [
- tk(:COMMENT, 1, 1, nil, "# File #{@top_level.file_absolute_name}, line 1"),
- RDoc::Parser::Ruby::NEWLINE_TOKEN,
- tk(:SPACE, 1, 1, nil, ''),
- ]
+ foo = @top_level.modules.first
+ assert_equal 'Foo', foo.full_name, 'module Foo'
- assert_equal stream, foo.token_stream
+ bar = foo.classes.first
+ assert_equal 'Foo::Bar', bar.full_name, 'class Foo::Bar'
+ assert_equal comment, bar.comment
end
def test_parse_statements_identifier_meta_method
@@ -487,8 +528,6 @@ end
def util_parser(content)
@parser = RDoc::Parser::Ruby.new @top_level, @filename, content, @options,
@stats
- @parser.progress = @progress
- @parser
end
def util_toplevel
diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb
index 5db8319..cddd4e6 100644
--- a/test/rdoc/test_rdoc_ri_driver.rb
+++ b/test/rdoc/test_rdoc_ri_driver.rb
@@ -41,11 +41,7 @@ class TestRDocRIDriver < Test::Unit::TestCase
def test_lookup_method_class_missing
def @driver.load_cache_for(klassname) end
- e = assert_raise RDoc::RI::Driver::NotFoundError do
- @driver.lookup_method 'Foo#bar', 'Foo'
- end
-
- assert_equal 'Nothing known about Foo#bar', e.message
+ assert_nil @driver.lookup_method('Foo#bar', 'Foo')
end
def test_lookup_method_dot_instance
@@ -67,11 +63,7 @@ class TestRDocRIDriver < Test::Unit::TestCase
def test_lookup_method_method_missing
def @driver.load_cache_for(klassname) {} end
- e = assert_raise RDoc::RI::Driver::NotFoundError do
- @driver.lookup_method 'Foo#bar', 'Foo'
- end
-
- assert_equal 'Nothing known about Foo#bar', e.message
+ assert_nil @driver.lookup_method('Foo#bar', 'Foo')
end
def test_parse_name