From 8797f48373dcfa3ff8e748667732dea8aea4347e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 19 Jun 2019 14:03:02 +0900 Subject: New buffer for shared string * string.c (rb_str_init): allocate new buffer if the string is shared. [Bug #15937] --- test/ruby/test_string.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/ruby/test_string.rb') diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 1d81d24dba..afa3803023 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -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) -- cgit v1.2.3