1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rdoc/*, test/rdoc/*: Update rdoc-5.0.0.beta2

Fixed ri parse defect with left-hand matched classes.
  https://github.com/rdoc/rdoc/pull/420

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2016-09-07 22:23:38 +00:00
parent bf51c067b9
commit ba6ae341ba
37 changed files with 100 additions and 274 deletions

View file

@ -1,3 +1,9 @@
Thu Sep 8 07:23:34 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* lib/rdoc/*, test/rdoc/*: Update rdoc-5.0.0.beta2
Fixed ri parse defect with left-hand matched classes.
https://github.com/rdoc/rdoc/pull/420
Thu Sep 8 01:12:47 2016 Shugo Maeda <shugo@ruby-lang.org> Thu Sep 8 01:12:47 2016 Shugo Maeda <shugo@ruby-lang.org>
* eval.c (rb_mod_s_used_refinements): new method * eval.c (rb_mod_s_used_refinements): new method

View file

@ -65,7 +65,7 @@ module RDoc
## ##
# RDoc version you are using # RDoc version you are using
VERSION = '5.0.0.beta1' VERSION = '5.0.0.beta2'
## ##
# Method visibilities # Method visibilities

View file

@ -150,8 +150,7 @@ class RDoc::CodeObject
else else
# HACK correct fix is to have #initialize create @comment # HACK correct fix is to have #initialize create @comment
# with the correct encoding # with the correct encoding
if String === @comment and if String === @comment and @comment.empty? then
Object.const_defined? :Encoding and @comment.empty? then
@comment.force_encoding comment.encoding @comment.force_encoding comment.encoding
end end
@comment @comment
@ -427,4 +426,3 @@ class RDoc::CodeObject
end end
end end

View file

@ -200,7 +200,7 @@ class RDoc::Comment
def remove_private def remove_private
# Workaround for gsub encoding for Ruby 1.9.2 and earlier # Workaround for gsub encoding for Ruby 1.9.2 and earlier
empty = '' empty = ''
empty.force_encoding @text.encoding if Object.const_defined? :Encoding empty.force_encoding @text.encoding
@text = @text.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty) @text = @text.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty)
@text = @text.sub(%r%^\s*[#*]?--.*%m, '') @text = @text.sub(%r%^\s*[#*]?--.*%m, '')
@ -227,4 +227,3 @@ class RDoc::Comment
end end
end end

View file

@ -25,7 +25,6 @@ module RDoc::Encoding
RDoc::Encoding.set_encoding content RDoc::Encoding.set_encoding content
if Object.const_defined? :Encoding then
begin begin
encoding ||= Encoding.default_external encoding ||= Encoding.default_external
orig_encoding = content.encoding orig_encoding = content.encoding
@ -63,7 +62,6 @@ module RDoc::Encoding
return nil return nil
end end
end end
end
content content
rescue ArgumentError => e rescue ArgumentError => e
@ -103,11 +101,8 @@ module RDoc::Encoding
remove_frozen_string_literal string remove_frozen_string_literal string
return unless Object.const_defined? :Encoding
enc = Encoding.find name enc = Encoding.find name
string.force_encoding enc if enc string.force_encoding enc if enc
end end
end end

View file

@ -698,7 +698,7 @@ class RDoc::Generator::Darkfish
out_file.dirname.mkpath out_file.dirname.mkpath
out_file.open 'w', 0644 do |io| out_file.open 'w', 0644 do |io|
io.set_encoding @options.encoding if Object.const_defined? :Encoding io.set_encoding @options.encoding
@context = yield io @context = yield io
@ -744,8 +744,7 @@ class RDoc::Generator::Darkfish
erbout = 'io' erbout = 'io'
else else
template = file.read template = file.read
template = template.encode @options.encoding if template = template.encode @options.encoding
Object.const_defined? :Encoding
file_var = File.basename(file).sub(/\..*/, '') file_var = File.basename(file).sub(/\..*/, '')
@ -758,4 +757,3 @@ class RDoc::Generator::Darkfish
end end
end end

View file

@ -142,7 +142,7 @@ class RDoc::Generator::JsonIndex
FileUtils.mkdir_p index_file.dirname, :verbose => $DEBUG_RDOC FileUtils.mkdir_p index_file.dirname, :verbose => $DEBUG_RDOC
index_file.open 'w', 0644 do |io| index_file.open 'w', 0644 do |io|
io.set_encoding Encoding::UTF_8 if Object.const_defined? :Encoding io.set_encoding Encoding::UTF_8
io.write 'var search_data = ' io.write 'var search_data = '
JSON.dump data, io, 0 JSON.dump data, io, 0
@ -295,4 +295,3 @@ class RDoc::Generator::JsonIndex
end end
end end

View file

@ -79,8 +79,6 @@ class RDoc::Markup::Parser
@binary_input = nil @binary_input = nil
@current_token = nil @current_token = nil
@debug = false @debug = false
@have_encoding = Object.const_defined? :Encoding
@have_byteslice = ''.respond_to? :byteslice
@input = nil @input = nil
@input_encoding = nil @input_encoding = nil
@line = 0 @line = 0
@ -324,15 +322,7 @@ class RDoc::Markup::Parser
# The character offset for the input string at the given +byte_offset+ # The character offset for the input string at the given +byte_offset+
def char_pos byte_offset def char_pos byte_offset
if @have_byteslice then
@input.byteslice(0, byte_offset).length @input.byteslice(0, byte_offset).length
elsif @have_encoding then
matched = @binary_input[0, byte_offset]
matched.force_encoding @input_encoding
matched.length
else
byte_offset
end
end end
## ##
@ -430,11 +420,6 @@ class RDoc::Markup::Parser
@line_pos = 0 @line_pos = 0
@input = input.dup @input = input.dup
if @have_encoding and not @have_byteslice then
@input_encoding = @input.encoding
@binary_input = @input.force_encoding Encoding::BINARY
end
@s = StringScanner.new input @s = StringScanner.new input
end end
@ -556,4 +541,3 @@ class RDoc::Markup::Parser
end end
end end

View file

@ -379,23 +379,15 @@ class RDoc::Options
@visibility = :protected @visibility = :protected
@webcvs = nil @webcvs = nil
@write_options = false @write_options = false
if Object.const_defined? :Encoding then
@encoding = Encoding::UTF_8 @encoding = Encoding::UTF_8
@charset = @encoding.name @charset = @encoding.name
else
@encoding = nil
@charset = 'UTF-8'
end
end end
def init_with map # :nodoc: def init_with map # :nodoc:
init_ivars init_ivars
encoding = map['encoding'] encoding = map['encoding']
@encoding = if Object.const_defined? :Encoding then @encoding = encoding ? Encoding.find(encoding) : encoding
encoding ? Encoding.find(encoding) : encoding
end
@charset = map['charset'] @charset = map['charset']
@exclude = map['exclude'] @exclude = map['exclude']
@ -689,7 +681,6 @@ Usage: #{opt.program_name} [options] [names...]
opt.separator "Parsing options:" opt.separator "Parsing options:"
opt.separator nil opt.separator nil
if Object.const_defined? :Encoding then
opt.on("--encoding=ENCODING", "-e", Encoding.list.map { |e| e.name }, opt.on("--encoding=ENCODING", "-e", Encoding.list.map { |e| e.name },
"Specifies the output encoding. All files", "Specifies the output encoding. All files",
"read will be converted to this encoding.", "read will be converted to this encoding.",
@ -700,8 +691,6 @@ Usage: #{opt.program_name} [options] [names...]
end end
opt.separator nil opt.separator nil
end
opt.on("--locale=NAME", opt.on("--locale=NAME",
"Specifies the output locale.") do |value| "Specifies the output locale.") do |value|
@ -1242,11 +1231,10 @@ Usage: #{opt.program_name} [options] [names...]
RDoc.load_yaml RDoc.load_yaml
open '.rdoc_options', 'w' do |io| open '.rdoc_options', 'w' do |io|
io.set_encoding Encoding::UTF_8 if Object.const_defined? :Encoding io.set_encoding Encoding::UTF_8
YAML.dump self, io YAML.dump self, io
end end
end end
end end

View file

@ -170,9 +170,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
@prev_seek = nil @prev_seek = nil
@markup = @options.markup @markup = @options.markup
@track_visibility = :nodoc != @options.visibility @track_visibility = :nodoc != @options.visibility
@encoding = @options.encoding
@encoding = nil
@encoding = @options.encoding if Object.const_defined? :Encoding
reset reset
end end
@ -2158,4 +2156,3 @@ class RDoc::Parser::Ruby < RDoc::Parser
end end
end end

View file

@ -52,11 +52,10 @@ class RDoc::Parser::Simple < RDoc::Parser
def remove_private_comment comment def remove_private_comment comment
# Workaround for gsub encoding for Ruby 1.9.2 and earlier # Workaround for gsub encoding for Ruby 1.9.2 and earlier
empty = '' empty = ''
empty.force_encoding comment.encoding if Object.const_defined? :Encoding empty.force_encoding comment.encoding
comment = comment.gsub(%r%^--\n.*?^\+\+\n?%m, empty) comment = comment.gsub(%r%^--\n.*?^\+\+\n?%m, empty)
comment.sub(%r%^--\n.*%m, empty) comment.sub(%r%^--\n.*%m, empty)
end end
end end

View file

@ -6,8 +6,7 @@ Gem::Specification.new do |s|
s.name = "rdoc" s.name = "rdoc"
s.version = RDoc::VERSION s.version = RDoc::VERSION
s.required_rubygems_version = Gem::Requirement.new(">= 1.3") if s.required_rubygems_version = Gem::Requirement.new(">= 1.3")
s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"] s.require_paths = ["lib"]
s.authors = [ s.authors = [

View file

@ -340,10 +340,8 @@ option)
# Parses +filename+ and returns an RDoc::TopLevel # Parses +filename+ and returns an RDoc::TopLevel
def parse_file filename def parse_file filename
if Object.const_defined? :Encoding then
encoding = @options.encoding encoding = @options.encoding
filename = filename.encode encoding filename = filename.encode encoding
end
@stats.add_file filename @stats.add_file filename
@ -553,7 +551,6 @@ end
begin begin
require 'rubygems' require 'rubygems'
if Gem.respond_to? :find_files then
rdoc_extensions = Gem.find_files 'rdoc/discover' rdoc_extensions = Gem.find_files 'rdoc/discover'
rdoc_extensions.each do |extension| rdoc_extensions.each do |extension|
@ -564,7 +561,6 @@ begin
warn "\t#{e.backtrace.join "\n\t"}" if $DEBUG warn "\t#{e.backtrace.join "\n\t"}" if $DEBUG
end end
end end
end
rescue LoadError rescue LoadError
end end
@ -572,4 +568,3 @@ end
require 'rdoc/generator/darkfish' require 'rdoc/generator/darkfish'
require 'rdoc/generator/ri' require 'rdoc/generator/ri'
require 'rdoc/generator/pot' require 'rdoc/generator/pot'

View file

@ -908,7 +908,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
def expand_class klass def expand_class klass
ary = classes.keys.grep(Regexp.new("\\A#{klass.gsub(/(?=::|\z)/, '[^:]*')}\\z")) ary = classes.keys.grep(Regexp.new("\\A#{klass.gsub(/(?=::|\z)/, '[^:]*')}\\z"))
raise NotFoundError, klass if ary.length != 1 raise NotFoundError, klass if ary.length != 1 && ary.first != klass
ary.first ary.first
end end
@ -1480,4 +1480,3 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
end end
end end

View file

@ -82,8 +82,6 @@ module RDoc::RI::Paths
# ri documentation. # ri documentation.
def self.gemdirs filter = :latest def self.gemdirs filter = :latest
require 'rubygems' unless defined?(Gem)
ri_paths = {} ri_paths = {}
all = Gem::Specification.map do |spec| all = Gem::Specification.map do |spec|
@ -185,4 +183,3 @@ module RDoc::RI::Paths
end end
end end

View file

@ -1,5 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: false
require 'rubygems'
begin begin
gem 'rdoc' gem 'rdoc'
rescue Gem::LoadError rescue Gem::LoadError

View file

@ -1,5 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: false
require 'rubygems'
require 'rubygems/user_interaction' require 'rubygems/user_interaction'
require 'fileutils' require 'fileutils'
require 'rdoc' require 'rdoc'
@ -251,4 +250,3 @@ class RDoc::RubygemsHook
end end
end end

View file

@ -22,7 +22,6 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++ #++
require 'rubygems'
begin begin
gem 'rdoc' gem 'rdoc'
rescue Gem::LoadError rescue Gem::LoadError
@ -328,4 +327,3 @@ module Rake
end end
# :startdoc: # :startdoc:

View file

@ -1,6 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: false
require 'rubygems'
begin begin
gem 'minitest', '~> 4.0' unless defined?(Test::Unit) gem 'minitest', '~> 4.0' unless defined?(Test::Unit)
rescue NoMethodError, Gem::LoadError rescue NoMethodError, Gem::LoadError
@ -41,8 +39,6 @@ class RDoc::TestCase < MiniTest::Unit::TestCase
@top_level = nil @top_level = nil
@have_encoding = Object.const_defined? :Encoding
@RM = RDoc::Markup @RM = RDoc::Markup
RDoc::Markup::PreProcess.reset RDoc::Markup::PreProcess.reset

View file

@ -52,7 +52,7 @@ module RDoc::Text
:open_squote => encode_fallback('', encoding, '\''), :open_squote => encode_fallback('', encoding, '\''),
:trademark => encode_fallback('®', encoding, '(r)'), :trademark => encode_fallback('®', encoding, '(r)'),
} }
end if Object.const_defined? :Encoding end
## ##
# Transcodes +character+ to +encoding+ with a +fallback+ character. # Transcodes +character+ to +encoding+ with a +fallback+ character.
@ -71,7 +71,7 @@ module RDoc::Text
text.each_line do |line| text.each_line do |line|
nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do
r = "#{$1}#{$2}#{' ' * (8 - $2.size)}" r = "#{$1}#{$2}#{' ' * (8 - $2.size)}"
r.force_encoding text.encoding if Object.const_defined? :Encoding r.force_encoding text.encoding
r r
end end
@ -93,7 +93,7 @@ module RDoc::Text
end end
empty = '' empty = ''
empty.force_encoding text.encoding if Object.const_defined? :Encoding empty.force_encoding text.encoding
text.gsub(/^ {0,#{indent}}/, empty) text.gsub(/^ {0,#{indent}}/, empty)
end end
@ -160,7 +160,7 @@ module RDoc::Text
return text if text =~ /^(?>\s*)[^\#]/ return text if text =~ /^(?>\s*)[^\#]/
empty = '' empty = ''
empty.force_encoding text.encoding if Object.const_defined? :Encoding empty.force_encoding text.encoding
text.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }.gsub(/^\s+$/, empty) text.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }.gsub(/^\s+$/, empty)
end end
@ -178,7 +178,7 @@ module RDoc::Text
def strip_stars text def strip_stars text
return text unless text =~ %r%/\*.*\*/%m return text unless text =~ %r%/\*.*\*/%m
encoding = text.encoding if Object.const_defined? :Encoding encoding = text.encoding
text = text.gsub %r%Document-method:\s+[\w:.#=!?]+%, '' text = text.gsub %r%Document-method:\s+[\w:.#=!?]+%, ''
@ -199,24 +199,9 @@ module RDoc::Text
# trademark symbols in +text+ to properly encoded characters. # trademark symbols in +text+ to properly encoded characters.
def to_html text def to_html text
if Object.const_defined? :Encoding then
html = ''.encode text.encoding html = ''.encode text.encoding
encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding] encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]
else
html = ''
encoded = {
:close_dquote => '”',
:close_squote => '',
:copyright => '©',
:ellipsis => '…',
:em_dash => '—',
:en_dash => '',
:open_dquote => '“',
:open_squote => '',
:trademark => '®',
}
end
s = StringScanner.new text s = StringScanner.new text
insquotes = false insquotes = false

View file

@ -50,8 +50,6 @@ class TestRDocCodeObject < XrefTestCase
end end
def test_comment_equals_encoding def test_comment_equals_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
refute_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check' refute_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check'
input = 'text' input = 'text'
@ -64,8 +62,6 @@ class TestRDocCodeObject < XrefTestCase
end end
def test_comment_equals_encoding_blank def test_comment_equals_encoding_blank
skip "Encoding not implemented" unless Object.const_defined? :Encoding
refute_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check' refute_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check'
input = '' input = ''
@ -448,4 +444,3 @@ class TestRDocCodeObject < XrefTestCase
end end
end end

View file

@ -207,8 +207,6 @@ lines, one line per element. Lines are assumed to be separated by _sep_.
end end
def test_force_encoding def test_force_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@comment.force_encoding Encoding::UTF_8 @comment.force_encoding Encoding::UTF_8
assert_equal Encoding::UTF_8, @comment.text.encoding assert_equal Encoding::UTF_8, @comment.text.encoding
@ -343,8 +341,6 @@ lines, one line per element. Lines are assumed to be separated by _sep_.
end end
def test_remove_private_encoding def test_remove_private_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
comment = RDoc::Comment.new <<-EOS, @top_level comment = RDoc::Comment.new <<-EOS, @top_level
# This is text # This is text
#-- #--
@ -467,8 +463,6 @@ lines, one line per element. Lines are assumed to be separated by _sep_.
end end
def test_remove_private_toggle_encoding def test_remove_private_toggle_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
comment = RDoc::Comment.new <<-EOS, @top_level comment = RDoc::Comment.new <<-EOS, @top_level
# This is text # This is text
#-- #--
@ -485,8 +479,6 @@ lines, one line per element. Lines are assumed to be separated by _sep_.
end end
def test_remove_private_toggle_encoding_ruby_bug? def test_remove_private_toggle_encoding_ruby_bug?
skip "Encoding not implemented" unless Object.const_defined? :Encoding
comment = RDoc::Comment.new <<-EOS, @top_level comment = RDoc::Comment.new <<-EOS, @top_level
#-- #--
# this is private # this is private
@ -502,4 +494,3 @@ lines, one line per element. Lines are assumed to be separated by _sep_.
end end
end end

View file

@ -25,8 +25,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_class_read_file_encoding def test_class_read_file_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
expected = "# coding: utf-8\nhi everybody" expected = "# coding: utf-8\nhi everybody"
@tempfile.write expected @tempfile.write expected
@ -38,8 +36,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_class_read_file_encoding_convert def test_class_read_file_encoding_convert
skip "Encoding not implemented" unless Object.const_defined? :Encoding
content = "" content = ""
content.encode! 'ISO-8859-1' content.encode! 'ISO-8859-1'
content << "# coding: ISO-8859-1\nhi \xE9verybody" content << "# coding: ISO-8859-1\nhi \xE9verybody"
@ -53,8 +49,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_class_read_file_encoding_fail def test_class_read_file_encoding_fail
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@tempfile.write "# coding: utf-8\n\317\200" # pi @tempfile.write "# coding: utf-8\n\317\200" # pi
@tempfile.flush @tempfile.flush
@ -70,8 +64,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_class_read_file_encoding_fancy def test_class_read_file_encoding_fancy
skip "Encoding not implemented" unless Object.const_defined? :Encoding
expected = "# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody" expected = "# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody"
expected.encode! Encoding::UTF_8 expected.encode! Encoding::UTF_8
@ -84,8 +76,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_class_read_file_encoding_force_transcode def test_class_read_file_encoding_force_transcode
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@tempfile.write "# coding: utf-8\n\317\200" # pi @tempfile.write "# coding: utf-8\n\317\200" # pi
@tempfile.flush @tempfile.flush
@ -96,8 +86,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_class_read_file_encoding_guess def test_class_read_file_encoding_guess
skip "Encoding not implemented" unless Object.const_defined? :Encoding
path = File.expand_path '../test.ja.txt', __FILE__ path = File.expand_path '../test.ja.txt', __FILE__
content = RDoc::Encoding.read_file path, Encoding::UTF_8 content = RDoc::Encoding.read_file path, Encoding::UTF_8
@ -105,8 +93,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_class_read_file_encoding_invalid def test_class_read_file_encoding_invalid
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@tempfile.write "# coding: ascii\nM\xE4r" @tempfile.write "# coding: ascii\nM\xE4r"
@tempfile.flush @tempfile.flush
@ -121,8 +107,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_class_read_file_encoding_with_signature def test_class_read_file_encoding_with_signature
skip "Encoding not implemented" unless defined? ::Encoding
@tempfile.write "\xEF\xBB\xBFhi everybody" @tempfile.write "\xEF\xBB\xBFhi everybody"
@tempfile.flush @tempfile.flush
@ -133,8 +117,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_class_read_file_encoding_iso_2022_jp def test_class_read_file_encoding_iso_2022_jp
skip "Encoding not implemented" unless Object.const_defined? :Encoding
input = "# coding: ISO-2022-JP\n:\e$B%3%^%s%I\e(B:" input = "# coding: ISO-2022-JP\n:\e$B%3%^%s%I\e(B:"
@tempfile.write input @tempfile.write input
@ -155,8 +137,6 @@ class TestRDocEncoding < RDoc::TestCase
# sanity check for 1.8 # sanity check for 1.8
skip "Encoding not implemented" unless Object.const_defined? :Encoding
assert_equal Encoding::UTF_8, s.encoding assert_equal Encoding::UTF_8, s.encoding
s = "#!/bin/ruby\n# coding: UTF-8\n" s = "#!/bin/ruby\n# coding: UTF-8\n"
@ -192,8 +172,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_class_set_encoding_bad def test_class_set_encoding_bad
skip "Encoding not implemented" unless Object.const_defined? :Encoding
s = "" s = ""
expected = s.encoding expected = s.encoding
RDoc::Encoding.set_encoding s RDoc::Encoding.set_encoding s
@ -218,8 +196,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_skip_frozen_string_literal def test_skip_frozen_string_literal
skip "Encoding not implemented" unless Object.const_defined? :Encoding
expected = "# frozen_string_literal: false\nhi everybody" expected = "# frozen_string_literal: false\nhi everybody"
@tempfile.write expected @tempfile.write expected
@ -231,8 +207,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_skip_frozen_string_literal_after_coding def test_skip_frozen_string_literal_after_coding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
expected = "# coding: utf-8\n# frozen-string-literal: false\nhi everybody" expected = "# coding: utf-8\n# frozen-string-literal: false\nhi everybody"
@tempfile.write expected @tempfile.write expected
@ -244,8 +218,6 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_skip_frozen_string_literal_before_coding def test_skip_frozen_string_literal_before_coding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
expected = "# frozen_string_literal: false\n# coding: utf-8\nhi everybody" expected = "# frozen_string_literal: false\n# coding: utf-8\nhi everybody"
@tempfile.write expected @tempfile.write expected
@ -257,11 +229,8 @@ class TestRDocEncoding < RDoc::TestCase
end end
def test_sanity def test_sanity
skip "Encoding not implemented" unless Object.const_defined? :Encoding
assert_equal Encoding::US_ASCII, ''.encoding, assert_equal Encoding::US_ASCII, ''.encoding,
'If this file is not ASCII tests may incorrectly pass' 'If this file is not ASCII tests may incorrectly pass'
end end
end end

View file

@ -83,11 +83,7 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
assert_hard_link 'fonts/SourceCodePro-Bold.ttf' assert_hard_link 'fonts/SourceCodePro-Bold.ttf'
assert_hard_link 'fonts/SourceCodePro-Regular.ttf' assert_hard_link 'fonts/SourceCodePro-Regular.ttf'
encoding = if Object.const_defined? :Encoding then encoding = Regexp.escape Encoding::UTF_8.name
Regexp.escape Encoding::UTF_8.name
else
Regexp.escape 'UTF-8'
end
assert_match %r%<meta charset="#{encoding}">%, File.read('index.html') assert_match %r%<meta charset="#{encoding}">%, File.read('index.html')
assert_match %r%<meta charset="#{encoding}">%, File.read('Object.html') assert_match %r%<meta charset="#{encoding}">%, File.read('Object.html')
@ -227,4 +223,3 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
end end
end end

View file

@ -198,8 +198,6 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
end end
def test_generate_utf_8 def test_generate_utf_8
skip "Encoding not implemented" unless Object.const_defined? :Encoding
text = "5\xB0" text = "5\xB0"
text.force_encoding Encoding::ISO_8859_1 text.force_encoding Encoding::ISO_8859_1
@klass.add_comment comment(text), @top_level @klass.add_comment comment(text), @top_level
@ -322,4 +320,3 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
end end
end end

View file

@ -7,10 +7,8 @@ class TestRDocGeneratorRI < RDoc::TestCase
super super
@options = RDoc::Options.new @options = RDoc::Options.new
if Object.const_defined? :Encoding then
@options.encoding = Encoding::UTF_8 @options.encoding = Encoding::UTF_8
@store.encoding = Encoding::UTF_8 @store.encoding = Encoding::UTF_8
end
@tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_ri_#{$$}" @tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_ri_#{$$}"
FileUtils.mkdir_p @tmpdir FileUtils.mkdir_p @tmpdir
@ -57,7 +55,7 @@ class TestRDocGeneratorRI < RDoc::TestCase
store = RDoc::RI::Store.new @tmpdir store = RDoc::RI::Store.new @tmpdir
store.load_cache store.load_cache
encoding = Object.const_defined?(:Encoding) ? Encoding::UTF_8 : nil encoding = Encoding::UTF_8
assert_equal encoding, store.encoding assert_equal encoding, store.encoding
end end
@ -76,4 +74,3 @@ class TestRDocGeneratorRI < RDoc::TestCase
end end
end end

View file

@ -1,5 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: false
require 'rubygems'
require 'minitest/autorun' require 'minitest/autorun'
require 'pp' require 'pp'
@ -1882,4 +1881,3 @@ foo
end end
end end

View file

@ -8,8 +8,6 @@ class TestRDocMarkupParser < RDoc::TestCase
def setup def setup
super super
@have_byteslice = ''.respond_to? :byteslice
@RMP = @RM::Parser @RMP = @RM::Parser
end end
@ -30,11 +28,7 @@ class TestRDocMarkupParser < RDoc::TestCase
s.scan(/\S+/) s.scan(/\S+/)
if @have_byteslice or @have_encoding then
assert_equal 3, parser.char_pos(s.pos) assert_equal 3, parser.char_pos(s.pos)
else
assert_equal 4, parser.char_pos(s.pos)
end
end end
def test_get def test_get
@ -1360,8 +1354,6 @@ cat::
end end
def test_tokenize_note_utf_8 def test_tokenize_note_utf_8
skip 'Encoding not implemented' unless @have_encoding
str = <<-STR str = <<-STR
cät:: l1a cät:: l1a
l1b l1b
@ -1626,11 +1618,7 @@ Example heading:
s.scan(/\S+/) s.scan(/\S+/)
if @have_encoding or @have_byteslice then
assert_equal [3, 0], parser.token_pos(s.pos) assert_equal [3, 0], parser.token_pos(s.pos)
else
assert_equal [4, 0], parser.token_pos(s.pos)
end
end end
# HACK move to Verbatim test case # HACK move to Verbatim test case
@ -1678,4 +1666,3 @@ some more text over here
end end
end end

View file

@ -55,8 +55,6 @@ contents of a string.
end end
def test_include_file_encoding_incompatible def test_include_file_encoding_incompatible
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@tempfile.write <<-INCLUDE @tempfile.write <<-INCLUDE
# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*- # -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
@ -471,4 +469,3 @@ contents of a string.
end end
end end

View file

@ -60,7 +60,7 @@ class TestRDocOptions < RDoc::TestCase
@options.encode_with coder @options.encode_with coder
encoding = Object.const_defined?(:Encoding) ? 'UTF-8' : nil encoding = 'UTF-8'
expected = { expected = {
'charset' => 'UTF-8', 'charset' => 'UTF-8',
@ -122,8 +122,6 @@ class TestRDocOptions < RDoc::TestCase
end end
def test_encoding_default def test_encoding_default
skip "Encoding not implemented" unless Object.const_defined? :Encoding
assert_equal Encoding::UTF_8, @options.encoding assert_equal Encoding::UTF_8, @options.encoding
end end
@ -142,7 +140,6 @@ class TestRDocOptions < RDoc::TestCase
end end
def test_init_with_encoding def test_init_with_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
RDoc.load_yaml RDoc.load_yaml
@options.encoding = Encoding::IBM437 @options.encoding = Encoding::IBM437
@ -273,8 +270,6 @@ rdoc_include:
end end
def test_parse_encoding def test_parse_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@options.parse %w[--encoding Big5] @options.parse %w[--encoding Big5]
assert_equal Encoding::Big5, @options.encoding assert_equal Encoding::Big5, @options.encoding
@ -282,8 +277,6 @@ rdoc_include:
end end
def test_parse_encoding_invalid def test_parse_encoding_invalid
skip "Encoding not implemented" unless Object.const_defined? :Encoding
out, err = capture_io do out, err = capture_io do
@options.parse %w[--encoding invalid] @options.parse %w[--encoding invalid]
end end
@ -764,4 +757,3 @@ rdoc_include:
assert_equal :private, @options.visibility assert_equal :private, @options.visibility
end end
end end

View file

@ -47,8 +47,6 @@ class TestRDocParser < RDoc::TestCase
end end
def test_class_binary_large_japanese_rdoc def test_class_binary_large_japanese_rdoc
skip "Encoding not implemented" unless Object.const_defined? :Encoding
capture_io do capture_io do
begin begin
extenc, Encoding.default_external = extenc, Encoding.default_external =
@ -62,8 +60,6 @@ class TestRDocParser < RDoc::TestCase
end end
def test_class_binary_japanese_rdoc def test_class_binary_japanese_rdoc
skip "Encoding not implemented" unless Object.const_defined? :Encoding
file_name = File.expand_path '../test.ja.rdoc', __FILE__ file_name = File.expand_path '../test.ja.rdoc', __FILE__
refute @RP.binary?(file_name) refute @RP.binary?(file_name)
end end
@ -325,4 +321,3 @@ class TestRDocParser < RDoc::TestCase
end end
end end

View file

@ -48,8 +48,6 @@ class C; end
end end
def test_collect_first_comment_encoding def test_collect_first_comment_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@options.encoding = Encoding::CP852 @options.encoding = Encoding::CP852
p = util_parser <<-CONTENT p = util_parser <<-CONTENT
@ -1928,8 +1926,7 @@ end
method = "def ω() end" method = "def ω() end"
assert_equal Encoding::UTF_8, method.encoding if assert_equal Encoding::UTF_8, method.encoding
Object.const_defined? :Encoding
util_parser method util_parser method
@ -2023,7 +2020,6 @@ end
end end
def test_parse_statements_encoding def test_parse_statements_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@options.encoding = Encoding::CP852 @options.encoding = Encoding::CP852
content = <<-EOF content = <<-EOF
@ -3320,4 +3316,3 @@ end
end end
end end

View file

@ -249,7 +249,6 @@ class TestRDocRDoc < RDoc::TestCase
end end
def test_parse_file_encoding def test_parse_file_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@rdoc.options.encoding = Encoding::ISO_8859_1 @rdoc.options.encoding = Encoding::ISO_8859_1
@rdoc.store = RDoc::Store.new @rdoc.store = RDoc::Store.new
@ -454,4 +453,3 @@ class TestRDocRDoc < RDoc::TestCase
end end
end end
end end

View file

@ -852,6 +852,20 @@ Foo::Bar#bother
assert_equal 'Foo::Bar', @driver.expand_class('F::B') assert_equal 'Foo::Bar', @driver.expand_class('F::B')
end end
def test_expand_class_3
@store1 = RDoc::RI::Store.new @home_ri, :home
@top_level = @store1.add_file 'file.rb'
@cFoo = @top_level.add_class RDoc::NormalClass, 'Foo'
@mFox = @top_level.add_module RDoc::NormalModule, 'FooBar'
@store1.save
@driver.stores = [@store1]
assert_equal 'Foo', @driver.expand_class('Foo')
end
def test_expand_name def test_expand_name
util_store util_store
@ -1452,4 +1466,3 @@ Foo::Bar#bother
end end
end end

View file

@ -1,5 +1,4 @@
# frozen_string_literal: false # frozen_string_literal: false
require 'rubygems'
require 'rubygems/test_case' require 'rubygems/test_case'
require 'rdoc/rubygems_hook' require 'rdoc/rubygems_hook'
@ -249,4 +248,3 @@ class TestRDocRubygemsHook < Gem::TestCase
end end
end end

View file

@ -429,8 +429,6 @@ class TestRDocStore < XrefTestCase
end end
def test_load_cache_encoding_differs def test_load_cache_encoding_differs
skip "Encoding not implemented" unless Object.const_defined? :Encoding
cache = { cache = {
:c_class_variables => {}, :c_class_variables => {},
:c_singleton_class_variables => {}, :c_singleton_class_variables => {},
@ -991,4 +989,3 @@ class TestRDocStore < XrefTestCase
end end
end end

View file

@ -16,8 +16,6 @@ class TestRDocText < RDoc::TestCase
end end
def test_self_encode_fallback def test_self_encode_fallback
skip "Encoding not implemented" unless Object.const_defined? :Encoding
assert_equal '…', assert_equal '…',
RDoc::Text::encode_fallback('…', Encoding::UTF_8, '...') RDoc::Text::encode_fallback('…', Encoding::UTF_8, '...')
assert_equal '...', assert_equal '...',
@ -63,8 +61,6 @@ class TestRDocText < RDoc::TestCase
end end
def test_expand_tabs_encoding def test_expand_tabs_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
inn = "hello\ns\tdave" inn = "hello\ns\tdave"
inn.force_encoding Encoding::BINARY inn.force_encoding Encoding::BINARY
@ -93,8 +89,6 @@ The comments associated with
end end
def test_flush_left_encoding def test_flush_left_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
text = <<-TEXT text = <<-TEXT
we don't worry too much. we don't worry too much.
@ -303,8 +297,6 @@ paragraph will be cut off …
end end
def test_strip_hashes_encoding def test_strip_hashes_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
text = <<-TEXT text = <<-TEXT
## ##
# we don't worry too much. # we don't worry too much.
@ -338,8 +330,6 @@ paragraph will be cut off …
end end
def test_strip_newlines_encoding def test_strip_newlines_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
assert_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check' assert_equal Encoding::UTF_8, ''.encoding, 'Encoding sanity check'
text = " \n" text = " \n"
@ -389,8 +379,6 @@ paragraph will be cut off …
end end
def test_strip_stars_encoding def test_strip_stars_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
text = <<-TEXT text = <<-TEXT
/* /*
* * we don't worry too much. * * we don't worry too much.
@ -415,8 +403,6 @@ paragraph will be cut off …
end end
def test_strip_stars_encoding2 def test_strip_stars_encoding2
skip "Encoding not implemented" unless Object.const_defined? :Encoding
text = <<-TEXT text = <<-TEXT
/* /*
* * we don't worry too much. * * we don't worry too much.
@ -511,8 +497,6 @@ The comments associated with
end end
def test_to_html_encoding def test_to_html_encoding
skip "Encoding not implemented" unless Object.const_defined? :Encoding
s = '...(c)'.encode Encoding::Shift_JIS s = '...(c)'.encode Encoding::Shift_JIS
html = to_html s html = to_html s
@ -555,4 +539,3 @@ The comments associated with
end end
end end