summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-07 07:07:12 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-07 07:07:12 +0000
commit60f2c9cf5bea6dd99fac50c460eab4809cc30b01 (patch)
treeab40b4f7be3ff6d9fc8aede6b90e1aa9dded0aff /test
parentca9f7009db8aea70af3dd58cb6c7de0010844d22 (diff)
Upgrade to RDoc 3.5.3. Fixes [Bug #4376]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/rdoc/test_rdoc_encoding.rb35
-rw-r--r--test/rdoc/test_rdoc_markup_pre_process.rb26
-rw-r--r--test/rdoc/test_rdoc_options.rb22
-rw-r--r--test/rdoc/test_rdoc_text.rb69
4 files changed, 136 insertions, 16 deletions
diff --git a/test/rdoc/test_rdoc_encoding.rb b/test/rdoc/test_rdoc_encoding.rb
index de6c10f678..f6c113affc 100644
--- a/test/rdoc/test_rdoc_encoding.rb
+++ b/test/rdoc/test_rdoc_encoding.rb
@@ -49,6 +49,26 @@ class TestRDocEncoding < MiniTest::Unit::TestCase
assert_equal "hi \u00e9verybody", contents.sub("\r", '')
end
+ 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.flush
+
+ # FIXME 1.9 fix on windoze
+ expected.gsub!("\n", "\r\n") if RUBY_VERSION =~ /^1.9/ && RUBY_PLATFORM =~ /mswin|mingw/
+
+ contents = :junk
+
+ _, err = capture_io do
+ contents = RDoc::Encoding.read_file @tempfile.path, Encoding::US_ASCII
+ end
+
+ assert_nil contents
+
+ assert_match %r%^unable to convert%, err
+ end
+
def test_class_read_file_encoding_fancy
skip "Encoding not implemented" unless Object.const_defined? :Encoding
@@ -66,6 +86,21 @@ class TestRDocEncoding < MiniTest::Unit::TestCase
assert_equal Encoding::UTF_8, contents.encoding
end
+ 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.flush
+
+ # FIXME 1.9 fix on windoze
+ expected.gsub!("\n", "\r\n") if RUBY_VERSION =~ /^1.9/ && RUBY_PLATFORM =~ /mswin|mingw/
+
+ contents = RDoc::Encoding.read_file @tempfile.path, Encoding::US_ASCII, true
+
+ assert_equal '?', contents
+ assert_equal Encoding::US_ASCII, contents.encoding
+ end
+
def test_class_read_file_encoding_guess
skip "Encoding not implemented" unless Object.const_defined? :Encoding
diff --git a/test/rdoc/test_rdoc_markup_pre_process.rb b/test/rdoc/test_rdoc_markup_pre_process.rb
index b4db512ce3..0d2e8565be 100644
--- a/test/rdoc/test_rdoc_markup_pre_process.rb
+++ b/test/rdoc/test_rdoc_markup_pre_process.rb
@@ -1,3 +1,5 @@
+# coding: utf-8
+
require 'tempfile'
require 'rubygems'
require 'minitest/autorun'
@@ -46,6 +48,30 @@ contents of a string.
assert_equal expected, content
end
+ def test_include_file_encoding_incompatible
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
+
+ @tempfile.write <<-INCLUDE
+# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
+
+ INCLUDE
+
+ @tempfile.flush
+ @tempfile.rewind
+
+ content = @pp.include_file @file_name, '', Encoding::US_ASCII
+
+ expected = "?\n"
+
+ # FIXME 1.9 fix on windoze
+ # preprocessor uses binread, so line endings are \r\n
+ expected.gsub!("\n", "\r\n") if
+ RUBY_VERSION =~ /^1.9/ && RUBY_PLATFORM =~ /mswin|mingw/
+
+ assert_equal expected, content
+ end
+
def test_handle
text = "# :x: y\n"
out = @pp.handle text
diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb
index eaa10586fd..763f50b5f0 100644
--- a/test/rdoc/test_rdoc_options.rb
+++ b/test/rdoc/test_rdoc_options.rb
@@ -17,28 +17,17 @@ class TestRDocOptions < MiniTest::Unit::TestCase
end
def test_check_files
- expected = ''
+ skip "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
out, err = capture_io do
Dir.mktmpdir do |dir|
- if RUBY_PLATFORM =~ /mswin|mingw/ then
- @options.files = %w[nonexistent]
-
- expected = <<-EXPECTED
-file 'nonexistent' not found
- EXPECTED
- else
+ Dir.chdir dir do
FileUtils.touch 'unreadable'
FileUtils.chmod 0, 'unreadable'
@options.files = %w[nonexistent unreadable]
- expected = <<-EXPECTED
-file 'nonexistent' not found
-file 'unreadable' not readable
- EXPECTED
+ @options.check_files
end
-
- @options.check_files
end
end
@@ -46,6 +35,11 @@ file 'unreadable' not readable
assert_equal '', out
+ expected = <<-EXPECTED
+file 'nonexistent' not found
+file 'unreadable' not readable
+ EXPECTED
+
assert_equal expected, err
end
diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb
index ebc92dc1a5..96635aaa8e 100644
--- a/test/rdoc/test_rdoc_text.rb
+++ b/test/rdoc/test_rdoc_text.rb
@@ -55,6 +55,18 @@ class TestRDocText < MiniTest::Unit::TestCase
expand_tabs(".\t\t."), 'dot tab tab dot')
end
+ def test_expand_tabs_encoding
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
+
+ inn = "hello\ns\tdave"
+ inn.force_encoding Encoding::BINARY
+
+ out = expand_tabs inn
+
+ assert_equal "hello\ns dave", out
+ assert_equal Encoding::BINARY, out.encoding
+ end
+
def test_flush_left
text = <<-TEXT
@@ -73,6 +85,31 @@ The comments associated with
assert_equal expected, flush_left(text)
end
+ def test_flush_left_encoding
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
+
+ text = <<-TEXT
+
+ we don't worry too much.
+
+ The comments associated with
+ TEXT
+
+ text.force_encoding Encoding::US_ASCII
+
+ expected = <<-EXPECTED
+
+we don't worry too much.
+
+The comments associated with
+ EXPECTED
+
+ result = flush_left text
+
+ assert_equal expected, result
+ assert_equal Encoding::US_ASCII, result.encoding
+ end
+
def test_markup
def formatter() RDoc::Markup::ToHtml.new end
@@ -223,8 +260,36 @@ The comments associated with
The comments associated with
EXPECTED
- assert_equal expected, strip_stars(text)
- assert_equal Encoding::CP852, text.encoding
+ result = strip_stars text
+
+ assert_equal expected, result
+ assert_equal Encoding::CP852, result.encoding
+ end
+
+ def test_strip_stars_encoding2
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
+
+ text = <<-TEXT
+/*
+ * * we don't worry too much.
+ *
+ * The comments associated with
+ */
+ TEXT
+
+ text.force_encoding Encoding::BINARY
+
+ expected = <<-EXPECTED
+
+ * we don't worry too much.
+
+ The comments associated with
+ EXPECTED
+
+ result = strip_stars text
+
+ assert_equal expected, result
+ assert_equal Encoding::BINARY, result.encoding
end
def test_to_html_apostrophe