diff options
Diffstat (limited to 'spec/ruby/core/string/shared/dedup.rb')
-rw-r--r-- | spec/ruby/core/string/shared/dedup.rb | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/spec/ruby/core/string/shared/dedup.rb b/spec/ruby/core/string/shared/dedup.rb index 345e874583..97b5df6ed1 100644 --- a/spec/ruby/core/string/shared/dedup.rb +++ b/spec/ruby/core/string/shared/dedup.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false describe :string_dedup, shared: true do it 'returns self if the String is frozen' do input = 'foo'.freeze @@ -38,10 +39,18 @@ describe :string_dedup, shared: true do dynamic.send(@method).should equal("this string is frozen".send(@method).freeze) end - ruby_version_is "3.0" do - 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 + it "does not deduplicate a frozen string when it has instance variables" do + dynamic = %w(this string is frozen).join(' ') + dynamic.instance_variable_set(:@a, 1) + dynamic.freeze + + dynamic.send(@method).should_not equal("this string is frozen".freeze) + 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 |