summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-17 04:20:40 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-17 04:20:40 +0000
commit897b2177c19cf2f0dc956b9b868191f5f4d29112 (patch)
tree29839ba1e56f4fbffb73c919138f133be3a8b01b /test
parent6d886eb2557fe846957da483ab08f7c964e95679 (diff)
merge revision(s) 47716: [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_0_0@47988 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 4b7e904f4b..ada5a3ae24 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -129,6 +129,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") }