Permalink
Browse files

adding test for file open encoding bug reported at JRUBY-6572

  • Loading branch information...
plentz committed Apr 22, 2012
1 parent 0d1759c commit 9920a7e8df19017cd753e4361be47ad0b0369076
Showing with 21 additions and 0 deletions.
  1. +20 −0 file_open_test.rb
  2. +1 −0 zh_cn-utf8.txt
View
@@ -0,0 +1,20 @@
+require 'rubygems'
+require 'minitest/autorun'
+
+class FileOpenTest < MiniTest::Unit::TestCase
+
+ #works on both
+ def test_file_open_line_encoding_when_default_encoding_is_nil
+ Encoding.default_internal = nil
+ File.open('zh_cn-utf8.txt', 'rb') do |file|
+ assert_equal file.gets.encoding, Encoding::ASCII_8BIT
+ end
+ end
+
+ def test_file_open_line_encoding_when_default_encoding_is_utf8
+ Encoding.default_internal = 'utf-8'
+ File.open('zh_cn-utf8.txt', 'rb') do |file|
+ assert_equal file.gets.encoding, Encoding::ASCII_8BIT
+ end
+ end
+end
View
@@ -0,0 +1 @@
+中

0 comments on commit 9920a7e

Please sign in to comment.