summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authoralexandre184 <110398901+alexandre184@users.noreply.github.com>2023-07-15 09:36:53 +0200
committerGitHub <noreply@github.com>2023-07-15 16:36:53 +0900
commite5825de7c9f07e4f7bd2b83ce8973e19a4652916 (patch)
tree92b04125daca166707c5465402469603d33fb619 /test/ruby
parentf15123c34ce80f3928612befe2a9aaf4c9d27fda (diff)
[Bug #19769] Fix range of size 1 in `String#tr`
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8080 Merged-By: nobu <nobu@ruby-lang.org>
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_string.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 06df67de38..6cc958332f 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -2301,6 +2301,8 @@ CODE
assert_not_predicate(str, :ascii_only?)
assert_not_predicate(star, :ascii_only?)
assert_not_predicate(result, :ascii_only?, bug13950)
+
+ assert_equal(S("XYC"), S("ABC").tr("A-AB", "XY"))
end
def test_tr!
@@ -2325,6 +2327,8 @@ CODE
a = S("abc".force_encoding(Encoding::US_ASCII))
assert_nil(a.tr!(S("z"), S("\u0101")), '[ruby-core:22326]')
assert_equal(Encoding::US_ASCII, a.encoding, '[ruby-core:22326]')
+
+ assert_equal(S("XYC"), S("ABC").tr!("A-AB", "XY"))
end
def test_tr_s
@@ -2332,6 +2336,8 @@ CODE
assert_equal(S("h*o"), S("hello").tr_s(S("el"), S("*")))
assert_equal("a".hash, S("\u0101\u0101").tr_s("\u0101", "a").hash)
assert_equal(true, S("\u3041\u3041").tr("\u3041", "a").ascii_only?)
+
+ assert_equal(S("XYC"), S("ABC").tr_s("A-AB", "XY"))
end
def test_tr_s!
@@ -2344,6 +2350,8 @@ CODE
a = S("hello")
assert_equal(S("h*o"), a.tr_s!(S("el"), S("*")))
assert_equal(S("h*o"), a)
+
+ assert_equal(S("XYC"), S("ABC").tr_s!("A-AB", "XY"))
end
def test_unpack