diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-24 00:47:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-24 00:47:12 +0000 |
commit | 4c0106ead6ba06487e837f32e3d80ecd8a310032 (patch) | |
tree | 6ed62b336e90bd5ee8bec51ee697bb537145b9f7 /test/ruby/test_m17n_comb.rb | |
parent | 673af3e9f27ba4282d04855febc3ad7dc7e736eb (diff) | |
download | ruby-4c0106ead6ba06487e837f32e3d80ecd8a310032.tar.gz |
string.c: smart chomp
* string.c (chompped_length): enable smart chomp for all non-dummy
encoding strings, not only default_rs.
[ruby-core:68258] [Bug #10893]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_m17n_comb.rb')
-rw-r--r-- | test/ruby/test_m17n_comb.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/ruby/test_m17n_comb.rb b/test/ruby/test_m17n_comb.rb index b7efd030fe..c35be701c6 100644 --- a/test/ruby/test_m17n_comb.rb +++ b/test/ruby/test_m17n_comb.rb @@ -659,7 +659,9 @@ class TestM17NComb < Test::Unit::TestCase combination(STRINGS, STRINGS) {|s1, s2| if !s1.ascii_only? && !s2.ascii_only? && !Encoding.compatible?(s1,s2) if s1.bytesize > s2.bytesize - assert_raise(Encoding::CompatibilityError) { s1.chomp(s2) } + assert_raise(Encoding::CompatibilityError, "#{encdump(s1)}.chomp(#{encdump(s2)})") do + s1.chomp(s2) + end end next end @@ -672,6 +674,17 @@ class TestM17NComb < Test::Unit::TestCase } end + def test_str_smart_chomp + bug10893 = '[ruby-core:68258] [Bug #10893]' + encodings = Encoding.list.select {|enc| !enc.dummy?} + combination(encodings, encodings) do |e1, e2| + expected = "abc".encode(e1) + combination(["abc\n", "abc\r\n"], ["", "\n"]) do |str, rs| + assert_equal(expected, str.encode(e1).chomp(rs.encode(e2)), bug10893) + end + end + end + def test_str_chop STRINGS.each {|s| s = s.dup |