mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
* string.c (tr_trans): should not be affected by the encoding of
replacement unless actually modified. [ruby-talk:328967] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0ec57a60af
commit
bc59123dc0
3 changed files with 31 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue