summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-18 15:00:46 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-18 15:00:46 +0000
commit1816ba09227bd92e0ed3127cbbd9cfff9363341b (patch)
treea56a450181a7b6533bc248968a980ff31c04a81d /test
parent4afc46dc8c62b718b48f2108ed44570d97e0f9ad (diff)
merge revision(s) 60000,60001,60002: [Backport #13925]
dup String#partition return value * string.c (rb_str_partition): return duplicated receiver, when no splits. [ruby-core:82911] [Bug#13925] Author: Seiei Miyagi <hanachin@gmail.com> dup String#rpartition return value * string.c (rb_str_rpartition): return duplicated receiver, when no splits. [ruby-core:82911] [Bug#13925] Author: Seiei Miyagi <hanachin@gmail.com> dup String#split return value * string.c (rb_str_split): return duplicated receiver, when no splits. patched by tompng (tomoya ishida) in [ruby-core:82911], and the test case by Seiei Miyagi <hanachin@gmail.com>. [Bug#13925] [Fix GH-1705] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@62818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_string.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index a0584e26bf..f61aa3e2c4 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1362,6 +1362,11 @@ class TestString < Test::Unit::TestCase
}
end
+ def test_split_dupped
+ s = "abc"
+ s.split("b", 1).map(&:upcase!)
+ assert_equal("abc", s)
+ end
def test_squeeze
assert_equal(S("abc"), S("aaabbbbccc").squeeze)
assert_equal(S("aa bb cc"), S("aa bb cc").squeeze(S(" ")))
@@ -2051,7 +2056,12 @@ class TestString < Test::Unit::TestCase
end
assert_equal(["\u30E6\u30FC\u30B6", "@", "\u30C9\u30E1.\u30A4\u30F3"],
- "\u30E6\u30FC\u30B6@\u30C9\u30E1.\u30A4\u30F3".partition(/[@.]/))
+ "\u30E6\u30FC\u30B6@\u30C9\u30E1.\u30A4\u30F3".partition(/[@.]/))
+
+ bug = '[ruby-core:82911]'
+ hello = "hello"
+ hello.partition("hi").map(&:upcase!)
+ assert_equal("hello", hello, bug)
end
def test_rpartition
@@ -2071,6 +2081,11 @@ class TestString < Test::Unit::TestCase
bug8138 = '[ruby-dev:47183]'
assert_equal(["\u30E6\u30FC\u30B6@\u30C9\u30E1", ".", "\u30A4\u30F3"],
"\u30E6\u30FC\u30B6@\u30C9\u30E1.\u30A4\u30F3".rpartition(/[@.]/), bug8138)
+
+ bug = '[ruby-core:82911]'
+ hello = "hello"
+ hello.rpartition("hi").map(&:upcase!)
+ assert_equal("hello", hello, bug)
end
def test_setter