From 15ee45080133c19d167760d577d72540a9db0ec9 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Tue, 4 Mar 2025 13:40:13 +0100 Subject: [PATCH] Move in-place interning spec to Ruby's tests Fix: https://github.com/ruby/spec/issues/1249 JRuby and TruffleRuby can't implement this behavior. While quite a lot of code out there relies on it, if it's not implemented it will simply result in sligthly less efficient code, so not the end of the world. --- spec/ruby/core/string/shared/dedup.rb | 5 ----- test/ruby/test_string.rb | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/ruby/core/string/shared/dedup.rb b/spec/ruby/core/string/shared/dedup.rb index 97b5df6ed1..1ffd6aa0fd 100644 --- a/spec/ruby/core/string/shared/dedup.rb +++ b/spec/ruby/core/string/shared/dedup.rb @@ -48,9 +48,4 @@ describe :string_dedup, shared: true do dynamic.send(@method).should_not equal("this string is frozen".send(@method).freeze) dynamic.send(@method).should equal(dynamic) end - - it "interns the provided string if it is frozen" do - dynamic = "this string is unique and frozen #{rand}".freeze - dynamic.send(@method).should equal(dynamic) - end end diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index d2099607fd..1011967fe9 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -3397,6 +3397,12 @@ CODE assert_same(str, bar, "uminus deduplicates [Feature #13077] str: #{ObjectSpace.dump(str)} bar: #{ObjectSpace.dump(bar)}") end + def test_uminus_dedup_in_place + dynamic = "this string is unique and frozen #{rand}".freeze + assert_same dynamic, -dynamic + assert_same dynamic, -dynamic.dup + end + def test_uminus_frozen return unless @cls == String