From 6ffc045a817fbdf04a6945d3c260b55b0fa1fd1e Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sun, 8 Sep 2019 11:53:27 +0200 Subject: [EXPERIMENTAL] Make Symbol#to_s return a frozen String * Always the same frozen String for a given Symbol. * Avoids extra allocations whenever calling Symbol#to_s. * See [Feature #16150] --- test/-ext-/string/test_capacity.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/-ext-/string/test_capacity.rb b/test/-ext-/string/test_capacity.rb index df59e76778..f5830a033b 100644 --- a/test/-ext-/string/test_capacity.rb +++ b/test/-ext-/string/test_capacity.rb @@ -14,7 +14,9 @@ class Test_StringCapacity < Test::Unit::TestCase end def test_capacity_shared - assert_equal 0, capa(:abcdefghijklmnopqrstuvwxyz.to_s) + str = :abcdefghijklmnopqrstuvwxyz.to_s.dup + assert Bug::String.shared_string? str + assert_equal 0, capa(str) end def test_capacity_normal -- cgit v1.2.3