diff options
Diffstat (limited to 'test/rdoc/test_rdoc_encoding.rb')
-rw-r--r-- | test/rdoc/test_rdoc_encoding.rb | 35 |
1 files changed, 35 insertions, 0 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 |