diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-03 11:39:19 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-03 11:39:19 +0000 |
commit | f3c363c6f72d189703627538ecc918b0e31debde (patch) | |
tree | 2c7bf3ef15a283b6c8ef00fa91e2262c3f2221be /test | |
parent | 725a2369fd1ddd3ee79ee3325c07a2fd850cc15a (diff) |
merges r22505 and r22547 from trunk into ruby_1_9_1.
--
* string.c (tr_trans): should not be affected by the encoding of
replacement unless actually modified. [ruby-talk:328967]
--
* string.c (tr_trans): should recalculate coderange.
[ruby-core:22326] (reopened at [ruby-core:22328])
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_string.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index eba0256439..2315a8c560 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,11 +1418,17 @@ 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 assert_equal(S("hypo"), S("hello").tr_s(S("el"), S("yp"))) assert_equal(S("h*o"), S("hello").tr_s(S("el"), S("*"))) + assert_equal("a".hash, "\u0101\u0101".tr_s("\u0101", "a").hash) + assert_equal(true, "\u3041\u3041".tr("\u3041", "a").ascii_only?) end def test_tr_s! |