summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-16 13:19:07 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-16 13:19:07 +0000
commit10a4543f715747b92e578e2b8d869a96e53040f0 (patch)
tree20175242eb7ac450c6ace1383c11b21e2f0a0001 /test
parente0a5ccfec19b157f21a1780cc51e652353f9d0fd (diff)
merge revision(s) r47716: [Backport #10285]
* ext/stringio/stringio.c (strio_write): ASCII-8BIT StringIO should be writable any encoding strings, without conversion. [ruby-core:65240] [Bug #10285] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/stringio/test_stringio.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index 3fbe2f7eca..07d89d16e1 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -137,6 +137,18 @@ class TestStringIO < Test::Unit::TestCase
assert_equal(Encoding::UTF_8, s.encoding, "honor the original encoding over ASCII-8BIT")
end
+ def test_set_encoding
+ bug10285 = '[ruby-core:65240] [Bug #10285]'
+ f = StringIO.new()
+ f.set_encoding(Encoding::ASCII_8BIT)
+ f.write("quz \x83 mat".b)
+ s = "foo \x97 bar".force_encoding(Encoding::WINDOWS_1252)
+ assert_nothing_raised(Encoding::CompatibilityError, bug10285) {
+ f.write(s)
+ }
+ assert_equal(Encoding::ASCII_8BIT, f.string.encoding, bug10285)
+ end
+
def test_mode_error
f = StringIO.new("", "r")
assert_raise(IOError) { f.write("foo") }