From 09af9d7f7ffe1bde891040e0232038130266ccbc Mon Sep 17 00:00:00 2001 From: drbrain Date: Thu, 29 Nov 2012 23:34:29 +0000 Subject: * lib/rdoc/generator/darkfish.rb: Silenced warning * test/rdoc/test_rdoc_rdoc.rb: ditto * lib/rdoc/markup/parser.rb: Use byteslice when available for performance * test/rdoc/test_rdoc_markup_parser.rb: Test for above * lib/rdoc/test_case.rb: ditto * lib/rdoc/parser/ruby.rb: Fixed bug parsing yield({}) * test/rdoc/test_rdoc_parser_ruby.rb (end): * lib/rdoc/rubygems_hook.rb: Skip default gems. Display generator name properly. * test/rdoc/test_rdoc_rubygems_hook.rb: Test for above * lib/rdoc/servlet.rb: Fixed typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rdoc/test_rdoc_markup_parser.rb | 10 ++++++---- test/rdoc/test_rdoc_parser_ruby.rb | 10 ++++++++++ test/rdoc/test_rdoc_rdoc.rb | 4 ---- test/rdoc/test_rdoc_rubygems_hook.rb | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/rdoc/test_rdoc_markup_parser.rb b/test/rdoc/test_rdoc_markup_parser.rb index 45f911acd1..b367b23bcc 100644 --- a/test/rdoc/test_rdoc_markup_parser.rb +++ b/test/rdoc/test_rdoc_markup_parser.rb @@ -7,13 +7,15 @@ class TestRDocMarkupParser < RDoc::TestCase def setup super + @have_byteslice = ''.respond_to? :byteslice + @RMP = @RM::Parser end def mu_pp(obj) s = '' s = PP.pp obj, s - s = s.force_encoding(Encoding.default_external) if defined? Encoding + s = s.force_encoding(Encoding.default_external) if @have_encoding s.chomp end @@ -34,7 +36,7 @@ class TestRDocMarkupParser < RDoc::TestCase s.scan(/\S+/) - if Object.const_defined? :Encoding then + if @have_byteslice or @have_encoding then assert_equal 3, parser.char_pos(s.pos) else assert_equal 4, parser.char_pos(s.pos) @@ -1364,7 +1366,7 @@ cat:: end def test_tokenize_note_utf_8 - skip 'Encoding not implemented' unless Object.const_defined? :Encoding + skip 'Encoding not implemented' unless @have_encoding str = <<-STR cät:: l1a @@ -1630,7 +1632,7 @@ Example heading: s.scan(/\S+/) - if Object.const_defined? :Encoding then + if @have_encoding or @have_byteslice then assert_equal [3, 0], parser.token_pos(s.pos) else assert_equal [4, 0], parser.token_pos(s.pos) diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb index 8168cd3f45..41b58f6615 100644 --- a/test/rdoc/test_rdoc_parser_ruby.rb +++ b/test/rdoc/test_rdoc_parser_ruby.rb @@ -1684,6 +1684,16 @@ end assert_equal "def \317\211", omega.text end + def test_parse_method_or_yield_parameters_hash + util_parser "({})\n" + + m = RDoc::AnyMethod.new nil, 'm' + + result = @parser.parse_method_or_yield_parameters m + + assert_equal '({})', result + end + def test_parse_statements_class_if util_parser <<-CODE module Foo diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index 5519ed36ac..643f1eff77 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -142,8 +142,6 @@ class TestRDocRDoc < RDoc::TestCase end def test_parse_file - pwd = Dir.pwd - @rdoc.store = RDoc::Store.new temp_dir do |dir| @@ -153,8 +151,6 @@ class TestRDocRDoc < RDoc::TestCase io.puts 'hi' end - test_txt = File.join dir, 'test.txt' - top_level = @rdoc.parse_file 'test.txt' assert_equal 'test.txt', top_level.absolute_name diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb index 63f44d3148..ceea0dfe12 100644 --- a/test/rdoc/test_rdoc_rubygems_hook.rb +++ b/test/rdoc/test_rdoc_rubygems_hook.rb @@ -100,6 +100,20 @@ class TestRDocRubygemsHook < Gem::TestCase assert rdoc.options.hyperlink_all end + def test_generate_default_gem + skip 'RubyGems 2 required' unless @a.respond_to? :default_gem? + @a.loaded_from = + File.join Gem::Specification.default_specifications_dir, 'a.gemspec' + + FileUtils.mkdir_p @a.doc_dir + FileUtils.mkdir_p File.join(@a.gem_dir, 'lib') + + @hook.generate + + refute @hook.rdoc_installed? + refute @hook.ri_installed? + end + def test_generate_disabled @hook.generate_rdoc = false @hook.generate_ri = false -- cgit v1.2.3