mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_string.rb (test_tr): test for [ruby-core:22328].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
80d230c394
commit
7b1bbd59e1
1 changed files with 8 additions and 3 deletions
|
@ -1397,7 +1397,12 @@ class TestString < Test::Unit::TestCase
|
||||||
assert_equal(S("hal"), S("ibm").tr(S("b-z"), S("a-z")))
|
assert_equal(S("hal"), S("ibm").tr(S("b-z"), S("a-z")))
|
||||||
|
|
||||||
a = "abc".force_encoding(Encoding::US_ASCII)
|
a = "abc".force_encoding(Encoding::US_ASCII)
|
||||||
assert_equal(Encoding::US_ASCII, a.tr(S("z"), S("\u0101")).encoding)
|
assert_equal(Encoding::US_ASCII, a.tr(S("z"), S("\u0101")).encoding, '[ruby-core:22326]')
|
||||||
|
|
||||||
|
assert_equal("a".hash, "a".tr("a", "\u0101").tr("\u0101", "a").hash, '[ruby-core:22328]')
|
||||||
|
assert_equal(true, "\u0101".tr("\u0101", "a").ascii_only?)
|
||||||
|
assert_equal(true, "\u3041".tr("\u3041", "a").ascii_only?)
|
||||||
|
assert_equal(false, "\u3041\u3042".tr("\u3041", "a").ascii_only?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_tr!
|
def test_tr!
|
||||||
|
@ -1420,8 +1425,8 @@ class TestString < Test::Unit::TestCase
|
||||||
assert_equal(S("ibm"), a)
|
assert_equal(S("ibm"), a)
|
||||||
|
|
||||||
a = "abc".force_encoding(Encoding::US_ASCII)
|
a = "abc".force_encoding(Encoding::US_ASCII)
|
||||||
assert_nil(a.tr!(S("z"), S("\u0101")))
|
assert_nil(a.tr!(S("z"), S("\u0101")), '[ruby-core:22326]')
|
||||||
assert_equal(Encoding::US_ASCII, a.encoding)
|
assert_equal(Encoding::US_ASCII, a.encoding, '[ruby-core:22326]')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_tr_s
|
def test_tr_s
|
||||||
|
|
Loading…
Reference in a new issue