mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
New buffer for shared string
* string.c (rb_str_init): allocate new buffer if the string is shared. [Bug #15937]
This commit is contained in:
parent
148f50fc78
commit
8797f48373
2 changed files with 14 additions and 0 deletions
|
@ -79,6 +79,11 @@ class TestString < Test::Unit::TestCase
|
|||
assert_equal("mystring", str.__send__(:initialize, str, capacity: 1000))
|
||||
end
|
||||
|
||||
def test_initialize_shared
|
||||
String.new(str = "mystring" * 10).__send__(:initialize, capacity: str.bytesize)
|
||||
assert_equal("mystring", str[0, 8])
|
||||
end
|
||||
|
||||
def test_initialize_nonstring
|
||||
assert_raise(TypeError) {
|
||||
S(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue