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.
This commit is contained in:
Jean Boussier 2025-03-04 13:40:13 +01:00
parent 5de02d6487
commit 15ee450801
Notes: git 2025-03-04 14:23:57 +00:00
2 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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