mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 07:26:00 +02:00
Preserve the string content at self-copying
* string.c (rb_str_init): preserve the embedded content when self-copying with a capacity. [Bug #15937]
This commit is contained in:
parent
d009e321a0
commit
28678997e4
2 changed files with 13 additions and 1 deletions
|
@ -68,6 +68,15 @@ class TestString < Test::Unit::TestCase
|
|||
assert_raise(FrozenError){ str.__send__(:initialize, encoding: 'euc-jp') }
|
||||
assert_raise(FrozenError){ str.__send__(:initialize, 'abc', encoding: 'euc-jp') }
|
||||
assert_raise(FrozenError){ str.__send__(:initialize, 'abc', capacity: 1000, encoding: 'euc-jp') }
|
||||
|
||||
str = S("")
|
||||
assert_equal("mystring", str.__send__(:initialize, "mystring"))
|
||||
str = S("mystring")
|
||||
assert_equal("mystring", str.__send__(:initialize, str))
|
||||
str = S("")
|
||||
assert_equal("mystring", str.__send__(:initialize, "mystring", capacity: 1000))
|
||||
str = S("mystring")
|
||||
assert_equal("mystring", str.__send__(:initialize, str, capacity: 1000))
|
||||
end
|
||||
|
||||
def test_initialize_nonstring
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue