diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-22 05:33:07 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-22 05:33:07 +0000 |
commit | 183e2cc25399a4dc677f50de9c8a7efa2298f821 (patch) | |
tree | 6124ec61df5c6472ee6db56a72684f19be460d5f /test | |
parent | 6adab3943fcadb9ba1384d75be0606e27adc2bc1 (diff) | |
download | ruby-183e2cc25399a4dc677f50de9c8a7efa2298f821.tar.gz ruby-183e2cc25399a4dc677f50de9c8a7efa2298f821.tar.xz ruby-183e2cc25399a4dc677f50de9c8a7efa2298f821.zip |
* string.c (tr_trans): should not be affected by the encoding of
replacement unless actually modified. [ruby-talk:328967]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_string.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index eba025643..4bee19bca 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1395,6 +1395,9 @@ class TestString < Test::Unit::TestCase assert_equal(S("hippo"), S("hello").tr(S("el"), S("ip"))) assert_equal(S("*e**o"), S("hello").tr(S("^aeiou"), S("*"))) assert_equal(S("hal"), S("ibm").tr(S("b-z"), S("a-z"))) + + a = "abc".force_encoding(Encoding::US_ASCII) + assert_equal(Encoding::US_ASCII, a.tr(S("z"), S("\u0101")).encoding) end def test_tr! @@ -1415,6 +1418,10 @@ class TestString < Test::Unit::TestCase a = S("ibm") assert_nil(a.tr!(S("B-Z"), S("A-Z"))) assert_equal(S("ibm"), a) + + a = "abc".force_encoding(Encoding::US_ASCII) + assert_nil(a.tr!(S("z"), S("\u0101"))) + assert_equal(Encoding::US_ASCII, a.encoding) end def test_tr_s |