diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-27 04:13:54 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-27 04:13:54 +0000 |
commit | ab9c982cc0299435a795000d68eb9472d8ecfde0 (patch) | |
tree | dcc891fa639942f22127f5f027604931556efc9c /test/ruby/test_string.rb | |
parent | 9052a8cd948840068c8a6a51850f421fff11c887 (diff) | |
download | ruby-ab9c982cc0299435a795000d68eb9472d8ecfde0.tar.gz |
* string.c (str_new_empty): should copy also the encoding as an
empty substring. [ruby-dev:45441][Bug #6206]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_string.rb')
-rw-r--r-- | test/ruby/test_string.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 27cb3a2552..9cc193ce41 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1174,6 +1174,12 @@ class TestString < Test::Unit::TestCase assert_equal("[2, 3]", [1,2,3].slice!(1,10000).inspect, "moved from btest/knownbug") + bug6206 = '[ruby-dev:45441]' + Encoding.list.each do |enc| + next unless enc.ascii_compatible? + s = S("a:".force_encoding(enc)) + assert_equal([enc]*2, s.split(":", 2).map(&:encoding), bug6206) + end end def test_squeeze @@ -1824,6 +1830,13 @@ class TestString < Test::Unit::TestCase assert_raise(TypeError) { "hello".partition(1) } def (hyphen = Object.new).to_str; "-"; end assert_equal(%w(foo - bar), "foo-bar".partition(hyphen), '[ruby-core:23540]') + + bug6206 = '[ruby-dev:45441]' + Encoding.list.each do |enc| + next unless enc.ascii_compatible? + s = S("a:".force_encoding(enc)) + assert_equal([enc]*3, s.partition("|").map(&:encoding), bug6206) + end end def test_rpartition @@ -1832,6 +1845,13 @@ class TestString < Test::Unit::TestCase assert_raise(TypeError) { "hello".rpartition(1) } def (hyphen = Object.new).to_str; "-"; end assert_equal(%w(foo - bar), "foo-bar".rpartition(hyphen), '[ruby-core:23540]') + + bug6206 = '[ruby-dev:45441]' + Encoding.list.each do |enc| + next unless enc.ascii_compatible? + s = S("a:".force_encoding(enc)) + assert_equal([enc]*3, s.rpartition("|").map(&:encoding), bug6206) + end end def test_setter |